summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README12
-rw-r--r--files/configs/Debian/nagios.cfg2
-rwxr-xr-xfiles/plugins/check_openvpn_server.pl109
-rw-r--r--manifests/apache.pp4
-rw-r--r--manifests/debian.pp7
-rw-r--r--manifests/defaults/commands.pp244
-rw-r--r--manifests/init.pp3
-rw-r--r--manifests/nrpe.pp4
-rw-r--r--manifests/nrpe/base.pp52
-rw-r--r--manifests/nrpe/debian.pp6
-rw-r--r--manifests/pnp4nagios.pp71
-rw-r--r--manifests/pnp4nagios/popup.pp27
-rw-r--r--manifests/service.pp18
-rw-r--r--manifests/service/mysql.pp2
-rw-r--r--manifests/stored_config.pp19
-rw-r--r--manifests/target.pp12
-rw-r--r--templates/nrpe/nrpe_command.erb2
17 files changed, 383 insertions, 211 deletions
diff --git a/README b/README
index 8a47ddd..cd0d254 100644
--- a/README
+++ b/README
@@ -12,11 +12,21 @@ In it's current form, this module can be used on CentOS and Debian.
Overview
========
+Requirements
+------------
+
+To use the nrpe functionality, you will need the perl module installed.
+
To use the nagios resources, activate storeconfigs on the
puppetmaster.
You need to be running verison 0.25 or later of puppet.
+! Upgrade Notice !
+
+ * the irc bot variables changed, they previously had $nagios_ prepended
+ but no longer have that. So you will need to change your local config
+ to use $nsa_server instead of $nagios_nsa_server, for example.
Monitor
-------
@@ -114,7 +124,7 @@ IRC bot
Notifications can easily be sent to an IRC channel by using a bot. To do so,
simply include 'nagios::irc_bot' on the nagios server and define the right
-$nagios_nsa_* variables (see the 'Variables' section below).
+$nsa_* variables (see the 'Variables' section below).
You can then use the notification commands 'notify-by-irc' and
'host-notify-by-irc' with service and host definitions to make them report
diff --git a/files/configs/Debian/nagios.cfg b/files/configs/Debian/nagios.cfg
index 41a2e3c..68e03bb 100644
--- a/files/configs/Debian/nagios.cfg
+++ b/files/configs/Debian/nagios.cfg
@@ -20,7 +20,7 @@ log_file=/var/log/nagios3/nagios.log
# host groups, contacts, contact groups, services, etc.
# You can split your object definitions across several config files
# if you wish (as shown below), or keep them all in a single config file.
-cfg_file=/etc/nagios3/commands.cfg
+#cfg_file=/etc/nagios3/commands.cfg
# Puppet-managed configuration files
cfg_dir=/etc/nagios3/conf.d
diff --git a/files/plugins/check_openvpn_server.pl b/files/plugins/check_openvpn_server.pl
new file mode 100755
index 0000000..b74ace8
--- /dev/null
+++ b/files/plugins/check_openvpn_server.pl
@@ -0,0 +1,109 @@
+#!/usr/bin/perl
+#
+# Filaname: check_openvpn
+# Created: 2012-06-15
+# Website: http://blog.kernelpicnic.net
+#
+# Description:
+# This script is for verifying the status of an OpenVPN daemon. It has been
+# written to integrate directly with Nagios / Opsview.
+#
+# Usage:
+# check_openvpn [OPTIONS]...
+#
+# -H, --hostname Host to check
+# -p, --port Port number to check
+# -h, --help Display help.
+#
+#############################################################################
+
+# Custom library path for Nagis modules.
+use lib qw ( /usr/local/nagios/perl/lib );
+
+# Enforce sanity.
+use strict;
+use warnings;
+
+# Required modules.
+use Getopt::Long qw(:config no_ignore_case);
+use Nagios::Plugin;
+use IO::Socket;
+
+# Define defaults.
+my $help = 0;
+my $timeout = 5;
+
+# Ensure required variables are set.
+my($hostname, $port);
+
+my $options = GetOptions(
+ "hostname|H=s" => \$hostname,
+ "timeout|t=s" => \$timeout,
+ "port|p=s" => \$port,
+ "help|h" => \$help,
+);
+
+# Check if help has been requested.
+if($help || !$hostname || !$port) {
+
+ printf("\n");
+ printf("Usage: check_openvpn [OPTIONS]...\n\n");
+ printf(" -H, --hostname Host to check\n");
+ printf(" -p, --port Port number to check\n");
+ printf(" -h, --help This help page\n");
+ printf(" -t, --timeout Socket timeout\n");
+ printf("\n");
+
+ exit(-1);
+
+}
+
+# Setup a new Nagios::Plugin object.
+my $nagios = Nagios::Plugin->new();
+
+# Define the check string to send to the OpenVPN server - as binary due
+# to non-printable characters.
+my $check_string = "001110000011001010010010011011101000000100010001110"
+ ."100110110101010110011000000000000000000000000000000"
+ ."0000000000";
+
+# Attempt to setup a socket to the specified host.
+my $host_sock = IO::Socket::INET->new(
+ Proto => 'udp',
+ PeerAddr => $hostname,
+ PeerPort => $port,
+);
+
+# Ensure we have a socket.
+if(!$host_sock) {
+ $nagios->nagios_exit(UNKNOWN, "Unable to bind socket");
+}
+
+# Fire off the check request.
+$host_sock->send(pack("B*", $check_string));
+
+# Wait for $timeout for response for a response, otherwise, fail.
+my $response;
+
+eval {
+
+ # Define how to handle ALARM.
+ local $SIG{ALRM} = sub {
+ $nagios->nagios_exit(CRITICAL, "No response received");
+ };
+
+ # Set the alarm for the given timeout value.
+ alarm($timeout);
+
+ # Check for response.
+ $host_sock->recv($response, 1)
+ or $nagios->nagios_exit(CRITICAL, "No response received");
+
+ # Alright, response received, cancel alarm.
+ alarm(0);
+ 1;
+
+};
+
+# Reply received, return okay.
+$nagios->nagios_exit(OK, "Response received from host");
diff --git a/manifests/apache.pp b/manifests/apache.pp
index b89ff5d..f6ec39a 100644
--- a/manifests/apache.pp
+++ b/manifests/apache.pp
@@ -1,13 +1,15 @@
class nagios::apache(
$allow_external_cmd = false,
$manage_shorewall = false,
- $manage_munin = false
+ $manage_munin = false,
+ $stored_config = true
) {
class{'nagios':
httpd => 'apache',
allow_external_cmd => $allow_external_cmd,
manage_munin => $manage_munin,
manage_shorewall => $manage_shorewall,
+ stored_config => $stored_config
}
case $::operatingsystem {
diff --git a/manifests/debian.pp b/manifests/debian.pp
index 0f451e3..f26bd97 100644
--- a/manifests/debian.pp
+++ b/manifests/debian.pp
@@ -18,13 +18,15 @@ class nagios::debian inherits nagios::base {
path => "${nagios::defaults::vars::int_cfgdir}/commands.cfg",
ensure => present,
notify => Service['nagios'],
- mode => 0644, owner => root, group => root;
+ mode => 0644, owner => root, group => root,
+ require => Package['nagios'],
}
file { "${nagios::defaults::vars::int_cfgdir}/stylesheets":
ensure => directory,
purge => false,
recurse => true,
+ require => Package['nagios'],
}
if $nagios::allow_external_cmd {
@@ -33,16 +35,19 @@ class nagios::debian inherits nagios::base {
unless => 'dpkg-statoverride --list nagios www-data 2710 /var/lib/nagios3/rw && dpkg-statoverride --list nagios nagios 751 /var/lib/nagios3',
logoutput => false,
notify => Service['nagios'],
+ require => Package['nagios'],
}
exec { 'nagios_external_cmd_perms_1':
command => 'chmod 0751 /var/lib/nagios3 && chown nagios:nagios /var/lib/nagios3',
unless => 'test "`stat -c "%a %U %G" /var/lib/nagios3`" = "751 nagios nagios"',
notify => Service['nagios'],
+ require => Package['nagios'],
}
exec { 'nagios_external_cmd_perms_2':
command => 'chmod 2751 /var/lib/nagios3/rw && chown nagios:www-data /var/lib/nagios3/rw',
unless => 'test "`stat -c "%a %U %G" /var/lib/nagios3/rw`" = "2751 nagios www-data"',
notify => Service['nagios'],
+ require => Package['nagios'],
}
}
}
diff --git a/manifests/defaults/commands.pp b/manifests/defaults/commands.pp
index 777a74e..7499b1f 100644
--- a/manifests/defaults/commands.pp
+++ b/manifests/defaults/commands.pp
@@ -5,140 +5,138 @@ class nagios::defaults::commands {
# common service commands
case $::operatingsystem {
- debian,ubuntu: {
- nagios_command {
- check_dummy:
- command_line => '$USER1$/check_dummy $ARG1$';
- check_https_cert:
- command_line => '$USER1$/check_http --ssl -C 20 -H $HOSTADDRESS$ -I $HOSTADDRESS$';
- check_http_url:
- command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$';
- check_http_url_regex:
- command_line => '$USER1$/check_http -H $ARG1$ -p $ARG2$ -u $ARG3$ -e $ARG4$';
- check_https_url:
- command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$';
- check_https_url_regex:
- command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$ -e $ARG3$';
- check_mysql_db:
- command_line => '$USER1$/check_mysql -H $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$ -d $ARG5$';
- check_ntp_time:
- command_line => '$USER1$/check_ntp_time -H $HOSTADDRESS$ -w 0.5 -c 1';
- check_silc:
- command_line => '$USER1$/check_tcp -p 706 -H $ARG1$';
- check_sobby:
- 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';
- }
+ debian,ubuntu: {
+ nagios_command {
+ 'check_dummy':
+ command_line => '$USER1$/check_dummy $ARG1$';
+ 'check_https_cert':
+ command_line => '$USER1$/check_http --ssl -C 20 -H $HOSTADDRESS$ -I $HOSTADDRESS$';
+ 'check_http_url':
+ command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$';
+ 'check_http_url_regex':
+ command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$ -e $ARG3$';
+ 'check_https_url':
+ command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$';
+ 'check_https_url_regex':
+ command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$ -e $ARG3$';
+ 'check_mysql_db':
+ command_line => '$USER1$/check_mysql -H $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$ -d $ARG5$';
+ 'check_ntp_time':
+ command_line => '$USER1$/check_ntp_time -H $HOSTADDRESS$ -w 0.5 -c 1';
+ 'check_openvpn_server':
+ command_line => '$USER1$/check_openvpn_server.pl -H $HOSTADDRESS$ -p 1194';
+ 'check_openvpn_server_ip_port':
+ command_line => '$USER1$/check_openvpn_server.pl -H $ARG1$ -p $ARG2$';
+ 'check_silc':
+ command_line => '$USER1$/check_tcp -p 706 -H $ARG1$';
+ 'check_sobby':
+ 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: {
- nagios_command {
- check_dummy:
- command_line => '$USER1$/check_dummy $ARG1$';
- check_ping:
- command_line => '$USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$';
- check-host-alive:
- command_line => '$USER1$/check_ping -H $HOSTADDRESS$ -w 5000,100% -c 5000,100% -p 1';
- check_tcp:
- command_line => '$USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$';
- check_udp:
- command_line => '$USER1$/check_udp -H $HOSTADDRESS$ -p $ARG1$';
- check_load:
- command_line => '$USER1$/check_load --warning=$ARG1$,$ARG2$,$ARG3$ --critical=$ARG4$,$ARG5$,$ARG6$';
- check_disk:
- command_line => '$USER1$/check_disk -w $ARG1$ -c $ARG2$ -e -p $ARG3$';
- check_all_disks:
- command_line => '$USER1$/check_disk -w $ARG1$ -c $ARG2$ -e';
- check_ssh:
- command_line => '$USER1$/check_ssh $HOSTADDRESS$';
- check_ssh_port:
- command_line => '$USER1$/check_ssh -p $ARG1$ $HOSTADDRESS$';
- check_ssh_port_host:
- command_line => '$USER1$/check_ssh -p $ARG1$ $ARG2$';
- check_http:
- command_line => '$USER1$/check_http -H $HOSTADDRESS$ -I $HOSTADDRESS$';
- check_https:
- command_line => '$USER1$/check_http --ssl -H $HOSTADDRESS$ -I $HOSTADDRESS$';
- check_https_cert:
- command_line => '$USER1$/check_http --ssl -C 20 -H $HOSTADDRESS$ -I $HOSTADDRESS$';
- check_http_url:
- command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$';
- check_http_url_regex:
- command_line => '$USER1$/check_http -H $ARG1$ -p $ARG2$ -u $ARG3$ -e $ARG4$';
- check_https_url:
- command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$';
- check_https_url_regex:
- command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$ -e $ARG3$';
- check_mysql:
- command_line => '$USER1$/check_mysql -H $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$';
- check_mysql_db:
- command_line => '$USER1$/check_mysql -H $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$ -d $ARG5$';
- check_ntp_time:
- command_line => '$USER1$/check_ntp_time -H $HOSTADDRESS$ -w 0.5 -c 1';
- check_silc:
- command_line => '$USER1$/check_tcp -p 706 -H $ARG1$';
- check_sobby:
- 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: {
+ nagios_command {
+ 'check_dummy':
+ command_line => '$USER1$/check_dummy $ARG1$';
+ 'check_ping':
+ command_line => '$USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$';
+ 'check-host-alive':
+ command_line => '$USER1$/check_ping -H $HOSTADDRESS$ -w 5000,100% -c 5000,100% -p 1';
+ 'check_tcp':
+ command_line => '$USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$';
+ 'check_udp':
+ command_line => '$USER1$/check_udp -H $HOSTADDRESS$ -p $ARG1$';
+ 'check_load':
+ command_line => '$USER1$/check_load --warning=$ARG1$,$ARG2$,$ARG3$ --critical=$ARG4$,$ARG5$,$ARG6$';
+ 'check_disk':
+ command_line => '$USER1$/check_disk -w $ARG1$ -c $ARG2$ -e -p $ARG3$';
+ 'check_all_disks':
+ command_line => '$USER1$/check_disk -w $ARG1$ -c $ARG2$ -e';
+ 'check_ssh':
+ command_line => '$USER1$/check_ssh $HOSTADDRESS$';
+ 'check_ssh_port':
+ command_line => '$USER1$/check_ssh -p $ARG1$ $HOSTADDRESS$';
+ 'check_ssh_port_host':
+ command_line => '$USER1$/check_ssh -p $ARG1$ $ARG2$';
+ 'check_http':
+ command_line => '$USER1$/check_http -H $HOSTADDRESS$ -I $HOSTADDRESS$';
+ 'check_https':
+ command_line => '$USER1$/check_http --ssl -H $HOSTADDRESS$ -I $HOSTADDRESS$';
+ 'check_https_cert':
+ command_line => '$USER1$/check_http --ssl -C 20 -H $HOSTADDRESS$ -I $HOSTADDRESS$';
+ 'check_http_url':
+ command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$';
+ 'check_http_url_regex':
+ command_line => '$USER1$/check_http -H $ARG1$ -p $ARG2$ -u $ARG3$ -e $ARG4$';
+ 'check_https_url':
+ command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$';
+ 'check_https_url_regex':
+ command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$ -e $ARG3$';
+ 'check_mysql':
+ command_line => '$USER1$/check_mysql -H $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$';
+ 'check_mysql_db':
+ command_line => '$USER1$/check_mysql -H $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$ -d $ARG5$';
+ 'check_ntp_time':
+ command_line => '$USER1$/check_ntp_time -H $HOSTADDRESS$ -w 0.5 -c 1';
+ 'check_silc':
+ command_line => '$USER1$/check_tcp -p 706 -H $ARG1$';
+ 'check_sobby':
+ 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';
}
+ }
}
- # commands for services defined by other modules
+ # commands for services defined by other modules
- nagios_command {
- # from apache module
- http_port:
- command_line => '$USER1$/check_http -p $ARG1$ -H $HOSTADDRESS$ -I $HOSTADDRESS$';
+ nagios_command {
+ # from apache module
+ 'http_port':
+ command_line => '$USER1$/check_http -p $ARG1$ -H $HOSTADDRESS$ -I $HOSTADDRESS$';
- check_http_port_url_content:
- command_line => '$USER1$/check_http -H $ARG1$ -p $ARG2$ -u $ARG3$ -s $ARG4$';
- check_https_port_url_content:
- command_line => '$USER1$/check_http --ssl -H $ARG1$ -p $ARG2$ -u $ARG3$ -s $ARG4$';
- check_http_url_content:
- command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$ -s $ARG3$';
- check_https_url_content:
- command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$ -s $ARG3$';
+ 'check_http_port_url_content':
+ command_line => '$USER1$/check_http -H $ARG1$ -p $ARG2$ -u $ARG3$ -s $ARG4$';
+ 'check_https_port_url_content':
+ command_line => '$USER1$/check_http --ssl -H $ARG1$ -p $ARG2$ -u $ARG3$ -s $ARG4$';
+ 'check_http_url_content':
+ command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$ -s $ARG3$';
+ 'check_https_url_content':
+ command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$ -s $ARG3$';
- # from bind module
- check_dig2:
- command_line => '$USER1$/check_dig -H $HOSTADDRESS$ -l $ARG1$ --record_type=$ARG2$';
+ # from bind module
+ 'check_dig2':
+ command_line => '$USER1$/check_dig -H $HOSTADDRESS$ -l $ARG1$ --record_type=$ARG2$';
- # from mysql module
- check_mysql_health:
- command_line => '$USER1$/check_mysql_health --hostname $ARG1$ --port $ARG2$ --username $ARG3$ --password $ARG4$ --mode $ARG5$ --database $ARG6$ $ARG7$ $ARG8$';
+ # from mysql module
+ 'check_mysql_health':
+ 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$';
+ # 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
+ # dnsbl checking
+ 'check_dnsbl':
+ command_line => '$USER1$/check_dnsbl -H $ARG1$';
+ }
- $mail_cmd_location = $::operatingsystem ? {
- centos => '/bin/mail',
- default => '/usr/bin/mail'
- }
+ # notification commands
- case $::lsbdistcodename {
- 'wheezy': { }
- default: {
- 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\$";
- '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\$";
- }
- }
- }
+ $mail_cmd_location = $::operatingsystem ? {
+ centos => '/bin/mail',
+ default => '/usr/bin/mail'
+ }
+ nagios_command {
+ 'notify-host-by-email':
+ command_line => "/usr/bin/printf \"%b\" \"***** Nagios *****\\n\\nNotification Type: \$NOTIFICATIONTYPE\$\\n\\nHost: \$HOSTNAME\$ (\$HOSTALIAS\$)\\nAddress: \$HOSTADDRESS\$\\nState: \$HOSTSTATE\$\\nDuration: \$HOSTDURATION\$\\n\\nDate/Time: \$LONGDATETIME\$\\n\\nOutput: \$HOSTOUTPUT\$\" | ${mail_cmd_location} -s \"\$NOTIFICATIONTYPE\$: \$HOSTSTATE\$ - \$HOSTNAME\$\" \$CONTACTEMAIL\$";
+ 'notify-service-by-email':
+ command_line => "/usr/bin/printf \"%b\" \"***** Nagios *****\\n\\nNotification Type: \$NOTIFICATIONTYPE\$\\n\\nHost: \$HOSTNAME\$ (\$HOSTALIAS\$)\\nAddress: \$HOSTADDRESS\$\\n\\nService: \$SERVICEDESC\$\\nState: \$SERVICESTATE\$\\nDuration: \$SERVICEDURATION\$\\n\\nDate/Time: \$LONGDATETIME\$\\n\\nOutput: \$SERVICEOUTPUT\$\" | ${mail_cmd_location} -s \"\$NOTIFICATIONTYPE\$: \$SERVICESTATE\$ - \$HOSTALIAS\$/\$SERVICEDESC\$\" \$CONTACTEMAIL\$";
+ }
}
diff --git a/manifests/init.pp b/manifests/init.pp
index 5cbd3f3..1221950 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -19,7 +19,8 @@ class nagios(
$httpd = 'apache',
$allow_external_cmd = false,
$manage_shorewall = false,
- $manage_munin = false
+ $manage_munin = false,
+ $stored_config = true
) {
case $nagios::httpd {
'absent': { }
diff --git a/manifests/nrpe.pp b/manifests/nrpe.pp
index 3ef7d07..8482df8 100644
--- a/manifests/nrpe.pp
+++ b/manifests/nrpe.pp
@@ -8,10 +8,10 @@ class nagios::nrpe {
include nagios::nrpe::freebsd
}
- 'Debian': {
+ 'Debian','Ubuntu': {
if $nagios_nrpe_pid_file == '' { $nagios_nrpe_pid_file = '/var/run/nagios/nrpe.pid' }
if $nagios_plugin_dir == '' { $nagios_plugin_dir = '/usr/lib/nagios/plugins' }
- include nagios::nrpe::linux
+ include nagios::nrpe::debian
}
default: {
if $nagios_nrpe_pid_file == '' { $nagios_nrpe_pid_file = '/var/run/nrpe.pid' }
diff --git a/manifests/nrpe/base.pp b/manifests/nrpe/base.pp
index 17abb04..3412f7e 100644
--- a/manifests/nrpe/base.pp
+++ b/manifests/nrpe/base.pp
@@ -2,31 +2,33 @@ 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
- }
+
+ # libwww-perl for check_apache
+ include perl::extensions::libwww
+
+ package { [ 'nagios-nrpe-server', 'nagios-plugins-basic' ]:
+ ensure => present;
+ }
# Special-case lenny. the package doesn't exist
- if $lsbdistcodename != 'lenny' {
- package { "libnagios-plugin-perl": ensure => present; }
+ if $::lsbdistcodename != 'lenny' {
+ package { 'libnagios-plugin-perl': ensure => present; }
}
-
- file { [ $nagios_nrpe_cfgdir, "$nagios_nrpe_cfgdir/nrpe.d" ]:
- ensure => directory }
+
+ 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;
+ content => template('nagios/nrpe/nrpe.cfg'),
+ owner => root, group => root, mode => '0644';
}
-
+
# 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" ],
+ 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.
@@ -36,15 +38,15 @@ class nagios::nrpe::base {
$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}",
+ nagios::nrpe::command { 'check_load':
+ command_line => "${::nagios::nrpe::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"],
+ 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/debian.pp b/manifests/nrpe/debian.pp
new file mode 100644
index 0000000..fcaf851
--- /dev/null
+++ b/manifests/nrpe/debian.pp
@@ -0,0 +1,6 @@
+class nagios::nrpe::debian inherits nagios::nrpe::base {
+ include nagios::nrpe::linux
+ Service['nagios-nrpe-server'] {
+ hasstatus => false,
+ }
+}
diff --git a/manifests/pnp4nagios.pp b/manifests/pnp4nagios.pp
index 5ade74f..230772f 100644
--- a/manifests/pnp4nagios.pp
+++ b/manifests/pnp4nagios.pp
@@ -2,27 +2,32 @@ class nagios::pnp4nagios {
include nagios::defaults::pnp4nagios
package { 'pnp4nagios':
- ensure => installed }
+ ensure => installed,
+ require => Package['nagios']
+ }
- # unfortunatly we can't use the nagios_host and nagios_service
- # definition to define templates, so we need to copy a file here.
- # see http://projects.reductivelabs.com/issues/1180 for this limitation
+ # unfortunatly i didn't find a way to use nagios_host and nagios_service definition, because
+ # imho puppet can't handle the "name" variable needed in these 2 definitions
+ # so we need to copy a file here.
file { 'pnp4nagios-templates.cfg':
- path => "${nagios::defaults::vars::int_cfgdir}/conf.d/pnp4nagios-templates.cfg",
- source => [ 'puppet:///modules/site_nagios/pnp4nagios/pnp4nagios-templates.cfg',
- 'puppet:///modules/nagios/pnp4nagios/pnp4nagios-templates.cfg' ],
- mode => '0644',
- owner => root,
- group => root,
- notify => Service['nagios'],
+ path => "${nagios::defaults::vars::int_cfgdir}/conf.d/pnp4nagios-templates.cfg",
+ source => [
+ 'puppet:///modules/site-nagios/pnp4nagios/pnp4nagios-templates.cfg',
+ 'puppet:///modules/nagios/pnp4nagios/pnp4nagios-templates.cfg' ],
+ mode => '0644',
+ owner => root,
+ group => root,
+ notify => Service['nagios'],
+ require => Package['pnp4nagios'],
}
file { 'apache.conf':
path => '/etc/pnp4nagios/apache.conf',
- source => [ 'puppet:///modules/site_nagios/pnp4nagios/apache.conf',
- 'puppet:///modules/nagios/pnp4nagios/apache.conf' ],
+ source => [
+ 'puppet:///modules/site-nagios/pnp4nagios/apache.conf',
+ 'puppet:///modules/nagios/pnp4nagios/apache.conf' ],
mode => '0644',
owner => root,
group => root,
@@ -33,31 +38,35 @@ class nagios::pnp4nagios {
# run npcd as daemon
file { '/etc/default/npcd':
- path => '/etc/default/npcd',
- source => [ 'puppet:///modules/site_nagios/pnp4nagios/npcd',
- 'puppet:///modules/nagios/pnp4nagios/npcd' ],
- mode => '0644',
- owner => root,
- group => root,
- notify => Service['npcd'];
+ path => '/etc/default/npcd',
+ source => [
+ 'puppet:///modules/site-nagios/pnp4nagios/npcd',
+ 'puppet:///modules/nagios/pnp4nagios/npcd' ],
+ mode => '0644',
+ owner => root,
+ group => root,
+ notify => Service['npcd'],
+ require => Package['pnp4nagios'],
}
service { 'npcd':
- ensure => running,
- enable => true,
- hasstatus => true,
- require => Package['pnp4nagios'],
+ ensure => running,
+ enable => true,
+ hasstatus => true,
+ require => Package['pnp4nagios'],
}
# modify action.gif
file { '/usr/share/nagios3/htdocs/images/action.gif':
- path => '/usr/share/nagios3/htdocs/images/action.gif',
- source => [ 'puppet:///modules/site_nagios/pnp4nagios/action.gif',
- 'puppet:///modules/nagios/pnp4nagios/action.gif' ],
- mode => '0644',
- owner => root,
- group => root,
- notify => Service['nagios'];
+ path => '/usr/share/nagios3/htdocs/images/action.gif',
+ source => [
+ 'puppet:///modules/site-nagios/pnp4nagios/action.gif',
+ 'puppet:///modules/nagios/pnp4nagios/action.gif' ],
+ mode => '0644',
+ owner => root,
+ group => root,
+ notify => Service['nagios'],
+ require => Package['pnp4nagios'],
}
}
diff --git a/manifests/pnp4nagios/popup.pp b/manifests/pnp4nagios/popup.pp
index 0dc04b0..91136cc 100644
--- a/manifests/pnp4nagios/popup.pp
+++ b/manifests/pnp4nagios/popup.pp
@@ -1,19 +1,24 @@
-class nagios::pnp4nagios::popup inherits nagios::pnp4nagios {
+class nagios::pnp4nagios::popup inherits nagios::pnp4nagios {
File['pnp4nagios-templates.cfg']{
- source => [ 'puppet:///modules/site_nagios/pnp4nagios/pnp4nagios-popup-templates.cfg',
- 'puppet:///modules/nagios/pnp4nagios/pnp4nagios-popup-templates.cfg' ],
+ source => [
+ 'puppet:///modules/site-nagios/pnp4nagios/pnp4nagios-popup-templates.cfg',
+ 'puppet:///modules/nagios/pnp4nagios/pnp4nagios-popup-templates.cfg' ],
}
file { '/usr/share/nagios3/htdocs/ssi':
- ensure => directory }
+ ensure => directory,
+ require => Package['nagios'],
+ }
file { 'status-header.ssi':
- path => '/usr/share/nagios3/htdocs/ssi/status-header.ssi',
- source => [ 'puppet:///modules/site_nagios/pnp4nagios/status-header.ssi',
- 'puppet:///modules/nagios/pnp4nagios/status-header.ssi' ],
- mode => '0644',
- owner => root,
- group => root,
- notify => Service['nagios'],
+ path => '/usr/share/nagios3/htdocs/ssi/status-header.ssi',
+ source => [
+ 'puppet:///modules/site-nagios/pnp4nagios/status-header.ssi',
+ 'puppet:///modules/nagios/pnp4nagios/status-header.ssi'],
+ mode => '0644',
+ owner => root,
+ group => root,
+ notify => Service['nagios'],
+ require => Package['nagios'],
}
}
diff --git a/manifests/service.pp b/manifests/service.pp
index 3e8f6c8..9e265a6 100644
--- a/manifests/service.pp
+++ b/manifests/service.pp
@@ -12,7 +12,7 @@ define nagios::service (
$contact_groups = '',
$use = 'generic-service',
$service_description = 'absent',
- $use_nrpe = '',
+ $use_nrpe = false,
$nrpe_args = '',
$nrpe_timeout = 10
) {
@@ -30,20 +30,22 @@ define nagios::service (
if $check_command == 'absent' {
fail("Must pass a check_command to ${name} if it should be present")
}
- if ($use_nrpe == true) {
+ 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_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}"] {
- check_command => $check_command,
+ check_command => $real_check_command,
host_name => $host_name,
use => $use,
service_description => $service_description ?{
diff --git a/manifests/service/mysql.pp b/manifests/service/mysql.pp
index 2c74717..9559b17 100644
--- a/manifests/service/mysql.pp
+++ b/manifests/service/mysql.pp
@@ -27,7 +27,7 @@ define nagios::service::mysql(
if $check_warning != undef {
$real_check_warning = "!--warning $check_warning"
}
-
+
if $check_critical != undef {
$real_check_critical = "!--critical $check_critical"
}
diff --git a/manifests/stored_config.pp b/manifests/stored_config.pp
new file mode 100644
index 0000000..5afda04
--- /dev/null
+++ b/manifests/stored_config.pp
@@ -0,0 +1,19 @@
+class nagios::stored_config {
+ # collect exported resources
+
+ Nagios_command <<||>>
+ Nagios_contactgroup <<||>>
+ Nagios_contact <<||>>
+ Nagios_hostdependency <<||>>
+ Nagios_hostescalation <<||>>
+ Nagios_hostextinfo <<||>>
+ Nagios_hostgroup <<||>>
+ Nagios_host <<||>>
+ Nagios_servicedependency <<||>>
+ Nagios_serviceescalation <<||>>
+ Nagios_servicegroup <<||>>
+ Nagios_serviceextinfo <<||>>
+ Nagios_service <<||>>
+ Nagios_timeperiod <<||>>
+
+}
diff --git a/manifests/target.pp b/manifests/target.pp
index be6c40e..40ff18a 100644
--- a/manifests/target.pp
+++ b/manifests/target.pp
@@ -3,8 +3,9 @@
class nagios::target(
$parents = 'absent',
$address = $::ipaddress,
- $nagios_alias = false,
- $hostgroups = 'absent'
+ $nagios_alias = $::false,
+ $hostgroups = 'absent',
+ $notes = 'absent'
){
@@nagios_host { $::fqdn:
address => $address,
@@ -19,10 +20,13 @@ class nagios::target(
}
if ($parents != 'absent') {
- Nagios_host["${::fqdn}"] { parents => $parents }
+ Nagios_host[ $::fqdn ] { parents => $parents }
}
if ($hostgroups != 'absent') {
- Nagios_host["${::fqdn}"] { hostgroups => $hostgroups }
+ Nagios_host[ $::fqdn ] { hostgroups => $hostgroups }
+ }
+ if ($notes != 'absent') {
+ Nagios_host[ $::fqdn ] { notes => $notes }
}
}
diff --git a/templates/nrpe/nrpe_command.erb b/templates/nrpe/nrpe_command.erb
index 8b50f60..99f4601 100644
--- a/templates/nrpe/nrpe_command.erb
+++ b/templates/nrpe/nrpe_command.erb
@@ -1,2 +1,2 @@
# generated by puppet, do not edit
-command[<%= @name -%>]=<%= @command_line %>
+command[<%= name -%>]=<%= command_line %>