summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2013-01-02 17:51:29 +0100
committermh <mh@immerda.ch>2013-01-02 17:51:29 +0100
commit2b2268702938453bcece9ebe6070c03929910f8a (patch)
treef7ddfdfaf2430b19dcb7f89b3c16ccf4321976de /manifests
parentdf358dcf15d26ba59b59f686ceee4b07b3aed7dd (diff)
parenta2a80093d42b7e9eec9d2af3c66138f7ceaf9ed6 (diff)
Merge remote-tracking branch 'riseup/master' into HEAD
Conflicts: manifests/apache.pp manifests/base.pp manifests/defaults/templates.pp manifests/defaults/vars.pp manifests/init.pp manifests/irc_bot.pp manifests/nsca/client.pp manifests/nsca/server.pp manifests/service.pp manifests/service/mysql.pp templates/irc_bot/nsa.cfg.erb
Diffstat (limited to 'manifests')
-rw-r--r--manifests/base.pp7
-rw-r--r--manifests/command/imap_pop3.pp14
-rw-r--r--manifests/command/smtp.pp24
-rw-r--r--manifests/defaults/commands.pp6
-rw-r--r--manifests/defaults/templates.pp1
-rw-r--r--manifests/init.pp1
-rw-r--r--manifests/irc_bot.pp65
-rw-r--r--manifests/irc_bot/base.pp37
-rw-r--r--manifests/irc_bot/centos.pp9
-rw-r--r--manifests/irc_bot/debian.pp8
-rw-r--r--manifests/irc_bot/disable.pp8
-rw-r--r--manifests/service/imap.pp32
-rw-r--r--manifests/service/mysql.pp14
-rw-r--r--manifests/service/pop.pp32
14 files changed, 194 insertions, 64 deletions
diff --git a/manifests/base.pp b/manifests/base.pp
index 0f8b777..c4ba260 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_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/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/defaults/templates.pp b/manifests/defaults/templates.pp
index 0e73c97..9711dd4 100644
--- a/manifests/defaults/templates.pp
+++ b/manifests/defaults/templates.pp
@@ -11,5 +11,4 @@ class nagios::defaults::templates {
notify => Service['nagios'],
mode => 0644, owner => root, group => root;
}
-
}
diff --git a/manifests/init.pp b/manifests/init.pp
index 12d3db2..5cbd3f3 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -14,6 +14,7 @@
# the Free Software Foundation.
#
+# manage nagios
class nagios(
$httpd = 'apache',
$allow_external_cmd = false,
diff --git a/manifests/irc_bot.pp b/manifests/irc_bot.pp
index 77c5fa8..88d769c 100644
--- a/manifests/irc_bot.pp
+++ b/manifests/irc_bot.pp
@@ -1,3 +1,4 @@
+<<<<<<< HEAD
class nagios::irc_bot(
$nsa_socket = 'absent',
$nsa_server,
@@ -6,7 +7,9 @@ class nagios::irc_bot(
$nsa_password = '',
$nsa_channel,
$nsa_pidfile = 'absent',
- $nsa_realname = 'Nagios'
+ $nsa_realname = 'Nagios',
+ $nsa_usenotices = false,
+ $nsa_commandfile = 'absent'
) {
$real_nsa_socket = $nsa_socket ? {
'absent' => $::operatingsystem ? {
@@ -15,67 +18,31 @@ class nagios::irc_bot(
},
default => $nsa_socket,
}
- $real__nsa_pidfile = $nsa_pidfile ? {
+ $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,
- }
-
- service { "nagios-nsa":
- ensure => "running",
- hasstatus => true,
- require => [ File["/etc/nagios_nsa.cfg"],
- Package["libnet-irc-perl"],
- Service['nagios'] ],
+ $real_nsa_commandfile = $nsa_commandfile ? {
+ 'absent' => $::operatingsystem ? {
+ centos => '/var/spool/nagios/cmd/nagios.cmd',
+ default => '/var/lib/nagios3/rw/nagios.cmd'
+ },
+ default => $nsa_commandfile,
}
case $::operatingsystem {
centos: {
- Package['libnet-irc-perl']{
- name => 'perl-Net-IRC',
- }
- Service['nagios-nsa']{
- enable => true,
- }
+ 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'],
- }
+ include nagios::irc_bot::debian
+ }
+ default: {
+ 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 {
diff --git a/manifests/irc_bot/base.pp b/manifests/irc_bot/base.pp
new file mode 100644
index 0000000..5014bcb
--- /dev/null
+++ b/manifests/irc_bot/base.pp
@@ -0,0 +1,37 @@
+class nagios::irc_bot::base {
+ 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,
+ }
+
+ service { "nagios-nsa":
+ ensure => "running",
+ hasstatus => true,
+ require => [ File["/etc/nagios_nsa.cfg"],
+ Package["libnet-irc-perl"],
+ Service['nagios'] ],
+ }
+
+ 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"';
+ }
+}
diff --git a/manifests/irc_bot/centos.pp b/manifests/irc_bot/centos.pp
new file mode 100644
index 0000000..d7b1906
--- /dev/null
+++ b/manifests/irc_bot/centos.pp
@@ -0,0 +1,9 @@
+class nagios::irc_bot::centos inherits nagios::irc_bot::base {
+ Package['libnet-irc-perl']{
+ name => 'perl-Net-IRC',
+ }
+
+ Service['nagios-nsa']{
+ enable => true,
+ }
+}
diff --git a/manifests/irc_bot/debian.pp b/manifests/irc_bot/debian.pp
new file mode 100644
index 0000000..93ea64b
--- /dev/null
+++ b/manifests/irc_bot/debian.pp
@@ -0,0 +1,8 @@
+class nagios::irc_bot::debian inherits nagios::irc_bot::base {
+ 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'],
+ }
+}
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 95f0970..4a9c81a 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}",
+ }
+ }
+}