diff options
author | Micah Anderson <micah@riseup.net> | 2010-09-27 13:18:51 -0400 |
---|---|---|
committer | Micah Anderson <micah@riseup.net> | 2010-09-27 13:18:51 -0400 |
commit | 784bd6271f46f72b84f28c7e3a346c7fa86b9baa (patch) | |
tree | 85045f3a393b904ec9e06b55b2600b05def34862 /manifests | |
parent | c4fa87912095d35e48c5b1a5f7c6f3b589c73e69 (diff) |
add a more advanced mysql health check plugin:
* create a mysql::server::nagios::base class with the common parts needed for the basic plugin, and the health plugin
* make mysql::server:nagios inherit mysql::server:nagios::base
* create a new class mysql::server::nagios::check_health inheriting ::base
the nagios module has also received a new define to setup the different nagios::service pieces for the different health check modes that might be desired
its assumed you would setup the different health check modes in site-mysql/init.pp as different hosts will require different modes and/or parameters, for example:
class site-mysql::server {
include mysql::server::nagios::check_health
nagios::service::mysql_health { [ 'connection-time', 'uptime', 'threads-connected', 'threadcache-hitrate' ]:
require => Mysql_grant[$nagios_mysql_user],
}
case $hostname {
"eider": {
nagios::service::mysql_health { [ 'slave-io-running', 'slave-sql-running', 'slave-lag' ]:
require => Mysql_grant[$nagios_mysql_user],
}
}
}
}
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/server/nagios.pp | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/manifests/server/nagios.pp b/manifests/server/nagios.pp index 4c1c153..1815882 100644 --- a/manifests/server/nagios.pp +++ b/manifests/server/nagios.pp @@ -1,10 +1,24 @@ # manifests/server/nagios.pp -class mysql::server::nagios { - case $nagios_mysql_password { - '': { fail("please specify \$nagios_mysql_password to enable nagios mysql check")} - } - +class mysql::server::nagios::base { + + case $nagios_mysql_password { + '': { fail("please specify \$nagios_mysql_password to enable nagios mysql check")} + } + + mysql_user{$nagios_mysql_user: + password_hash => mysql_password("${nagios_mysql_password}"), + require => Package['mysql'], + } + + mysql_grant{$nagios_mysql_user: + privileges => 'select_priv', + require => [ Mysql_user[$nagios_mysql_user], Package['mysql'] ], + } +} + +class mysql::server::nagios inherits mysql::server::nagios::base { + # Flip this variable if you need to check MySQL through check_ssh or check_nrpe, # in that case you will have to manually define nagios::service::mysql if ($nagios_mysql_notcp != true) { @@ -20,14 +34,28 @@ class mysql::server::nagios { else { $nagios_mysql_user = 'nagios@localhost' } - - mysql_user{$nagios_mysql_user: - password_hash => mysql_password("${nagios_mysql_password}"), - require => Package['mysql'], - } +} - mysql_grant{$nagios_mysql_user: - privileges => 'select_priv', - require => [ Mysql_user[$nagios_mysql_user], Package['mysql'] ], - } +class mysql::server::nagios::check_health inherits mysql::server::nagios::base { + + nagios::plugin{'check_mysql_health': + source => 'mysql/nagios/check_mysql_health'; + } + + @@nagios_command{ + 'check_mysql_health': + command_line => '$USER1$/check_mysql_health --hostname $ARG1$ --port $ARG2$ --username $ARG3$ --password $ARG4$ --mode $ARG5$ --database $ARG6$', + require => Nagios::Plugin['check_mysql_health']; + } + + case $mysql_nagios_user { + '': { $mysql_nagios_user = 'nagios' } + } + + if ($nagios_mysql_notcp != true) { + $nagios_mysql_user = 'nagios@%' + } + else { + $nagios_mysql_user = 'nagios@localhost' + } } |