diff options
-rw-r--r-- | README | 19 | ||||
-rw-r--r-- | README.pnp4nagios | 49 | ||||
-rwxr-xr-x | files/plugins/check_openvpn_server.pl | 109 | ||||
-rw-r--r-- | files/pnp4nagios/action.gif | bin | 0 -> 1536 bytes | |||
-rw-r--r-- | files/pnp4nagios/apache.conf | 30 | ||||
-rw-r--r-- | files/pnp4nagios/npcd | 8 | ||||
-rw-r--r-- | files/pnp4nagios/pnp4nagios-popup-templates.cfg | 31 | ||||
-rw-r--r-- | files/pnp4nagios/pnp4nagios-templates.cfg | 33 | ||||
-rw-r--r-- | files/pnp4nagios/status-header.ssi | 8 | ||||
-rw-r--r-- | images/nagiosgraph.gif | bin | 0 -> 1252 bytes | |||
-rw-r--r-- | manifests/defaults/pnp4nagios.pp | 27 | ||||
-rw-r--r-- | manifests/munin.pp | 4 | ||||
-rw-r--r-- | manifests/pnp4nagios.pp | 57 | ||||
-rw-r--r-- | manifests/pnp4nagios/popup.pp | 21 |
14 files changed, 394 insertions, 2 deletions
@@ -190,6 +190,25 @@ PNP4Nagios Nagios Grapher integration see README.pnp4nagios +PNP4Nagios integration +====================== +Currently, there are no pnp4nagios debian packages - you need to install pnp4nagios +from source. See http://docs.pnp4nagios.org/pnp-0.6/start for installation notes. +Integration in the nagios/icinga webinterface is configured by including either the +nagios::pnp4nagios or the nagios::pnp4nagios::popup class, the later one includes +fancy popups when you hoover over the extra service action image. +For hosts you need to use the host-pnp definition, for services the srv-pnp def. +i.e. + + @@nagios_service { "ping_example_node": + use => "generic-service,srv-pnp", + ... + + nagios_host { 'example_node': + use => 'generic-host,host-pnp', + ... + + Examples ======== diff --git a/README.pnp4nagios b/README.pnp4nagios new file mode 100644 index 0000000..ac929e9 --- /dev/null +++ b/README.pnp4nagios @@ -0,0 +1,49 @@ +PNP4Nagios integration +====================== + +As of 2012/01 debian packages for pnp4nagios are availible from lenny-backports on. + +In the default config files the "Bulk Mode with NPCD" is used +(see http://docs.pnp4nagios.org/en/pnp-0.6/config for more infos about the different +modes). + +Include the nagios::pnp4nagios::popup class for fancy popups when you hoover over +the extra service action image. + + +Please include this in your nagios.cfg: + +process_performance_data=1 + +#http://docs.pnp4nagios.org/en/pnp-0.6/config#bulk_mode_mit_npcd +# +# Service Performance-Data +# +service_perfdata_file=/var/lib/nagios3/service-perfdata +service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$ +service_perfdata_file_mode=a +service_perfdata_file_processing_interval=15 +service_perfdata_file_processing_command=process-service-perfdata-file-pnp4nagios-bulk-npcd + +# +# Host Performance-Data +# +host_perfdata_file=/var/lib/nagios3/host-perfdata +host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$ +host_perfdata_file_mode=a +host_perfdata_file_processing_interval=15 +host_perfdata_file_processing_command=process-host-perfdata-file-pnp4nagios-bulk-npcd + + +For hosts you need to use the host-pnp definition, for services the srv-pnp def. +i.e. + + @@nagios_service { "ping_example_node": + use => "generic-service,srv-pnp", + ... + + nagios_host { 'example_node': + use => 'generic-host,host-pnp', + ... + + 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/files/pnp4nagios/action.gif b/files/pnp4nagios/action.gif Binary files differnew file mode 100644 index 0000000..96571a4 --- /dev/null +++ b/files/pnp4nagios/action.gif diff --git a/files/pnp4nagios/apache.conf b/files/pnp4nagios/apache.conf new file mode 100644 index 0000000..8f66756 --- /dev/null +++ b/files/pnp4nagios/apache.conf @@ -0,0 +1,30 @@ +# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER + +Alias /pnp4nagios "/usr/share/pnp4nagios/html" + +<Directory "/usr/share/pnp4nagios/html"> + AllowOverride None + Order allow,deny + Allow from all + # + # Use the same value as defined in nagios.conf + # + AuthName "Nagios Access" + AuthType Basic + AuthUserFile /etc/nagios3/htpasswd.users + Require valid-user + <IfModule mod_rewrite.c> + # Turn on URL rewriting + RewriteEngine On + Options FollowSymLinks + # Installation directory + RewriteBase /pnp4nagios/ + # Protect application and system files from being viewed + RewriteRule ^(application|modules|system) - [F,L] + # Allow any files or directories that exist to be displayed directly + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + # Rewrite all other URLs to index.php/URL + RewriteRule .* index.php/$0 [PT,L] + </IfModule> +</Directory> diff --git a/files/pnp4nagios/npcd b/files/pnp4nagios/npcd new file mode 100644 index 0000000..64b3d4d --- /dev/null +++ b/files/pnp4nagios/npcd @@ -0,0 +1,8 @@ +# Default settings for the NPCD init script. + +# Should NPCD be started? ("yes" to enable) +RUN="yes" + +# Additional options that are passed to the daemon. +DAEMON_OPTS="-d -f /etc/pnp4nagios/npcd.cfg" + diff --git a/files/pnp4nagios/pnp4nagios-popup-templates.cfg b/files/pnp4nagios/pnp4nagios-popup-templates.cfg new file mode 100644 index 0000000..de17d84 --- /dev/null +++ b/files/pnp4nagios/pnp4nagios-popup-templates.cfg @@ -0,0 +1,31 @@ +# http://docs.pnp4nagios.org/de/pnp-0.6/webfe + +define host { + name host-pnp + action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_ + register 0 +} + +define service { + name srv-pnp + action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$ + register 0 +} + +# templates for explicit use, i.e. +# use => 'generic-host-pnp' + +define host { + name generic-host-pnp + use generic-host,host-pnp +# action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_ + register 0 +} + +define service { + name generic-service-pnp + use generic-service,srv-pnp +# action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_ + register 0 +} + diff --git a/files/pnp4nagios/pnp4nagios-templates.cfg b/files/pnp4nagios/pnp4nagios-templates.cfg new file mode 100644 index 0000000..64c5186 --- /dev/null +++ b/files/pnp4nagios/pnp4nagios-templates.cfg @@ -0,0 +1,33 @@ +# http://docs.pnp4nagios.org/de/pnp-0.6/webfe + +# templates for additional use, i.e. +# use => 'generic-host,host-pnp' +define host { + name host-pnp + action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_ + register 0 +} + +define service { + name srv-pnp + action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$ + register 0 +} + +# templates for explicit use, i.e. +# use => 'generic-host-pnp' + +define host { + name generic-host-pnp + use generic-host,host-pnp +# action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_ + register 0 +} + +define service { + name generic-service-pnp + use generic-service,srv-pnp +# action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_ + register 0 +} + diff --git a/files/pnp4nagios/status-header.ssi b/files/pnp4nagios/status-header.ssi new file mode 100644 index 0000000..472be3a --- /dev/null +++ b/files/pnp4nagios/status-header.ssi @@ -0,0 +1,8 @@ +<script src="/pnp4nagios/media/js/jquery-min.js" type="text/javascript"></script> +<script src="/pnp4nagios/media/js/jquery.cluetip.js" type="text/javascript"></script> +<script type="text/javascript"> +$(document).ready(function() { + $('a.tips').cluetip({ajaxCache: false, dropShadow: false,showTitle: false }); +}); +</script> + diff --git a/images/nagiosgraph.gif b/images/nagiosgraph.gif Binary files differnew file mode 100644 index 0000000..068082a --- /dev/null +++ b/images/nagiosgraph.gif diff --git a/manifests/defaults/pnp4nagios.pp b/manifests/defaults/pnp4nagios.pp new file mode 100644 index 0000000..f6556c9 --- /dev/null +++ b/manifests/defaults/pnp4nagios.pp @@ -0,0 +1,27 @@ +class nagios::defaults::pnp4nagios { + # performance data cmds + # http://docs.pnp4nagios.org/de/pnp-0.6/config#bulk_mode_mit_npcd + nagios_command { + 'process-service-perfdata-file-pnp4nagios-bulk-npcd': + command_line => '/bin/mv /var/lib/nagios3/service-perfdata /var/spool/pnp4nagios/npcd/service-perfdata.$TIMET$'; + 'process-host-perfdata-file-pnp4nagios-bulk-npcd': + command_line => '/bin/mv /var/lib/nagios3/host-perfdata /var/spool/pnp4nagios/npcd/host-perfdata.$TIMET$' + } + + # nagios host templates + # http://docs.pnp4nagios.org/de/pnp-0.6/webfe + + # this doesn't work, see manifests/pnp4nagios.pp + #nagios_host { 'host-pnp': + # action_url => '/pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_', + # register => 0, + # #ensure => absent; + #} + + #nagios_service { 'service-pnp': + # #naginatorname => 'service-pnp', + # action_url => '/pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$', + # register => 0, + # ensure => absent; + #} +} diff --git a/manifests/munin.pp b/manifests/munin.pp index 92a389f..490b016 100644 --- a/manifests/munin.pp +++ b/manifests/munin.pp @@ -17,12 +17,12 @@ class nagios::munin inherits munin::plugins::base { exec { 'munin_nagios2stats_link': command => 'ln -s /usr/sbin/nagios2stats /usr/local/sbin/nagiostats', - onlyif => ["test ! -e /usr/local/sbin/nagiostats", "test -e /usr/sbin/nagios2stats"], + onlyif => ["/usr/bin/test ! -e /usr/local/sbin/nagiostats", "/usr/bin/test -e /usr/sbin/nagios2stats"], } exec { 'munin_nagios3stats_link': command => 'ln -s /usr/sbin/nagios3stats /usr/local/sbin/nagiostats', - onlyif => ["test ! -e /usr/local/sbin/nagiostats", "test -e /usr/sbin/nagios3stats"], + onlyif => ["/usr/bin/test ! -e /usr/local/sbin/nagiostats", "/usr/bin/test -e /usr/sbin/nagios3stats"], } } diff --git a/manifests/pnp4nagios.pp b/manifests/pnp4nagios.pp new file mode 100644 index 0000000..0f86d2a --- /dev/null +++ b/manifests/pnp4nagios.pp @@ -0,0 +1,57 @@ +class nagios::pnp4nagios { + include nagios::defaults::pnp4nagios + + package { pnp4nagios: + ensure => installed } + + + # 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::nagios_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'], + } + + file { 'apache.conf': + path => "/etc/pnp4nagios/apache.conf", + source => [ "puppet:///modules/site-nagios/pnp4nagios/apache.conf", + "puppet:///modules/nagios/pnp4nagios/apache.conf" ], + mode => 0644, owner => root, group => root, + notify => Service['apache'], + require => Package['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']; + } + + service { 'npcd': + 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']; + } + + +} diff --git a/manifests/pnp4nagios/popup.pp b/manifests/pnp4nagios/popup.pp new file mode 100644 index 0000000..b0da18b --- /dev/null +++ b/manifests/pnp4nagios/popup.pp @@ -0,0 +1,21 @@ +class nagios::pnp4nagios::popup inherits nagios::pnp4nagios { + notify {"${nagios::defaults::vars::int_nagios_cfgdir}":} + File['pnp4nagios-templates.cfg']{ + path => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/pnp4nagios-templates.cfg", + source => [ "puppet:///modules/site-nagios/pnp4nagios/pnp4nagios-popup-templates.cfg", + "puppet:///modules/nagios/pnp4nagios/pnp4nagios-popup-templates.cfg" ], + mode => 0644, owner => root, group => root, + notify => Service['nagios'], + } + + file { "/usr/share/nagios3/htdocs/ssi": + ensure => directory } + + 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'], + } +} |