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.pp21
-rw-r--r--manifests/debian.pp6
-rw-r--r--manifests/nrpe/debian.pp6
-rw-r--r--manifests/pnp4nagios/popup.pp27
-rw-r--r--manifests/service/mysql.pp2
-rw-r--r--manifests/stored_config.pp19
-rw-r--r--templates/nrpe/nrpe_command.erb2
10 files changed, 188 insertions, 18 deletions
diff --git a/README b/README
index 46b2a85..f799090 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
-------
@@ -149,7 +159,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 1dcef4a..291a474 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_file=/etc/nagios3/nagios_templates.cfg
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 8da9c11..8fa9061 100644
--- a/manifests/apache.pp
+++ b/manifests/apache.pp
@@ -2,12 +2,31 @@
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:///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":
+ ensure => link,
+ target => "${nagios::defaults::vars::int_cfgdir}/apache2.conf",
+ require => File["${nagios::defaults::vars::int_cfgdir}/apache2.conf"],
+ }
+ }
}
}
diff --git a/manifests/debian.pp b/manifests/debian.pp
index 9b1f7e7..b5d6974 100644
--- a/manifests/debian.pp
+++ b/manifests/debian.pp
@@ -21,11 +21,13 @@ class nagios::debian inherits nagios::base {
notify => Service['nagios'],
owner => root,
group => root,
- mode => '0644';
+ mode => '0644',
+ require => Package['nagios'];
"${nagios::defaults::vars::int_cfgdir}/stylesheets":
ensure => directory,
purge => false,
- recurse => true;
+ recurse => true,
+ require => Package['nagios'];
}
if $nagios::allow_external_cmd {
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/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/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/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 %>