commit a0f31b143929c0074c71da176b750c6c7ff04fc1 Author: sceox Date: Wed Aug 26 12:45:51 2020 -0700 initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..c9a3add --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +Simple nagios monitoring scripts. + +`check_ircd` attempts to connect to an IRC server. + +`check_senderscore` checks the senderscore (a metric for whether an IP address +tends to send spam email) of an IP address. + diff --git a/check_ircd b/check_ircd new file mode 100755 index 0000000..95cbb82 --- /dev/null +++ b/check_ircd @@ -0,0 +1,47 @@ +#!/bin/bash + +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" | nc -i 1 -q $crit -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 diff --git a/check_senderscore b/check_senderscore new file mode 100755 index 0000000..f15d190 --- /dev/null +++ b/check_senderscore @@ -0,0 +1,36 @@ +#!/bin/sh + +# bare-bones check_senderscore plugin for nagios + +# default thresholds +warn=95 +crit=90 + +while getopts 'H:w:c:' opt +do + case "$opt" in + H) host="$OPTARG";; + w) warn="$OPTARG";; + c) crit="$OPTARG";; + esac +done + +revip=`echo $host | awk -F . '{print $4"."$3"."$2"."$1".score.senderscore.com"}'` +score=`dig a $revip +short | awk -F . '{print $4""}'` + +if [ -z "$score" ]; then + echo 'SenderScore OK:' "$host" '(no score yet)' + exit 0 # ok +elif [ "$score" -gt "$warn" ]; then + echo 'SenderScore OK:' "$host:" $score + exit 0 # ok +elif [ $score -gt $crit ]; then + echo 'SenderScore WARNING:' "$host:" $score + exit 1 # warning +elif [ $score -le $crit ]; then + echo 'SenderScore CRITICAL:' "$host:" $score + exit 2 # critical +else + echo 'SenderScore UNKNOWN' + exit 3 # unknown +fi