diff options
author | Micah <micah@leap.se> | 2016-05-24 10:19:34 -0400 |
---|---|---|
committer | Micah <micah@leap.se> | 2016-05-24 10:19:34 -0400 |
commit | 4e4f581e5ad057da6dc38a2e820600227168de57 (patch) | |
tree | da512377b1cc9c942d0e2d2ed71ced38ad78f6cc /puppet/modules/nagios/manifests/service/mysql.pp | |
parent | 85a00655cbfa53ddbae455e26700d3d9888bf9f0 (diff) | |
parent | a8c803387fe3a53cfee912470d98b1a39d8b1940 (diff) |
Merge commit 'a8c803387fe3a53cfee912470d98b1a39d8b1940' as 'puppet/modules/nagios'
Diffstat (limited to 'puppet/modules/nagios/manifests/service/mysql.pp')
-rw-r--r-- | puppet/modules/nagios/manifests/service/mysql.pp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/puppet/modules/nagios/manifests/service/mysql.pp b/puppet/modules/nagios/manifests/service/mysql.pp new file mode 100644 index 00000000..9559b17c --- /dev/null +++ b/puppet/modules/nagios/manifests/service/mysql.pp @@ -0,0 +1,58 @@ +# Checks a mysql instance via tcp or socket +define nagios::service::mysql( + $ensure = present, + $check_host = 'absent', + $check_port = '3306', + $check_username = 'nagios', + $check_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_host == 'absent') { + fail("Please specify a hostname, ip address or socket to check a mysql instance.") + } + + if $check_name != undef { + $real_check_name = "!--name $check_name" + } + + if $check_warning != undef { + $real_check_warning = "!--warning $check_warning" + } + + if $check_critical != undef { + $real_check_critical = "!--critical $check_critical" + } + + case $check_mode { + 'tcp': { + if ($check_host == 'localhost') { + $real_check_host = '127.0.0.1' + } + else { + $real_check_host = $check_host + } + } + 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!${real_check_host}!${check_port}!${check_username}!'${check_password}'!${check_health_mode}!${check_database}${real_check_name}${real_check_warning}${real_check_critical}", + } +} |