summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
Diffstat (limited to 'manifests')
-rw-r--r--manifests/defaults.pp2
-rw-r--r--manifests/defaults/commands.pp4
-rw-r--r--manifests/defaults/plugins.pp5
-rw-r--r--manifests/service/mysql.pp83
4 files changed, 51 insertions, 43 deletions
diff --git a/manifests/defaults.pp b/manifests/defaults.pp
index 32ba335..7c25ac9 100644
--- a/manifests/defaults.pp
+++ b/manifests/defaults.pp
@@ -8,5 +8,5 @@ class nagios::defaults {
include nagios::defaults::hostgroups
include nagios::defaults::templates
include nagios::defaults::timeperiods
-
+ include nagios::defaults::plugins
}
diff --git a/manifests/defaults/commands.pp b/manifests/defaults/commands.pp
index bbb6ce5..25ab1bc 100644
--- a/manifests/defaults/commands.pp
+++ b/manifests/defaults/commands.pp
@@ -90,6 +90,10 @@ class nagios::defaults::commands {
# from bind module
check_dig2:
command_line => '$USER1$/check_dig -H $HOSTADDRESS$ -l $ARG1$ --record_type=$ARG2$';
+
+ # from mysql module
+ check_mysql_health:
+ command_line => '$USER1$/check_mysql_health --hostname $ARG1$ --port $ARG2$ --username $ARG3$ --password $ARG4$ --mode $ARG5$ --database $ARG6$';
}
# notification commands
diff --git a/manifests/defaults/plugins.pp b/manifests/defaults/plugins.pp
new file mode 100644
index 0000000..1df8064
--- /dev/null
+++ b/manifests/defaults/plugins.pp
@@ -0,0 +1,5 @@
+class nagios::defaults::plugins {
+
+ nagios::plugin { 'check_mysql_health': source => 'nagios/plugins/check_mysql_health'; }
+
+}
diff --git a/manifests/service/mysql.pp b/manifests/service/mysql.pp
index ca2ae15..d501f06 100644
--- a/manifests/service/mysql.pp
+++ b/manifests/service/mysql.pp
@@ -1,48 +1,47 @@
-# Checks a mysql instance via tcp or socket
+# Checks a mysql instance via tcp or socket
define nagios::service::mysql(
- $ensure = present,
- $check_hostname = 'absent',
- $check_port = '3306',
- $check_username = 'nagios',
- $check_password = '',
- $check_database = 'absent',
- $check_mode = 'tcp'
-){
- if ($check_hostname == 'absent') {
- fail("Please specify a hostname, ip address or socket to check a mysql instance.")
- }
-
- case $check_mode {
- 'tcp': {
- if ($check_hostname == 'localhost') {
- $real_check_hostname = '127.0.0.1'
- }
- else {
- $real_check_hostname = $check_hostname
- }
- }
- default: {
- if ($check_hostname == '127.0.0.1') {
- $real_check_hostname = 'localhost'
- }
- else {
- $real_check_hostname = $check_hostname
- }
- }
- }
+ $ensure = present,
+ $check_host = 'absent',
+ $check_port = '3306',
+ $check_username = 'nagios',
+ $check_password = $nagios_mysql_password,
+ $check_database = 'information_schema',
+ $check_warning = undef,
+ $check_critical = undef,
+ $check_health_mode = $name,
+ $check_name = undef,
+ $check_name2 = undef,
+ $check_regexp = undef,
+ $check_units = undef,
+ $check_mode = 'tcp' )
+{
- if ($check_database == 'absent') {
- nagios::service { 'mysql':
- ensure => $ensure,
- check_command => "check_mysql!${real_check_hostname}!${check_port}!${check_username}!${check_password}",
- }
+ if ($check_host == 'absent') {
+ fail("Please specify a hostname, ip address or socket to check a mysql instance.")
+ }
+
+ case $check_mode {
+ 'tcp': {
+ if ($check_host == 'localhost') {
+ $real_check_host = '127.0.0.1'
+ }
+ else {
+ $real_check_host = $check_host
+ }
}
- else {
- nagios::service { "mysql_${check_database}":
- ensure => $ensure,
- check_command => "check_mysql_db!${real_check_hostname}!${check_port}!${check_username}!${check_password}!${check_database}",
- }
+ default: {
+ if ($check_host == '127.0.0.1') {
+ $real_check_host = 'localhost'
+ }
+ else {
+ $real_check_host = $check_host
+ }
}
-
+ }
+
+ nagios::service { "mysql_health_${name}":
+ ensure => $ensure,
+ check_command => "check_mysql_health!${check_host}!${check_port}!${check_username}!${check_password}!${name}!${check_database}",
+ }
}