nagios nsca wrapper

nsca vs. nrpe

Personally i favor nrpe as I can control at a central point which checks are really run. I can have 30 checks in the config but, use only 5 of them. With nsca you have to adjust the cronjob-list on every server and have no central option.

nrpe

  • + nrpe has the advantage of a semi central configuration. you can add and remove services easily from your central nagios.cfg on your nagios server
    the nagios server polls the nrpe deamon
  • – with lots of hosts there can be a problem with many checks waiting for execution

nsca

  • + with nsca the server pushes the request
  • – the configuration and maintenance is a little more difficult

setup nsca

just follow this excellent Howto found on the nagios-website
http://nagios.sourceforge.net/download/contrib/documentation/misc/NSCA_Setup.pdf

a wrapper script for nsca

once you setup nsca you somehow have to send your nrpe-scripts output to the nagios server, i wrote a simple wrapper-skript. it also does a random sleep between 1-30 seconds to further randomize the load a bit over all servers.

#!/bin/bash

nscabin=/usr/sbin/send_nsca
nscacfg=/etc/nagios/send_nsca.cfg
nagiosserver=192.168.XX.XX 
randomsleep=$RANDOM
let "randomsleep %= 30"

host=$1
shift

checkname=$1
shift

checkcommand=$@

sleep $randomsleep
output=$($checkcommand)
ret=$?
echo -e "$host\t$checkname\t$ret\t$output" | $nscabin -H $nagiosserver -c $nscacfg > /dev/null

rewrite the nrpe-config to a basic cronjob running nsca jobs

the only missing thing is a cronjob. I used this oneliner to generate some kind of base config for cron from my nrpe-configs. You have to edit it manually to fit your needs.

cat /etc/nrpe.d/* | sed "s#^command\[#*/3 * * * * nagios /etc/nagios/nsca/nscawrapper.sh $(hostname | awk -F '.' '{print $1}') nrpe_#" | sed 's/\]=/ /' > /etc/cron.d/nagiosnsca
pixelstats trackingpixel

Leave a comment

Your comment

Time limit is exhausted. Please reload the CAPTCHA.