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:
parent
38d8bd2bda
commit
b18a7ab8df
2 changed files with 33 additions and 1 deletions
|
@ -17,6 +17,10 @@ class mysql::server {
|
|||
}
|
||||
}
|
||||
|
||||
if $use_nagios {
|
||||
include mysql::server::nagios
|
||||
}
|
||||
|
||||
if $use_shorewall {
|
||||
include shorewall::rules::mysql
|
||||
}
|
||||
|
|
28
manifests/server/nagios.pp
Normal file
28
manifests/server/nagios.pp
Normal 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',
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue