From d34da8424e8b35022f6d5f2ee9a68bc6cedccad6 Mon Sep 17 00:00:00 2001 From: varac Date: Sat, 23 Oct 2010 02:55:17 +0200 Subject: basic pnp4nagios grapher integration --- README | 19 +++++++++++++++++ files/pnp4nagios/pnp4nagios-popup-templates.cfg | 14 +++++++++++++ files/pnp4nagios/pnp4nagios-templates.cfg | 14 +++++++++++++ files/pnp4nagios/status-header.ssi | 8 ++++++++ manifests/defaults/pnp4nagios.pp | 27 +++++++++++++++++++++++++ manifests/pnp4nagios.pp | 17 ++++++++++++++++ manifests/pnp4nagios/popup.pp | 17 ++++++++++++++++ 7 files changed, 116 insertions(+) create mode 100644 files/pnp4nagios/pnp4nagios-popup-templates.cfg create mode 100644 files/pnp4nagios/pnp4nagios-templates.cfg create mode 100644 files/pnp4nagios/status-header.ssi create mode 100644 manifests/defaults/pnp4nagios.pp create mode 100644 manifests/pnp4nagios.pp create mode 100644 manifests/pnp4nagios/popup.pp diff --git a/README b/README index 9c4e056..de50806 100644 --- a/README +++ b/README @@ -178,6 +178,25 @@ Options to change the behavior of the nagios module: 'notice' if you would prefer them to be sent as IRC NOTICE messages. +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/files/pnp4nagios/pnp4nagios-popup-templates.cfg b/files/pnp4nagios/pnp4nagios-popup-templates.cfg new file mode 100644 index 0000000..0035c63 --- /dev/null +++ b/files/pnp4nagios/pnp4nagios-popup-templates.cfg @@ -0,0 +1,14 @@ +# 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 +} + diff --git a/files/pnp4nagios/pnp4nagios-templates.cfg b/files/pnp4nagios/pnp4nagios-templates.cfg new file mode 100644 index 0000000..14b60c9 --- /dev/null +++ b/files/pnp4nagios/pnp4nagios-templates.cfg @@ -0,0 +1,14 @@ +# http://docs.pnp4nagios.org/de/pnp-0.6/webfe + +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 +} + 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 @@ + + + + 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/pnp4nagios.pp b/manifests/pnp4nagios.pp new file mode 100644 index 0000000..051bad8 --- /dev/null +++ b/manifests/pnp4nagios.pp @@ -0,0 +1,17 @@ +class nagios::pnp4nagios { + include nagios::defaults::pnp4nagios + + package { [php5, php5-gd, rrdcollect, rrdtool, librrdp-perl, librrds-perl ]: + 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" ] + } +} diff --git a/manifests/pnp4nagios/popup.pp b/manifests/pnp4nagios/popup.pp new file mode 100644 index 0000000..372fe3b --- /dev/null +++ b/manifests/pnp4nagios/popup.pp @@ -0,0 +1,17 @@ +class nagios::pnp4nagios::popup inherits nagios::pnp4nagios { + File['pnp4nagios-templates.cfg']{ + path => "$nagios::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" ] + } + + file { "/usr/share/$nagios::nagios_packagename/htdocs/ssi": + ensure => directory } + + file { 'status-header.ssi': + path => "/usr/share/$nagios::nagios_packagename/htdocs/ssi/status-header.ssi", + source => [ "puppet:///modules/site-nagios/pnp4nagios/status-header.ssi", + "puppet:///modules/nagios/pnp4nagios/status-header.ssi" ] + } + +} -- cgit v1.2.3