Thanks nothink.org for snmpcheck
December 9th, 2006 — maxwellI’ve exchanged quite a few e-mails the past month with the maintainer of nothink.org about a Perl script he wrote called snmpcheck. This scripts gathers all kinds of information from Windows, Linux, Cisco, printers, switches, firewalls, and whatever else you have running SNMP on. It’s pretty cool. I use it in a script which runs nightly with cron to check up on systems. I then link the information into a nice little info link in Nagios. It’s really nice to use to have a list of useful information of your systems for backup purposes, or simply because you’re a monitoring junkie like me. Output looks like so:
snmpcheck.pl v1.6 - snmp enumerator Copyright (c) 2005,2006 by Matteo Cantoni (nothink.org) Creating ip address list... [*] 1 host/s to scan [*] starting... [*] try to connect to 192.168.0.27... [x] 192.168.0.27, connecting... starting check at Fri Dec 8 22:33:32 2006 Hostname : myhost Description : Linux myhost 2.6.9-42.0.3.ELsmp #1 SMP Fri Oct 6 06:21:39 CDT 2006 i686 Uptime (snmpd) : 156 days, 08:42:50.12 Domain : - Contact : root@localhost Location : The Moon Motd : - RTFM [*] Hardware and storage informations [*] Mountpoints [*] Devices [*] Processes [*] Network interfaces [*] Routing information [*] TCP connections [*] Listening UDP ports [x] 192.168.1.27, finished! Scanned in 37.082768 seconds
Obviously, each category above is filled in with all kinds of useful stuff, a few pages usually. Anyways, I just wanted to thank Matteo and pass along his cool script. Here’s my little script that I use to tie it together nightly to check my hosts, reverse lookup the IP and resolve the hostname, and then append that output to a text file which I link into Nagios to view on the web browswer.
COMSTRING1=yourstring
DATE=`/bin/date`
LINPCS='/var/www/snmp/linux'
SNMPCHECK='/usr/local/bin/snmpcheck-1.6.pl'
[ -d $LINPCS ] || mkdir $LINPCS
while read linpc
do
if ping -c 1 -w 1 $linpc > /dev/null; then
$SNMPCHECK -T 60 -t $linpc -c $COMSTRING1 >
$LINPCS/$(/usr/bin/resolveip -s $linpc).txt
else
echo -e "I'm sorry, but $(/usr/bin/resolveip -s $linpc) ($linpc)
was unreachable on $DATE. I'll try again next run, but in the meantime
please check that the host is up and has an active network connection."
>$LINPCS/$(/usr/bin/resolveip -s $linpc).txt
fi
done<<EOF
192.168.0.10
192.168.0.11
192.168.0.12
...and so on.
Yeah, I know. I’m not a scripting guru, but it works. Also, the latest version of snmpcheck allows for you to call more than one IP at the same time, which you could split the output. This would be:
./snmpcheck.pl -t 192.168.0.0/24 ./snmpcheck.pl -t 192.168.0.1-192.168.0.10 ./snmpcheck.pl -i iplist
So if you’ve never heard of this and find use of his script and my wanna-be script, then here you go.






December 26th, 2006 at 2:37 pm
You need to check out Fruity, you’ll love it.
http://fruity.sourceforge.net/