summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Charaoui <jcharaoui@cmaisonneuve.qc.ca>2009-12-11 15:25:20 -0500
committerJerome Charaoui <jcharaoui@cmaisonneuve.qc.ca>2009-12-11 15:25:20 -0500
commitb18a7ab8df99b4cf884ae186edd912c5e7ea2d69 (patch)
tree089dad886bad714d30a6b1d6b04d61cb98913518
parent38d8bd2bdafa5db9e6fc064a86e388958c1c70d9 (diff)
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
-rw-r--r--manifests/server.pp6
-rw-r--r--manifests/server/nagios.pp28
2 files changed, 33 insertions, 1 deletions
diff --git a/manifests/server.pp b/manifests/server.pp
index 49ef9eb..60fc93d 100644
--- a/manifests/server.pp
+++ b/manifests/server.pp
@@ -16,7 +16,11 @@ class mysql::server {
default: { include mysql::server::munin::default }
}
}
-
+
+ if $use_nagios {
+ include mysql::server::nagios
+ }
+
if $use_shorewall {
include shorewall::rules::mysql
}
diff --git a/manifests/server/nagios.pp b/manifests/server/nagios.pp
new file mode 100644
index 0000000..147667f
--- /dev/null
+++ b/manifests/server/nagios.pp
@@ -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',
+ }
+ }
+}