Nagios

Escape '&'

In, say, a URL. foo?bar=baz&fuzz=woot will break things as the cmd interpreter will choke on the &. You can't escape with a single \, you need two because nagios uses \ to escape !, so to pass the \ through to the shell, you need to type it twice it, a la foo?bar=baz\\&fuzz=woot.


Configuration

it starts working.


ePN

Nagios for Fedora comes default with ePN or Embedded Perl Nagios. That means any plugins written in perl will be interpreted not by perl, but by nagios. There are a lot of wierd caviats that this creates including:


Quieting Down Nagios During Host Service

OK, so you're supposed to use nagios's fancy 'planned downtime' stuff, but that includes letting the CGIs have write access, which I don't like. If you're like me, and you don't want pages when you take a system offline, set up a check host command that always says the host is down, and says the host is being maintained.

This way, you'll get one page when nagios realises the system is offline. You won't get repeated onnline/offline pages from rebooting, and even better, you won't get the 8 pages you get when the system is pingable, but not offering any other services.

Here's a command (in checkcommands.cfg in my setup) that will do just that.

define command{
    command_name check-host-planned
    command_line    $USER1$/check_dummy 2 "Down For Service"
}


Upgrading to Nagios 3 and Making CGIs run as Nagios

CentOS yum repos provide Nagios 2 only. For nagios 3, you need to enable another yum repo.

First, set up rpmforge.repo as a yum repo. See http://wiki.centos.org/AdditionalResources/Repositories/RPMForge

includepkgs = nagios

... to only include nagios from rpmforge. Then run yum update and it will update from nagios 2 to nagios 3.

Okay, it's not working. Need to re-assess cgiwrapness

Here's the apache snippet. This must go inside the appropriate virtualhost.

RewriteRule ^/nagios/cgi-bin/(.*) /nagios/cgiwrap/cgiwrap/nagios/$1 [PT]

ScriptAlias /nagios/cgiwrap/ /home/system/nagios/cgiwrap/

Alias /nagios /home/system/nagios/htdocs

<Directory "/home/system/nagios">
   AllowOverride None
   Order allow,deny
   Allow from all
   AuthName "Nagios Access"
   AuthType Basic
   AuthUserFile /etc/nagios/passwd
   Require valid-user
</Directory>

The following does some but not all of the required steps

set -e

RPMCGI=/usr/lib/nagios/cgi
RPMHTML=/usr/share/nagios
NAGIOS=/home/system/nagios

function mkdiro {
    dir=$1
    if [ -d $dir ] ; then
        return
    fi
    mkdir $dir
}

mkdiro $NAGIOS

mv $RPMHTML $NAGIOS/htdocs
mv $RPMCGI $NAGIOS/htdocs/cgi-bin

ln -s $NAGIOS/htdocs $RPMHTML
ln -s $NAGIOS/htdocs/cgi-bin $RPMCGI

usermod -d /home/system/nagios nagios
mkdiro $NAGIOS/checkresults
mkdiro $NAGIOS/rw


chown -R nagios:nagios $NAGIOS
chown -R nagios:nagios /var/log/nagios

mkdiro $NAGIOS/cgiwrap
cp /home/webmaster/cgi-bin/cgiwrap* $NAGIOS/cgiwrap

chmod -R a+rX $NAGIOS
chmod -R og-rwx $NAGIOS/checkresults
chmod -R og-rwx $NAGIOS/rw

echo all loadmodule stuff should be done in /etc/httpd/conf/loadmodule.conf
echo Hint! remove LoadModule calls from conf.d/*.conf with a command like this:
echo 'perl -p -i -e \'s/^LoadModule/#LoadModule/\' *.conf'


CategoryNotes

Nagios (last edited 2009-09-24 23:30:13 by dmartin)