Creating Custom Scripts
Both the good and the bad of passive checks is that you will need to construct your own scripts in order to assess the output and determine the host and service status. Here is a simple example of what you will need to do.
# Custom Script for Users
USERS=`who |wc -l`
if (($USERS <= 3 ))
then CMD=”nagpass;Users;0;Current Users $USERS”
elif (( $USERS >= 4 ))
then CMD=”nagpass;Users;1;Current Users $USERS”
/bin/echo $CMD | /usr/sbin/send_nsca -H 192.168.5.50 -d ‘;’ -c $CFG
Here is the output, 3 or less users, you send the “O” for OK.
Here the output is more than 3 users so you issue a warning with “1”.
If the output is over your warning level you can enter “2” for critical.