Puppet Class: monitoring::service::mysql

Defined in:
manifests/service/mysql.pp

Overview



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'manifests/service/mysql.pp', line 2

class monitoring::service::mysql {
  include ::monitoring
  include monitoring::plugin::check_daemon
  $db_server = $::monitoring::db_server
  $db_user   = $::monitoring::db_user
  $db_pass   = $::monitoring::db_pass
  $db_port   = $::monitoring::db_port

  # # the mysql user will have to be created by hand for now
  $mysqld    = $osfamily ? {
    default => '/usr/libexec/mysqld',
    Debian  => '/usr/sbin/mysqld'
  }

  monitoring::service { 'mysql':
    service_description => 'MYSQL',
    servicegroups       => $::monitoring::host_type ? {
      'nonotify_server' => 'db',
      default           => 'db,important_sms'
    },
    check_command       => 'check_nrpe!check_mysql',
    contact_groups      => 'admins,database_admins',
    sms_contact_groups  => 'admins,database_admin_sms',
  }

  monitoring::servicedependency { 'mysql':
    dependent_service_description => 'MYSQL',
    service_description           => 'NRPE',
  }

  nrpe::plugin { 'mysql':
    plugin        => 'extra',
    check_command => 'check_mysqld',
    command_args  => "-u ${db_user} -p ${db_pass} -H ${db_server} -P ${db_port} -w ,,40,,, -c ,,100,,, -a threads_connected,threads_cached,threads_running,questions,slow_queries,open_tables -A threads_connected,threads_cached,threads_running,questions,slow_queries,open_tables,com_select,com_update,com_insert,com_insert_select,com_commit,com_delete,com_rollback,bytes_received,bytes_sent,qcache_hits,qcache_inserts,qcache_not_cached,questions",
    require       => Monitoring::Script['check_mysqld'],
  }

  monitoring::service { 'mysql_daemon':
    service_description => 'DAEMON MYSQL',
    servicegroups       => $::monitoring::host_type ? {
      'nonotify_server' => 'db',
      default           => 'db,important_sms'
    },
    check_command       => 'check_nrpe!check_mysqld_daemon',
    contact_groups      => 'admins,database_admins',
    sms_contact_groups  => 'database_admin_sms',
  }

  monitoring::servicedependency { 'mysql_daemon':
    dependent_service_description => 'DAEMON MYSQL',
    service_description           => 'NRPE',
  }

  nrpe::plugin { 'mysqld_daemon':
    sudo          => true,
    plugin        => 'extra',
    check_command => 'check_daemon',
    command_args  => $db_server ? {
      default     => "${mysqld} -p ${db_port}/tcp -H 127.0.0.1/${db_port} -n 1:1 -c sockets=0:100",
      'localhost' => "${mysqld} -n 1:1 -c sockets=0:100"
    },
  }

  monitoring::script { 'check_mysqld':
    template => 'monitoring/scripts/check_mysqld.pl.erb',
  }

  monitoring::service { 'mysql_connections':
    service_description => 'MYSQL connections',
    servicegroups       => $::monitoring::host_type ? {
      'nonotify_server' => 'db',
      default           => 'db,important_sms'
    },
    check_command       => 'check_nrpe!check_mysql_connections',
    contact_groups      => 'admins,database_admins',
    sms_contact_groups  => 'database_admin_sms',
  }

  monitoring::servicedependency { 'mysql_connections':
    dependent_service_description => 'MYSQL connections',
    service_description           => 'NRPE',
  }

  nrpe::plugin { 'mysql_connections':
    plugin        => 'extra',
    check_command => 'check_mysql_connections',
    command_args  => "-u ${db_user} -p ${db_pass} -w 50% -c 80% -H ${db_server} -P ${db_port}",
    require       => Monitoring::Script['check_mysql_connections'],
  }

  monitoring::script { 'check_mysql_connections':
    template => 'monitoring/scripts/check_mysql_connections.erb',
  }

  package { 'perl-DBD-MySQL':
    name   => $osfamily ? {
      Redhat => 'perl-DBD-MySQL',
      Debian => 'libdbd-mysql-perl'
    },
    ensure => installed,
  }

}