summaryrefslogtreecommitdiff
path: root/manifests/service
diff options
context:
space:
mode:
authorJerome Charaoui <jcharaoui@cmaisonneuve.qc.ca>2009-12-28 15:10:13 -0500
committerJerome Charaoui <jcharaoui@cmaisonneuve.qc.ca>2009-12-28 15:10:13 -0500
commit9c5e3367a6106fbf46aa53014cf5bfa026195d71 (patch)
treee7c84c893db844d7080d70a5881bb1d1a2f3547b /manifests/service
parentd96b70dc892bcf6e76bd6be96e9c15325f784a15 (diff)
add port and database options to mysql service, use 'hostname' plugin parameter to specify socket
Diffstat (limited to 'manifests/service')
-rw-r--r--manifests/service/mysql.pp45
1 files changed, 32 insertions, 13 deletions
diff --git a/manifests/service/mysql.pp b/manifests/service/mysql.pp
index 9d99d09..ca2ae15 100644
--- a/manifests/service/mysql.pp
+++ b/manifests/service/mysql.pp
@@ -1,29 +1,48 @@
+# Checks a mysql instance via tcp or socket
+
define nagios::service::mysql(
$ensure = present,
- $check_hostname = 'localhost',
- $check_socket = 'absent',
+ $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 {
- # Check MySQL using TCP
'tcp': {
- nagios::service { 'mysql_tcp':
- ensure => $ensure,
- check_command => "check_mysql_tcp!${check_hostname}!${check_username}!${check_password}",
+ if ($check_hostname == 'localhost') {
+ $real_check_hostname = '127.0.0.1'
+ }
+ else {
+ $real_check_hostname = $check_hostname
}
}
- # Check MySQL using local socket
default: {
- nagios::service { 'mysql_socket':
- ensure => $ensure,
- check_command => $check_socket ? {
- 'absent' => "check_mysql!${check_username}!${check_password}!${check_database}",
- default => "check_mysql_socket!${check_socket}!${check_username}!${check_password}",
- },
+ if ($check_hostname == '127.0.0.1') {
+ $real_check_hostname = 'localhost'
}
+ else {
+ $real_check_hostname = $check_hostname
+ }
+ }
+ }
+
+ if ($check_database == 'absent') {
+ nagios::service { 'mysql':
+ ensure => $ensure,
+ check_command => "check_mysql!${real_check_hostname}!${check_port}!${check_username}!${check_password}",
}
}
+ else {
+ nagios::service { "mysql_${check_database}":
+ ensure => $ensure,
+ check_command => "check_mysql_db!${real_check_hostname}!${check_port}!${check_username}!${check_password}!${check_database}",
+ }
+ }
+
}