diff options
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/base.pp | 7 | ||||
-rw-r--r-- | manifests/command/imap_pop3.pp | 14 | ||||
-rw-r--r-- | manifests/command/nrpe.pp | 14 | ||||
-rw-r--r-- | manifests/command/nrpe_timeout.pp | 11 | ||||
-rw-r--r-- | manifests/command/smtp.pp | 24 | ||||
-rw-r--r-- | manifests/defaults/commands.pp | 6 | ||||
-rw-r--r-- | manifests/irc_bot.pp | 84 | ||||
-rw-r--r-- | manifests/irc_bot/base.pp | 69 | ||||
-rw-r--r-- | manifests/irc_bot/centos.pp | 7 | ||||
-rw-r--r-- | manifests/irc_bot/disable.pp | 8 | ||||
-rw-r--r-- | manifests/nrpe.pp | 22 | ||||
-rw-r--r-- | manifests/nrpe/base.pp | 50 | ||||
-rw-r--r-- | manifests/nrpe/command.pp | 33 | ||||
-rw-r--r-- | manifests/nrpe/freebsd.pp | 16 | ||||
-rw-r--r-- | manifests/nrpe/linux.pp | 9 | ||||
-rw-r--r-- | manifests/nrpe/xinetd.pp | 11 | ||||
-rw-r--r-- | manifests/nsca/server.pp | 1 | ||||
-rw-r--r-- | manifests/service.pp | 21 | ||||
-rw-r--r-- | manifests/service/imap.pp | 32 | ||||
-rw-r--r-- | manifests/service/mysql.pp | 14 | ||||
-rw-r--r-- | manifests/service/pop.pp | 32 |
21 files changed, 396 insertions, 89 deletions
diff --git a/manifests/base.pp b/manifests/base.pp index 0f8b777..d4d6590 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -26,6 +26,13 @@ class nagios::base { mode => 0644, owner => root, group => root; } + file { 'nagios_commands_cfg': + path => "${nagios::defaults::vars::int_nagios_cfgdir}/commands.cfg", + ensure => present, + notify => Service['nagios'], + mode => 0644, owner => root, group => root; + } + file { 'nagios_cgi_cfg': path => "${nagios::defaults::vars::int_cfgdir}/cgi.cfg", source => [ "puppet:///modules/site_nagios/configs/${::fqdn}/cgi.cfg", diff --git a/manifests/command/imap_pop3.pp b/manifests/command/imap_pop3.pp index 174b09c..3735136 100644 --- a/manifests/command/imap_pop3.pp +++ b/manifests/command/imap_pop3.pp @@ -1,7 +1,15 @@ class nagios::command::imap_pop3 { - nagios_command{ - 'check_imap': - command_line => '$USER1$/check_imap -H $ARG1$ -p $ARG2$'; + case $operatingsystem { + debian,ubuntu: { } # Debian/Ubuntu already define those checks + default: { + nagios_command { + 'check_imap': + command_line => '$USER1$/check_imap -H $ARG1$ -p $ARG2$'; + } + } + } + + nagios_command { 'check_imap_ssl': command_line => '$USER1$/check_imap -H $ARG1$ -p $ARG2$ -S'; 'check_pop3': diff --git a/manifests/command/nrpe.pp b/manifests/command/nrpe.pp new file mode 100644 index 0000000..7539a26 --- /dev/null +++ b/manifests/command/nrpe.pp @@ -0,0 +1,14 @@ +class nagios::command::nrpe { + + # this command runs a program $ARG1$ with arguments $ARG2$ + nagios_command { + 'check_nrpe': + command_line => '/usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$' + } + + # this command runs a program $ARG1$ with no arguments + nagios_command { + 'check_nrpe_1arg': + command_line => '/usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$' + } +} diff --git a/manifests/command/nrpe_timeout.pp b/manifests/command/nrpe_timeout.pp new file mode 100644 index 0000000..3415566 --- /dev/null +++ b/manifests/command/nrpe_timeout.pp @@ -0,0 +1,11 @@ +class nagios::command::nrpe_timeout { + nagios_command { + 'check_nrpe_timeout': + command_line => '/usr/lib/nagios/plugins/check_nrpe -t $ARG1$ -H $HOSTADDRESS$ -c $ARG2$ -a $ARG3$' + } + + nagios_command { + 'check_nrpe_1arg_timeout': + command_line => '/usr/lib/nagios/plugins/check_nrpe -t $ARG1$ -H $HOSTADDRESS$ -c $ARG2$' + } +} diff --git a/manifests/command/smtp.pp b/manifests/command/smtp.pp index 04f8543..29d97f8 100644 --- a/manifests/command/smtp.pp +++ b/manifests/command/smtp.pp @@ -1,14 +1,22 @@ class nagios::command::smtp { - nagios_command{ - 'check_smtp': - command_line => '$USER1$/check_smtp -H $ARG1$ -p $ARG2$'; + case $operatingsystem { + debian,ubuntu: { } # Debian/Ubuntu already define those checks + default: { + nagios_command { + 'check_smtp': + command_line => '$USER1$/check_smtp -H $ARG1$ -p $ARG2$'; + 'check_ssmtp': + command_line => '$USER1$/check_ssmtp -H $ARG1$ -p $ARG2$ -S'; + } + } + } + + nagios_command { 'check_smtp_tls': - command_line => '$USER1$/check_smtp -H $ARG1$ -p $ARG2$ -S'; + command_line => '$USER1$/check_smtp -H $ARG1$ -p $ARG2$ -S'; 'check_smtp_cert': - command_line => '$USER1$/check_smtp -H $ARG1$ -p $ARG2$ -S -D $ARG3$'; - 'check_ssmtp': - command_line => '$USER1$/check_ssmtp -H $ARG1$ -p $ARG2$ -S'; + command_line => '$USER1$/check_smtp -H $ARG1$ -p $ARG2$ -S -D $ARG3$'; 'check_ssmtp_cert': - command_line => '$USER1$/check_ssmtp -H $ARG1$ -p $ARG2$ -S -D $ARG3$'; + command_line => '$USER1$/check_ssmtp -H $ARG1$ -p $ARG2$ -S -D $ARG3$'; } } diff --git a/manifests/defaults/commands.pp b/manifests/defaults/commands.pp index 195c8e3..bb19638 100644 --- a/manifests/defaults/commands.pp +++ b/manifests/defaults/commands.pp @@ -29,6 +29,8 @@ class nagios::defaults::commands { command_line => '$USER1$/check_tcp -H $ARG1$ -p $ARG2$'; check_jabber: command_line => '$USER1$/check_jabber -H $ARG1$'; + check_git: + command_line => '$USER1$/check_tcp -H $ARG1$ -p 9418'; } } default: { @@ -109,7 +111,7 @@ class nagios::defaults::commands { # from mysql module check_mysql_health: - command_line => '$USER1$/check_mysql_health --hostname $ARG1$ --port $ARG2$ --username $ARG3$ --password $ARG4$ --mode $ARG5$ --database $ARG6$'; + command_line => '$USER1$/check_mysql_health --hostname $ARG1$ --port $ARG2$ --username $ARG3$ --password $ARG4$ --mode $ARG5$ --database $ARG6$ $ARG7$ $ARG8$'; # better check_dns check_dns2: @@ -129,7 +131,7 @@ class nagios::defaults::commands { nagios_command { 'notify-host-by-email': - command_line => "/usr/bin/printf \"%b\" \"***** Nagios *****\\n\\nNotification Type: \$NOTIFICATIONTYPE\$\\nHost: \\$HOSTNAME\\$\\nState: \$HOSTSTATE\$\\nAddress: \$HOSTADDRESS\$\\nInfo: \$HOSTOUTPUT\$\\n\\nDate/Time: \$LONGDATETIME\$\\n\" | ${mail_cmd_location} -s \"** \$NOTIFICATIONTYPE\$ Host Alert: \$HOSTNAME\$ is \$HOSTSTATE\$ **\" \$CONTACTEMAIL\$"; + command_line => "/usr/bin/printf \"%b\" \"***** Nagios *****\\n\\nNotification Type: \$NOTIFICATIONTYPE\$\\nHost: \$HOSTNAME\$\\nState: \$HOSTSTATE\$\\nAddress: \$HOSTADDRESS\$\\nInfo: \$HOSTOUTPUT\$\\n\\nDate/Time: \$LONGDATETIME\$\\n\" | ${mail_cmd_location} -s \"** \$NOTIFICATIONTYPE\$ Host Alert: \$HOSTNAME\$ is \$HOSTSTATE\$ **\" \$CONTACTEMAIL\$"; 'notify-service-by-email': command_line => "/usr/bin/printf \"%b\" \"***** Nagios *****\\n\\nNotification Type: \$NOTIFICATIONTYPE\$\\n\\nService: \$SERVICEDESC\$\\nHost: \$HOSTALIAS\$\\nAddress: \$HOSTADDRESS\$\\nState: \$SERVICESTATE\$\\n\\nDate/Time: \$LONGDATETIME\$\\n\\nAdditional Info:\\n\\n\$SERVICEOUTPUT\$\" | ${mail_cmd_location} -s \"** \$NOTIFICATIONTYPE\$ Service Alert: \$HOSTALIAS\$/\$SERVICEDESC\$ is \$SERVICESTATE\$ **\" \$CONTACTEMAIL\$"; } diff --git a/manifests/irc_bot.pp b/manifests/irc_bot.pp index 77c5fa8..a034fe0 100644 --- a/manifests/irc_bot.pp +++ b/manifests/irc_bot.pp @@ -1,83 +1,21 @@ -class nagios::irc_bot( - $nsa_socket = 'absent', - $nsa_server, - $nsa_port = 6667, - $nsa_nickname, - $nsa_password = '', - $nsa_channel, - $nsa_pidfile = 'absent', - $nsa_realname = 'Nagios' -) { - $real_nsa_socket = $nsa_socket ? { - 'absent' => $::operatingsystem ? { - centos => '/var/run/nagios-nsa/nsa.socket', - default => '/var/run/nagios3/nsa.socket' - }, - default => $nsa_socket, - } - $real__nsa_pidfile = $nsa_pidfile ? { - 'absent' => $::operatingsystem ? { - centos => '/var/run/nagios-nsa/nsa.pid', - default => '/var/run/nagios3/nsa.pid' - }, - default => $nsa_pidfile, - } - - file { - '/usr/local/bin/riseup-nagios-client.pl': - source => 'puppet:///modules/nagios/irc_bot/riseup-nagios-client.pl', - owner => root, group => root, mode => 0755; - '/usr/local/bin/riseup-nagios-server.pl': - source => 'puppet:///modules/nagios/irc_bot/riseup-nagios-server.pl', - owner => root, group => root, mode => 0755; - '/etc/init.d/nagios-nsa': - content => template("nagios/irc_bot/${::operatingsystem}/nagios-nsa.sh.erb"), - require => File['/usr/local/bin/riseup-nagios-server.pl'], - owner => root, group => root, mode => 0755; - '/etc/nagios_nsa.cfg': - ensure => present, - content => template('nagios/irc_bot/nsa.cfg.erb'), - owner => nagios, group => root, mode => 0400; - } - - package { 'libnet-irc-perl': - ensure => present, +class nagios::irc_bot { + if ( ! ($nsa_server and $nsa_nickname and $nsa_channel) ) { + fail("Please provide values at least for \$nsa_server, \$nsa_nickname and \$nsa_channel") } - service { "nagios-nsa": - ensure => "running", - hasstatus => true, - require => [ File["/etc/nagios_nsa.cfg"], - Package["libnet-irc-perl"], - Service['nagios'] ], - } - - case $::operatingsystem { + case $operatingsystem { centos: { - Package['libnet-irc-perl']{ - name => 'perl-Net-IRC', - } - Service['nagios-nsa']{ - enable => true, - } + $nsa_default_socket = '/var/run/nagios-nsa/nsa.socket' + $nsa_default_pidfile = '/var/run/nagios-nsa/nsa.pid' + include nagios::irc_bot::centos } - debian,ubuntu: { - exec { "nagios_nsa_init_script": - command => "/usr/sbin/update-rc.d nagios-nsa defaults", - unless => "/bin/ls /etc/rc3.d/ | /bin/grep nagios-nsa", - require => File["/etc/init.d/nagios-nsa"], - before => Service['nagios-nsa'], - } + default: { + $nsa_default_socket = '/var/run/nagios3/nsa.socket' + $nsa_default_pidfile = '/var/run/nagios3/nsa.pid' + include nagios::irc_bot::base } } - nagios_command { - 'notify-by-irc': - command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($SERVICEDESC$) $NOTIFICATIONTYPE$ n.$SERVICEATTEMPT$ $SERVICESTATETYPE$ $SERVICEEXECUTIONTIME$s $SERVICELATENCY$s $SERVICEOUTPUT$ $SERVICEPERFDATA$"'; - 'host-notify-by-irc': - command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($HOSTALIAS$) $NOTIFICATIONTYPE$ n.$HOSTATTEMPT$ $HOSTSTATETYPE$ took $HOSTEXECUTIONTIME$s $HOSTOUTPUT$ $HOSTPERFDATA$ $HOSTLATENCY$s"'; - } - if $nagios::manage_shorewall { include shorewall::rules::out::irc } diff --git a/manifests/irc_bot/base.pp b/manifests/irc_bot/base.pp new file mode 100644 index 0000000..6fab2ac --- /dev/null +++ b/manifests/irc_bot/base.pp @@ -0,0 +1,69 @@ +class nagios::irc_bot::base { + + # Default values for the two first variables are defined in nagios::irc_bot + $nsa_socket = $nsa_socket ? { + '' => $nsa_default_socket, + default => $nsa_socket, + } + $nsa_pidfile = $nsa_pidfile ? { + '' => $nsa_default_pidfile, + default => $nsa_pidfile, + } + $nsa_port = $nsa_port ? { + '' => '6667', + default => $nsa_port, + } + $nsa_realname = $nsa_realname ? { + '' => 'Nagios', + default => $nsa_realname, + } + + if (! $nsa_password) { + $nsa_password = '' + } + + if (! $nsa_usenotices) { + $nsa_usenotices = '' + } + + file { "/usr/local/bin/riseup-nagios-client.pl": + owner => root, group => 0, mode => 0755, + source => "puppet:///modules/nagios/irc_bot/riseup-nagios-client.pl", + } + file { "/usr/local/bin/riseup-nagios-server.pl": + owner => root, group => 0, mode => 0755, + source => "puppet:///modules/nagios/irc_bot/riseup-nagios-server.pl", + } + file { "/etc/init.d/nagios-nsa": + owner => root, group => 0, mode => 0755, + content => template("nagios/irc_bot/${operatingsystem}/nagios-nsa.sh.erb"), + require => File["/usr/local/bin/riseup-nagios-server.pl"], + } + file { "/etc/nagios_nsa.cfg": + ensure => present, + owner => nagios, group => 0, mode => 0400, + content => template('nagios/irc_bot/nsa.cfg.erb'), + notify => Service["nagios-nsa"], + } + + package { "libnet-irc-perl": + ensure => present, + } + + service { "nagios-nsa": + ensure => "running", + hasstatus => true, + enable => true, + require => [File["/etc/nagios_nsa.cfg"], + File["/etc/init.d/nagios-nsa"], + Package["libnet-irc-perl"], + Service['nagios'] ], + } + + nagios_command { + "notify-by-irc": + command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($SERVICEDESC$) $NOTIFICATIONTYPE$ $SERVICEATTEMPT$/$MAXSERVICEATTEMPTS$ $SERVICESTATETYPE$ $SERVICEEXECUTIONTIME$s $SERVICELATENCY$s $SERVICEOUTPUT$ $SERVICEPERFDATA$"'; + "host-notify-by-irc": + command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($HOSTALIAS$) $NOTIFICATIONTYPE$ $HOSTATTEMPT$/$MAXHOSTATTEMPTS$ $HOSTSTATETYPE$ took $HOSTEXECUTIONTIME$s $HOSTOUTPUT$ $HOSTPERFDATA$ $HOSTLATENCY$s"'; + } +} diff --git a/manifests/irc_bot/centos.pp b/manifests/irc_bot/centos.pp new file mode 100644 index 0000000..e77e93a --- /dev/null +++ b/manifests/irc_bot/centos.pp @@ -0,0 +1,7 @@ +class nagios::irc_bot::centos inherits nagios::irc_bot::base { + + Package['libnet-irc-perl']{ + name => 'perl-Net-IRC', + } + +} diff --git a/manifests/irc_bot/disable.pp b/manifests/irc_bot/disable.pp new file mode 100644 index 0000000..d6b7c55 --- /dev/null +++ b/manifests/irc_bot/disable.pp @@ -0,0 +1,8 @@ +class nagios::irc_bot::disable inherits nagios::irc_bot::base { + + Service['nagios-nsa'] { + ensure => stopped, + enable => false, + } + +} diff --git a/manifests/nrpe.pp b/manifests/nrpe.pp new file mode 100644 index 0000000..5c05ed4 --- /dev/null +++ b/manifests/nrpe.pp @@ -0,0 +1,22 @@ +class nagios::nrpe { + + case $operatingsystem { + 'FreeBSD': { + if $nagios_nrpe_cfgdir == '' { $nagios_nrpe_cfgdir = '/usr/local/etc' } + if $nagios_nrpe_pid_file == '' { $nagios_nrpe_pid_file = '/var/spool/nagios/nrpe2.pid' } + if $nagios_plugin_dir == '' { $nagios_plugin_dir = '/usr/local/libexec/nagios' } + + include nagios::nrpe::freebsd + } + default: { + if $nagios_nrpe_pid_file == '' { $nagios_nrpe_pid_file = '/var/run/nrpe.pid' } + if $nagios_plugin_dir == '' { $nagios_plugin_dir = '/usr/lib/nagios/plugins' } + + case $kernel { + linux: { include nagios::nrpe::linux } + default: { include nagios::nrpe::base } + } + } + } + +} diff --git a/manifests/nrpe/base.pp b/manifests/nrpe/base.pp new file mode 100644 index 0000000..17abb04 --- /dev/null +++ b/manifests/nrpe/base.pp @@ -0,0 +1,50 @@ +class nagios::nrpe::base { + + if $nagios_nrpe_cfgdir == '' { $nagios_nrpe_cfgdir = '/etc/nagios' } + if $processorcount == '' { $processorcount = 1 } + + package { "nagios-nrpe-server": ensure => present; + "nagios-plugins-basic": ensure => present; + "libwww-perl": ensure => present; # for check_apache + } + + # Special-case lenny. the package doesn't exist + if $lsbdistcodename != 'lenny' { + package { "libnagios-plugin-perl": ensure => present; } + } + + file { [ $nagios_nrpe_cfgdir, "$nagios_nrpe_cfgdir/nrpe.d" ]: + ensure => directory } + + if $nagios_nrpe_dont_blame == '' { $nagios_nrpe_dont_blame = 1 } + file { "$nagios_nrpe_cfgdir/nrpe.cfg": + content => template('nagios/nrpe/nrpe.cfg'), + owner => root, group => 0, mode => 644; + } + + # default commands + nagios::nrpe::command { "basic_nrpe": + source => [ "puppet:///modules/site-nagios/configs/nrpe/nrpe_commands.${fqdn}.cfg", + "puppet:///modules/site-nagios/configs/nrpe/nrpe_commands.cfg", + "puppet:///modules/nagios/nrpe/nrpe_commands.cfg" ], + } + # the check for load should be customized for each server based on number + # of CPUs and the type of activity. + $warning_1_threshold = 7 * $processorcount + $warning_5_threshold = 6 * $processorcount + $warning_15_threshold = 5 * $processorcount + $critical_1_threshold = 10 * $processorcount + $critical_5_threshold = 9 * $processorcount + $critical_15_threshold = 8 * $processorcount + nagios::nrpe::command { "check_load": + command_line => "${nagios_plugin_dir}/check_load -w ${warning_1_threshold},${warning_5_threshold},${warning_15_threshold} -c ${critical_1_threshold},${critical_5_threshold},${critical_15_threshold}", + } + + service { "nagios-nrpe-server": + ensure => running, + enable => true, + pattern => "nrpe", + subscribe => File["$nagios_nrpe_cfgdir/nrpe.cfg"], + require => Package["nagios-nrpe-server"], + } +} diff --git a/manifests/nrpe/command.pp b/manifests/nrpe/command.pp new file mode 100644 index 0000000..e6ebdae --- /dev/null +++ b/manifests/nrpe/command.pp @@ -0,0 +1,33 @@ +define nagios::nrpe::command ( + $ensure = present, + $command_line = '', + $source = '' ) +{ + if ($command_line == '' and $source == '') { + fail ( "Either one of 'command_line' or 'source' must be given to nagios::nrpe::command." ) + } + + if $nagios_nrpe_cfg_dir == '' { + $nagios_nrpe_cfgdir = $nagios::nrpe::base::nagios_nrpe_cfgdir + } + + file { "$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg": + ensure => $ensure, + mode => 644, owner => root, group => 0, + notify => Service['nagios-nrpe-server'], + require => File [ "$nagios_nrpe_cfgdir/nrpe.d" ] + } + + case $source { + '': { + File["$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg"] { + content => template( "nagios/nrpe/nrpe_command.erb" ), + } + } + default: { + File["$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg"] { + source => $source, + } + } + } +} diff --git a/manifests/nrpe/freebsd.pp b/manifests/nrpe/freebsd.pp new file mode 100644 index 0000000..063b79b --- /dev/null +++ b/manifests/nrpe/freebsd.pp @@ -0,0 +1,16 @@ +class nagios::nrpe::freebsd inherits nagios::nrpe::base { + + Package["nagios-nrpe-server"] { name => "nrpe" } + Package["nagios-plugins-basic"] { name => "nagios-plugins" } + Package["libnagios-plugin-perl"] { name => "p5-Nagios-Plugin" } + Package["libwww-perl"] { name => "p5-libwww" } + + # TODO check_cpustats.sh is probably not working as of now. the package 'sysstat' is not available under FreeBSD + + Service["nagios-nrpe-server"] { + pattern => "^/usr/local/sbin/nrpe2", + path => "/usr/local/etc/rc.d", + name => "nrpe2", + hasstatus => "false", + } +} diff --git a/manifests/nrpe/linux.pp b/manifests/nrpe/linux.pp new file mode 100644 index 0000000..14e007f --- /dev/null +++ b/manifests/nrpe/linux.pp @@ -0,0 +1,9 @@ +class nagios::nrpe::linux inherits nagios::nrpe::base { + + package { + "nagios-plugins-standard": ensure => present; + "ksh": ensure => present; # for check_cpustats.sh + "sysstat": ensure => present; # for check_cpustats.sh + } + +} diff --git a/manifests/nrpe/xinetd.pp b/manifests/nrpe/xinetd.pp new file mode 100644 index 0000000..e13ed76 --- /dev/null +++ b/manifests/nrpe/xinetd.pp @@ -0,0 +1,11 @@ +# This is created only to cope with cases where we're not the only ones +# administering a machine and NRPE is running in xinetd. +class nagios::nrpe::xinetd inherits base { + + Service ["nagios-nrpe-server"] { + ensure => stopped, + } + + # TODO manage the xinetd config file that glues with NRPE + +} diff --git a/manifests/nsca/server.pp b/manifests/nsca/server.pp index 8ba0116..bd5389d 100644 --- a/manifests/nsca/server.pp +++ b/manifests/nsca/server.pp @@ -6,6 +6,7 @@ class nagios::nsca::server { ensure => running, hasstatus => false, hasrestart => true, + require => Package['nsca'], } file { '/etc/nsca.cfg': diff --git a/manifests/service.pp b/manifests/service.pp index a739317..71f78b0 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -11,16 +11,33 @@ define nagios::service ( $notification_options = '', $contact_groups = '', $use = 'generic-service', - $service_description = 'absent' ) + $service_description = 'absent', + $use_nrpe = '', + $nrpe_args = '', + $nrpe_timeout = 10 ) { # TODO: this resource should normally accept all nagios_host parameters $real_name = "${::hostname}_${name}" + if ($use_nrpe == 'true') { + include nagios::command::nrpe_timeout + + if ($nrpe_args != '') { + $real_check_command = "check_nrpe_timeout!$nrpe_timeout!$check_command!\"$nrpe_args\"" + } + else { + $real_check_command = "check_nrpe_1arg_timeout!$nrpe_timeout!$check_command" + } + } + else { + $real_check_command = "$check_command" + } + @@nagios_service { "${real_name}": ensure => $ensure, - check_command => $check_command, + check_command => $real_check_command, host_name => $host_name, use => $use, notify => Service[nagios], diff --git a/manifests/service/imap.pp b/manifests/service/imap.pp new file mode 100644 index 0000000..b703db4 --- /dev/null +++ b/manifests/service/imap.pp @@ -0,0 +1,32 @@ +define nagios::service::imap( + $ensure = 'present', + $host = 'absent', + $port = '143', + $tls = true, + $tls_port = '993' +){ + + $real_host = $host ? { + 'absent' => $name, + default => $host + } + + nagios::service{ + "imap_${name}_${port}": + ensure => $ensure; + "imaps_${name}_${tls_port}": + ensure => $tls ? { + true => $ensure, + default => 'absent' + }; + } + + if $ensure != 'absent' { + Nagios::Service["imap_${name}_${port}"]{ + check_command => "check_imap!${real_host}!${port}", + } + Nagios::Service["imaps_${name}_${tls_port}"]{ + check_command => "check_imap_ssl!${real_host}!${tls_port}", + } + } +} diff --git a/manifests/service/mysql.pp b/manifests/service/mysql.pp index 95f0970..94881d8 100644 --- a/manifests/service/mysql.pp +++ b/manifests/service/mysql.pp @@ -21,6 +21,18 @@ define nagios::service::mysql( 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') { @@ -42,6 +54,6 @@ define nagios::service::mysql( nagios::service { "mysql_health_${name}": ensure => $ensure, - check_command => "check_mysql_health!${check_host}!${check_port}!${check_username}!${check_password}!${name}!${check_database}", + 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}", } } diff --git a/manifests/service/pop.pp b/manifests/service/pop.pp new file mode 100644 index 0000000..9ec4aec --- /dev/null +++ b/manifests/service/pop.pp @@ -0,0 +1,32 @@ +define nagios::service::pop( + $ensure = 'present', + $host = 'absent', + $port = '110', + $tls = true, + $tls_port = '995' +){ + + $real_host = $host ? { + 'absent' => $name, + default => $host + } + + nagios::service{ + "pop_${name}_${port}": + ensure => $ensure; + "pops_${name}_${tls_port}": + ensure => $tls ? { + true => $ensure, + default => 'absent' + }; + } + + if $ensure != 'absent' { + Nagios::Service["pop_${name}_${port}"]{ + check_command => "check_pop3!${real_host}!${port}", + } + Nagios::Service["pops_${name}_${tls_port}"]{ + check_command => "check_pop3_ssl!${real_host}!${tls_port}", + } + } +} |