summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README28
-rw-r--r--files/configs/Debian/nagios.cfg2
-rwxr-xr-xfiles/plugins/check_openvpn_server.pl109
-rw-r--r--manifests/apache.pp10
-rw-r--r--manifests/base.pp182
-rw-r--r--manifests/debian.pp7
-rw-r--r--manifests/defaults/commands.pp239
-rw-r--r--manifests/init.pp3
-rw-r--r--manifests/nrpe.pp5
-rw-r--r--manifests/nrpe/base.pp50
-rw-r--r--manifests/nrpe/debian.pp6
-rw-r--r--manifests/service.pp20
-rw-r--r--manifests/service/mysql.pp2
-rw-r--r--manifests/stored_config.pp19
-rw-r--r--manifests/target.pp14
-rw-r--r--templates/nrpe/nrpe_command.erb2
16 files changed, 426 insertions, 272 deletions
diff --git a/README b/README
index 0949071..90a97c6 100644
--- a/README
+++ b/README
@@ -17,6 +17,11 @@ 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
-------
@@ -68,24 +73,11 @@ files directly.
NRPE Services
-------------
-Some Nagios services need to be checked via NRPE. The following will make the
-nagios server define a service that will check the NRPE command 'check_cpu' on
-the current node:
-
- nagios::service { 'CPU Usage':
- use_nrpe => 'true',
- check_command => "check_cpu",
- nrpe_args => "-t 60"
- }
-
-NRPE Commands
--------------
-
-To be able to call NRPE commands on a host, one needs to define that command
-and what it is going to execute:
+NRPE Services can be defines as i.e.:
- nagios::nrpe::command { 'debsums':
- check_command => '/usr/lib/nagios/plugins/check_debsums openssh-server'
+ nagios::service { 'CPU Usage': use_nrpe => 'true',
+ check_command => "check_cpu",
+ nrpe_args => "-t 60"
}
@@ -114,7 +106,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 8eae393..cf0d1f3 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 a90d0ee..f6ec39a 100644
--- a/manifests/apache.pp
+++ b/manifests/apache.pp
@@ -1,22 +1,24 @@
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 {
'debian': {
file { "${nagios::defaults::vars::int_cfgdir}/apache2.conf":
ensure => present,
- source => [ "puppet:///site_nagios/configs/${::fqdn}/apache2.conf",
- "puppet:///site_nagios/configs/apache2.conf",
- "puppet:///nagios/configs/apache2.conf"],
+ source => [ "puppet:///modules/site_nagios/configs/${::fqdn}/apache2.conf",
+ "puppet:///modules/site_nagios/configs/apache2.conf",
+ "puppet:///modules/nagios/configs/apache2.conf"],
}
apache::config::global { "nagios3.conf":
diff --git a/manifests/base.pp b/manifests/base.pp
index 0f8b777..3a0765a 100644
--- a/manifests/base.pp
+++ b/manifests/base.pp
@@ -23,7 +23,8 @@ class nagios::base {
"puppet:///modules/nagios/configs/${::operatingsystem}/nagios.cfg",
"puppet:///modules/nagios/configs/nagios.cfg" ],
notify => Service['nagios'],
- mode => 0644, owner => root, group => root;
+ mode => 0644, owner => root, group => root,
+ require => Package['nagios'],
}
file { 'nagios_cgi_cfg':
@@ -35,13 +36,15 @@ class nagios::base {
"puppet:///modules/nagios/configs/cgi.cfg" ],
mode => '0644', owner => 'root', group => 0,
notify => Service['apache'],
+ require => Package['nagios'],
}
file { 'nagios_htpasswd':
path => "${nagios::defaults::vars::int_cfgdir}/htpasswd.users",
source => [ "puppet:///modules/site_nagios/htpasswd.users",
"puppet:///modules/nagios/htpasswd.users" ],
- mode => 0640, owner => root, group => apache;
+ mode => 0640, owner => root, group => apache,
+ require => Package['nagios'],
}
file { 'nagios_private':
@@ -50,7 +53,8 @@ class nagios::base {
purge => true,
recurse => true,
notify => Service['nagios'],
- mode => '0750', owner => root, group => nagios;
+ mode => '0750', owner => root, group => nagios,
+ require => Package['nagios'],
}
file { 'nagios_private_resource_cfg':
@@ -58,7 +62,8 @@ class nagios::base {
source => [ "puppet:///modules/site_nagios/configs/${::operatingsystem}/private/resource.cfg.${::architecture}",
"puppet:///modules/nagios/configs/${::operatingsystem}/private/resource.cfg.${::architecture}" ],
notify => Service['nagios'],
- owner => root, group => nagios, mode => '0640';
+ owner => root, group => nagios, mode => '0640',
+ require => Package['nagios'],
}
file { 'nagios_confd':
@@ -67,90 +72,82 @@ class nagios::base {
purge => true,
recurse => true,
notify => Service['nagios'],
- mode => '0750', owner => root, group => nagios;
- }
- 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 <<||>>
-
- Nagios_command <||> {
- target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_command.cfg",
- require => File['nagios_confd'],
- notify => Service['nagios'],
- }
- Nagios_contact <||> {
- target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contact.cfg",
- require => File['nagios_confd'],
- notify => Service['nagios'],
- }
- Nagios_contactgroup <||> {
- target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contactgroup.cfg",
- require => File['nagios_confd'],
- notify => Service['nagios'],
- }
- Nagios_host <||> {
- target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_host.cfg",
- require => File['nagios_confd'],
- notify => Service['nagios'],
- }
- Nagios_hostdependency <||> {
- target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostdependency.cfg",
- notify => Service['nagios'],
- }
- Nagios_hostescalation <||> {
- target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostescalation.cfg",
- notify => Service['nagios'],
- }
- Nagios_hostextinfo <||> {
- target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostextinfo.cfg",
- require => File['nagios_confd'],
- notify => Service['nagios'],
- }
- Nagios_hostgroup <||> {
- target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostgroup.cfg",
- require => File['nagios_confd'],
- notify => Service['nagios'],
- }
- Nagios_service <||> {
- target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_service.cfg",
- require => File['nagios_confd'],
- notify => Service['nagios'],
- }
- Nagios_servicegroup <||> {
- target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicegroup.cfg",
- notify => Service['nagios'],
- }
- Nagios_servicedependency <||> {
- target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicedependency.cfg",
- require => File['nagios_confd'],
- notify => Service['nagios'],
- }
- Nagios_serviceescalation <||> {
- target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceescalation.cfg",
- require => File['nagios_confd'],
- notify => Service['nagios'],
- }
- Nagios_serviceextinfo <||> {
- target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceextinfo.cfg",
- require => File['nagios_confd'],
- notify => Service['nagios'],
- }
- Nagios_timeperiod <||> {
- target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_timeperiod.cfg",
- require => File['nagios_confd'],
- notify => Service['nagios'],
+ mode => '0750', owner => root, group => nagios,
+ require => Package['nagios'],
}
+ if ( $nagios::stored_config == true ) {
+ include nagios::stored_config
+ }
+ Nagios_command <||> {
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_command.cfg",
+ require => [ File['nagios_confd'], Package['nagios'] ],
+ notify => Service['nagios'],
+ }
+ Nagios_contact <||> {
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contact.cfg",
+ require => [ File['nagios_confd'], Package['nagios'] ],
+ notify => Service['nagios'],
+ }
+ Nagios_contactgroup <||> {
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contactgroup.cfg",
+ require => [ File['nagios_confd'], Package['nagios'] ],
+ notify => Service['nagios'],
+ }
+ Nagios_host <||> {
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_host.cfg",
+ require => [ File['nagios_confd'], Package['nagios'] ],
+ notify => Service['nagios'],
+ }
+ Nagios_hostdependency <||> {
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostdependency.cfg",
+ notify => Service['nagios'],
+ require => Package['nagios'],
+ }
+ Nagios_hostescalation <||> {
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostescalation.cfg",
+ notify => Service['nagios'],
+ require => Package['nagios'],
+ }
+ Nagios_hostextinfo <||> {
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostextinfo.cfg",
+ require => [ File['nagios_confd'], Package['nagios'] ],
+ notify => Service['nagios'],
+ }
+ Nagios_hostgroup <||> {
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostgroup.cfg",
+ require => [ File['nagios_confd'], Package['nagios'] ],
+ notify => Service['nagios'],
+ }
+ Nagios_service <||> {
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_service.cfg",
+ require => [ File['nagios_confd'], Package['nagios'] ],
+ notify => Service['nagios'],
+ }
+ Nagios_servicegroup <||> {
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicegroup.cfg",
+ notify => Service['nagios'],
+ require => Package['nagios'],
+ }
+ Nagios_servicedependency <||> {
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicedependency.cfg",
+ require => [ File['nagios_confd'], Package['nagios'] ],
+ notify => Service['nagios'],
+ }
+ Nagios_serviceescalation <||> {
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceescalation.cfg",
+ require => [ File['nagios_confd'], Package['nagios'] ],
+ notify => Service['nagios'],
+ }
+ Nagios_serviceextinfo <||> {
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceextinfo.cfg",
+ require => [ File['nagios_confd'], Package['nagios'] ],
+ notify => Service['nagios'],
+ }
+ Nagios_timeperiod <||> {
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_timeperiod.cfg",
+ require => [ File['nagios_confd'], Package['nagios'] ],
+ notify => Service['nagios'],
+ }
file{[ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_command.cfg",
"${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contact.cfg",
@@ -170,7 +167,8 @@ class nagios::base {
ensure => file,
replace => false,
notify => Service['nagios'],
- mode => 0644, owner => root, group => 0;
+ mode => 0644, owner => root, group => 0,
+ require => Package['nagios'],
}
# manage nagios cfg files
@@ -181,6 +179,12 @@ class nagios::base {
recurse => true,
purge => true,
notify => Service['nagios'],
- mode => 0755, owner => root, group => root;
+ mode => 0755, owner => root, group => root,
+ require => Package['nagios'],
}
+
+ file { [ '/usr/lib64', '/usr/lib64/nagios', '/usr/lib64/nagios/plugins/' ]:
+ ensure => directory
+ }
+
}
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 bb19638..07d2b1d 100644
--- a/manifests/defaults/commands.pp
+++ b/manifests/defaults/commands.pp
@@ -5,135 +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$ -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_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$';
-
- # dnsbl checking
- check_dnsbl:
- command_line => '$USER1$/check_dnsbl -H $ARG1$';
- }
+ # better check_dns
+ 'check_dns2':
+ command_line => '$USER1$/check_dns2 -c $ARG1$ A $ARG2$';
- # 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
- 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\$\\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/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 5c05ed4..8482df8 100644
--- a/manifests/nrpe.pp
+++ b/manifests/nrpe.pp
@@ -8,6 +8,11 @@ class nagios::nrpe {
include nagios::nrpe::freebsd
}
+ '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::debian
+ }
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' }
diff --git a/manifests/nrpe/base.pp b/manifests/nrpe/base.pp
index 17abb04..162abd6 100644
--- a/manifests/nrpe/base.pp
+++ b/manifests/nrpe/base.pp
@@ -2,31 +2,31 @@ 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
+ package { [ 'nagios-nrpe-server', 'nagios-plugins-basic', 'libwww-perl' ]:
+ 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 +36,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/service.pp b/manifests/service.pp
index 134d1f7..c214d7e 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_comand == 'absent' {
fail("Must pass a check_command to ${name} if it should be present")
}
- if ($use_nrpe == 'true') {
- include nagios::command::nrpe_timeout
+ 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 f9b7e13..aaa67cf 100644
--- a/manifests/target.pp
+++ b/manifests/target.pp
@@ -4,19 +4,23 @@ class nagios::target(
$parents = 'absent',
$address = $::ipaddress,
$nagios_alias = $::hostname,
- $hostgroups = 'absent'
+ $hostgroups = 'absent',
+ $notes = 'absent'
){
@@nagios_host { $::fqdn:
address => $address,
- alias => $nagios_alias,
- use => 'generic-host',
+ alias => $nagios_alias,
+ use => 'generic-host',
}
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
new file mode 100644
index 0000000..99f4601
--- /dev/null
+++ b/templates/nrpe/nrpe_command.erb
@@ -0,0 +1,2 @@
+# generated by puppet, do not edit
+command[<%= name -%>]=<%= command_line %>