diff options
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/defaults/commands.pp | 8 | ||||
-rw-r--r-- | manifests/defaults/plugins.pp | 2 | ||||
-rw-r--r-- | manifests/irc_bot.pp | 111 | ||||
-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/service/imap.pp | 32 | ||||
-rw-r--r-- | manifests/service/mysql.pp | 14 | ||||
-rw-r--r-- | manifests/service/pop.pp | 32 |
9 files changed, 190 insertions, 93 deletions
diff --git a/manifests/defaults/commands.pp b/manifests/defaults/commands.pp index 15c4478..1213485 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,11 +111,15 @@ 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: command_line => '$USER1$/check_dns2 -c $ARG1$ A $ARG2$'; + + # dnsbl checking + check_dnsbl: + command_line => '$USER1$/check_dnsbl -H $ARG1$'; } # notification commands diff --git a/manifests/defaults/plugins.pp b/manifests/defaults/plugins.pp index 842f9ce..18f8161 100644 --- a/manifests/defaults/plugins.pp +++ b/manifests/defaults/plugins.pp @@ -5,6 +5,8 @@ class nagios::defaults::plugins { source => 'nagios/plugins/check_mysql_health'; 'check_dns2': source => 'nagios/plugins/check_dns2'; + 'check_dnsbl': + source => 'nagios/plugins/check_dnsbl'; } } diff --git a/manifests/irc_bot.pp b/manifests/irc_bot.pp index 961755a..7629b94 100644 --- a/manifests/irc_bot.pp +++ b/manifests/irc_bot.pp @@ -1,93 +1,22 @@ class nagios::irc_bot { - if ( ! ($nagios_nsa_server and $nagios_nsa_nickname and $nagios_nsa_channel) ) { - fail("Please provide values at least for \$nagios_nsa_server, \$nagios_nsa_nickname and \$nagios_nsa_channel") - } - - $nagios_nsa_socket = $nagios_nsa_socket ? { - '' => $operatingsystem ? { - centos => '/var/run/nagios-nsa/nsa.socket', - default => '/var/run/nagios3/nsa.socket' - }, - default => $nagios_nsa_socket, - } - $nagios_nsa_pidfile = $nagios_nsa_pidfile ? { - '' => $operatingsystem ? { - centos => '/var/run/nagios-nsa/nsa.pid', - default => '/var/run/nagios3/nsa.pid' - }, - default => $nagios_nsa_pidfile, - } - $nagios_nsa_port = $nagios_nsa_port ? { - '' => '6667', - default => $nagios_nsa_port, - } - $nagios_nsa_realname = $nagios_nsa_realname ? { - '' => 'Nagios', - default => $nagios_nsa_realname, - } - - if (! $nagios_nsa_password) { - $nagios_nsa_password = '' - } - - file { "/usr/local/bin/riseup-nagios-client.pl": - owner => root, group => root, mode => 0755, - source => "puppet:///modules/nagios/irc_bot/riseup-nagios-client.pl", - } - file { "/usr/local/bin/riseup-nagios-server.pl": - owner => root, group => root, mode => 0755, - source => "puppet:///modules/nagios/irc_bot/riseup-nagios-server.pl", - } - file { "/etc/init.d/nagios-nsa": - owner => root, group => root, 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 => root, mode => 0400, - content => template('nagios/irc_bot/nsa.cfg.erb'), - } - - package { "libnet-irc-perl": - ensure => present, - } - - service { "nagios-nsa": - ensure => "running", - hasstatus => true, - require => [File["/etc/nagios_nsa.cfg"], - Package["libnet-irc-perl"], - Service['nagios'] ], - } - - case $operatingsystem { - centos: { - Package['libnet-irc-perl']{ - name => 'perl-Net-IRC', - } - Service['nagios-nsa']{ - enable => true, - } - } - 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'], - } - } - } - - 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 $use_shorewall { - include shorewall::rules::out::irc - } + if ( ! ($nagios_nsa_server and $nagios_nsa_nickname and $nagios_nsa_channel) ) { + fail("Please provide values at least for \$nagios_nsa_server, \$nagios_nsa_nickname and \$nagios_nsa_channel") + } + + case $operatingsystem { + centos: { + $nagios_nsa_default_socket = '/var/run/nagios-nsa/nsa.socket' + $nagios_nsa_default_pidfile = '/var/run/nagios-nsa/nsa.pid' + include nagios::irc_bot::centos + } + default: { + $nagios_nsa_default_socket = '/var/run/nagios3/nsa.socket' + $nagios_nsa_default_pidfile = '/var/run/nagios3/nsa.pid' + include nagios::irc_bot::base + } + } + + if $use_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..c36d8e6 --- /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 + $nagios_nsa_socket = $nagios_nsa_socket ? { + '' => $nagios_nsa_default_socket, + default => $nagios_nsa_socket, + } + $nagios_nsa_pidfile = $nagios_nsa_pidfile ? { + '' => $nagios_nsa_default_pidfile, + default => $nagios_nsa_pidfile, + } + $nagios_nsa_port = $nagios_nsa_port ? { + '' => '6667', + default => $nagios_nsa_port, + } + $nagios_nsa_realname = $nagios_nsa_realname ? { + '' => 'Nagios', + default => $nagios_nsa_realname, + } + + if (! $nagios_nsa_password) { + $nagios_nsa_password = '' + } + + if (! $nagios_nsa_usenotices) { + $nagios_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/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 d501f06..2fde402 100644 --- a/manifests/service/mysql.pp +++ b/manifests/service/mysql.pp @@ -20,7 +20,19 @@ define nagios::service::mysql( 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') { @@ -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}", + } + } +} |