#!/bin/sh botname=nagiosbot host=localhost port=6667 warn=10 crit=15 while getopts 'H:p:w:c:' opt do case "$opt" in H) host="$OPTARG";; p) port="$OPTARG";; w) warn="$OPTARG";; c) crit="$OPTARG";; esac done # if your netcat does not have the -i flag, modify the script below, # putting this function in the pipeline between echo and nc function delay { while read line do sleep 1 echo $line done } SECONDS=0 echo "NICK $botname USER $botname 8 * : $botname QUIT" | nc -i 1 -w $crit $host $port 2>&1 > /dev/null exit=$? if [ ! "$exit" == 0 ]; then echo "IRCd CRITICAL: $host: connection failed" exit $exit fi if [ "$SECONDS" -ge "$crit" ]; then echo "IRCd CRITICAL: $host: check took $SECONDS" exit 2 elif [ "$SECONDS" -ge "$warn" ]; then echo "IRCd WARNING: $host: check took $SECONDS" exit 1 else echo "IRCd OK: $host: check took $SECONDS" exit 0 fi