add nagios class to create mysql user and grant for nagios, with option to skip nagios service registration if check is done through check_ssh or check_nrpe for example

This commit is contained in:
Jerome Charaoui 2009-12-11 15:25:20 -05:00
parent 38d8bd2bda
commit b18a7ab8df
2 changed files with 33 additions and 1 deletions

View file

@ -16,7 +16,11 @@ class mysql::server {
default: { include mysql::server::munin::default } default: { include mysql::server::munin::default }
} }
} }
if $use_nagios {
include mysql::server::nagios
}
if $use_shorewall { if $use_shorewall {
include shorewall::rules::mysql include shorewall::rules::mysql
} }

View file

@ -0,0 +1,28 @@
# manifests/server/nagios.pp
class mysql::server::nagios {
case $nagios_mysql_password {
'': { fail("please specify \$nagios_mysql_password to enable nagios mysql check")}
}
mysql_user{'nagios@localhost':
password_hash => mysql_password("${nagios_mysql_password}"),
require => Package['mysql'],
}
mysql_grant{'nagios@localhost':
privileges => 'select_priv',
require => [ Mysql_user['nagios@localhost'], Package['mysql'] ],
}
# 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) {
nagios::service::mysql { 'mysql':
check_hostname => $fqdn,
check_username => 'nagios',
check_password => $nagios_mysql_password,
check_mode => 'tcp',
}
}
}