A wrapper for grabbing performance info from Nagios plugin

check_procs is an example for a plugin which doesn’t deliver performance data:

./check_procs -a apache2 -w 1: -c 0:
PROCS OK: 33 processes with args ‘apache2’

This can be changed with the following wrapper script:

#!/bin/bash
LINE=`/usr/local/nagios/libexec/check_procs $*`
RC=$?
COUNT=`echo $LINE | awk '{print $3}'`
echo $LINE \| procs=$COUNT
exit $RC

Now you’ll get the number together with the required label:

PROCS OK: 33 processes with args ‘apache2’| procs=33