[Nagiosplug-devel] Nagios-plugin to check Cisco Interface input queue

Michael Markstaller mm at elabnet.de
Fri Jul 18 11:38:15 CEST 2003


Hi,

I just built me a lousy but working quickhack to monitor, if an interface input-queue on a Cisco-router grows above a specific value. Maybe somebody finfs it useful.
You might think what current exploit this is for, I just want to make sure and also monitor it in general for future as I had other bugs were the queue grew that way..
I found no snmp-value to poll this out so I used a (very lousy) thing: rsh wrapped in a shell-script.
I already use rsh to poll NAT/Inspect-stats for mtrg on several routers - I'm sure there're 100 better ways to do, but this works for me so far..
Sometime I'd tend to bring this thing into a perlscript using at least telnet or even better ssh, but it's Friday evening and the Biergarten is waiting ;)
Maybe this shouldn't go into the contrib or wider production, without being re-written with more time and another concept than rsh as I don't want to distribute lousy things ;)


Quick-HowTo:
- enable rsh on the router:
--- cut ---
ip rcmd rsh-enable
ip rcmd remote-host nagios <IP-OF-NAGIOS-HOST> nagios enable
! below is only for testing with root-account
ip rcmd remote-host nagios <IP-OF-NAGIOS-HOST> root enable
--- cut ---


- services.cfg
--- cut ---
define service{
	use				xyz-template
	host_name			xyz-host
	service_description	IfInQueue
	normal_check_interval	30
	check_command		check_ifqueue!RSH-USER!Serial0/0:0!15!30
	}
--- cut ---

- checkcommands.cfg
--- cut ---
# 'check_ifqueue' command definition
define command{
	command_name		check_ifqueue
	command_line	$USER1$/check_ifqueue.sh $HOSTADDRESS$ $ARG1$ "$ARG2$" $ARG3$ $ARG4$
	}
--- cut ---



- the script check_ifqueue.sh should go into the nagios-plugins-folder, set correct rights so nagios can execute it
--- cut ---
#! /bin/sh

Exe=/usr/bin/rsh

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin

PROGNAME=`basename $0`
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION=`echo '$Revision: 1.0 $' | sed -e 's/[^0-9.]//g'`

. $PROGPATH/utils.sh


print_usage() {
	echo "Usage: $PROGNAME HOSTNAME RSH-USERNAME IF-NAME WARN-LEVEL CRIT-LEVEL"
}

print_help() {
	print_revision $PROGNAME $REVISION
	echo ""
	print_usage
	echo ""
	echo "This plugin checks the given cisco interface input queue by using rsh."
	echo "quickhack 17. July 2003 Michael Markstaller / ElabNET"
	echo "on router: #ip rcmd rsh-enable# and #ip rcmd remote-host nagios <IP-OF-NAGIOS-HOST> nagios enable#"
	echo ""
	support
	exit 3
}

if [ ! "$#" == "5" ]; then
	print_help
fi

rshUser=$2
ifname=$3
WARN=$4
CRIT=$5

case "$1" in
	--help)
		print_help
		exit 0
		;;
	-h)
		print_help
		exit 0
		;;
	--version)
   	print_revision $PROGNAME $REVISION
		exit 0
		;;
	-V)
		print_revision $PROGNAME $REVISION
		exit 0
		;;
	*)
		
		ifInQlen=`$Exe -l $rshUser $1 "show int $ifname | inc Input" | cut -d ':' -f 2 | cut -d '/' -f 1 | awk '{print $1}' | head -n 1`
		if test ${ifInQlen} -gt $CRIT; then
			echo "CRITICAL - InQueue of $ifname is $ifInQlen (gt $CRIT)"
			exit 2
		elif test ${ifInQlen} -gt $WARN; then
			echo "WARNING - InQueue of $ifname is $ifInQlen (gt $WARN)"
			exit 1
		elif test ${ifInQlen} -lt $WARN; then
			echo "OK - InQueue of $ifname is $ifInQlen"
			exit 0
		else
			echo "UNKNOWN - Output $ifInQlen - in $1 $2 $3 $4 $5"
			exit -1
		fi
		;;
esac
--- cut ---


Michael




More information about the Devel mailing list