I wanted to monitor the SL500 tape library at work and it supports SNMP. I downloaded the MIB from the tape library, opened it and thought "What is this gibberish? and How am I going to make sense of this?". I used snmptranslate, a lot of typing, and the following.
Jangle: Java SNMP GUI -
http://www.petertribble.co.uk/Solaris/jangle.htmlThe SNMP Cuddletech Reference -
http://www.cuddletech.com/articles/tekref/SNMP.tekref.txtI wrote a script to check the tape drives temperature and another to check the fans status. I use cron to run them on Solaris 10 and should work on LInux with minor changes. The scripts below are generic to illustrate the concept.
#!/usr/bin/bash
# Retrive tape drive temperatures using SNMP and email output
#Define variables
SNMPGET=/usr/sfw/bin/snmpget
AWK=/usr/bin/awk
DATE=$(/usr/bin/date)
SLEEP=/usr/bin/sleep
MAILX=/usr/bin/mailx
#Retrive and format temperature
Y1=$($SNMPGET -v snmp_version -c community_string -m /path/to/tape/library/MIB tape_library_IP_address OID)
T1C=$(echo $Y1 | $AWK '{ print $NF }')
T1F=$(echo $T1C | $AWK '{ TF = (9 / 5) * $1 +32; print TF }')
#1 second pause between requests
$SLEEP 1
Y2=$($SNMPGET -v snmp_version -c community_string -m /path/to/tape/library/MIB tape_library_IP_address OID)
T2C=$(echo $Y2 | $AWK '{ print $NF }')
T2F=$(echo $T2C | $AWK '{ TF = (9 / 5) * $1 +32; print TF }')
$SLEEP 1
Y3=$($SNMPGET -v snmp_version -c community_string -m /path/to/tape/library/MIB tape_library_IP_address OID)
T3C=$(echo $Y1 | $AWK '{ print $NF }')
T3F=$(echo $T3C | $AWK '{ TF = (9 / 5) * $1 +32; print TF }')
$SLEEP 1
Y4=$($SNMPGET -v snmp_version -c community_string -m /path/to/tape/library/MIB tape_library_IP_address OID)
T4C=$(echo $Y4 | $AWK '{ print $NF }')
T4F=$(echo $T4C | $AWK '{ TF = (9 / 5) * $1 +32; print TF }')
# Clear previous contents and put current date and time in file
echo -e ""$DATE"\n" > /path/to/output/file
# Append report title in file
echo " Current SL500 tape drive temperatures. " >> /path/to/output/file
echo " Drive 1 temp is "$T1C"C "$T1F"F" >> /path/to/output/file
echo " Drive 2 temp is "$T2C"C "$T2F"F" >> /path/to/output/file
echo " Drive 3 temp is "$T3C"C "$T3F"F" >> /path/to/output/file
echo " Drive 4 temp is "$T4C"C "$T4F"F" >> /path/to/output/file
echo -e "\n\n" >> /path/to/output/file
echo "Warning temperature: 43C/109.4F" >> /path/to/output/file
echo "Automated library shutdown temperature: 48C/118.4F" >> /path/to/output/file
# Email report
cat /path/to/output/file | $MAILX -s "SL500 tape drive temperatures" email_address,another_email_address
# This should also work
# $MAILX -s "SL500 tape drive temperatures" email_address,another_email_address < /path/to/output/file
#!/usr/bin/bash
# Retrive tape library fan status
SNMPGET=/usr/sfw/bin/snmpget
AWK=/usr/bin/awk
DATE=$(/usr/bin/date)
SLEEP=/usr/bin/sleep
MAILX=/usr/bin/mailx
SED=/usr/bin/sed
F1=$($SNMPGET -v snmp_version -c community_string -m /path/to/tape/library/MIB tape_library_IP_address OID)
FP1=$(echo $F1 | $AWK '{ print $NF }')
S1=$($SNMPGET -v snmp_version -c community_string -m /path/to/tape/library/MIB tape_library_IP_address OID)
FS1=$(echo $S1 | $SED 's/(2)//' | $AWK '{ print $NF }')
$SLEEP 1
F2=$($SNMPGET -v snmp_version -c community_string -m /path/to/tape/library/MIB tape_library_IP_address OID)
FP2=$(echo $F2 | $AWK '{ print $NF }')
S2=$($SNMPGET -v snmp_version -c community_string -m /path/to/tape/library/MIB tape_library_IP_address OID)
FS2=$(echo $S2 | $SED 's/(2)//' | $AWK '{ print $NF }')
$SLEEP 1
F3=$($SNMPGET -v snmp_version -c community_string -m /path/to/tape/library/MIB tape_library_IP_address OID)
FP3=$(echo $F3 | $AWK '{ print $NF }')
S3=$($SNMPGET -v snmp_version -c community_string -m /path/to/tape/library/MIB tape_library_IP_address OID)
FS3=$(echo $S3 | $SED 's/(2)//' | $AWK '{ print $NF }')
$SLEEP 1
F4=$($SNMPGET -v snmp_version -c community_string -m /path/to/tape/library/MIB tape_library_IP_address OID)
FP4=$(echo $F4 | $AWK '{ print $NF }')
S4=$($SNMPGET -v snmp_version -c community_string -m /path/to/tape/library/MIB tape_library_IP_address OID)
FS4=$(echo $S4 | $SED 's/(2)//' | $AWK '{ print $NF }')
$SLEEP 1
F5=$($SNMPGET -v snmp_version -c community_string -m /path/to/tape/library/MIB tape_library_IP_address OID)
FP5=$(echo $F5 | $AWK '{ print $NF }')
S5=$($SNMPGET -v snmp_version -c community_string -m /path/to/tape/library/MIB tape_library_IP_address OID)
FS5=$(echo $S5 | $SED 's/(2)//' | $AWK '{ print $NF }')
$SLEEP 1
F6=$($SNMPGET -v snmp_version -c community_string -m /path/to/tape/library/MIB tape_library_IP_address OID)
FP6=$(echo $F6 | $AWK '{ print $NF }')
S6=$($SNMPGET -v snmp_version -c community_string -m /path/to/tape/library/MIB tape_library_IP_address OID)
FS6=$(echo $S6 | $SED 's/(2)//' | $AWK '{ print $NF }')
echo -e ""$DATE"\n" > /path/to/output/file
echo " SL500 fans status. " >> /path/to/output/file
echo " Fan $FP1 is $FS1" >> /path/to/output/file
echo " Fan $FP2 is $FS2" >> /path/to/output/file
echo " Fan $FP3 is $FS3" >> /path/to/output/file
echo " Fan $FP4 is $FS4" >> /path/to/output/file
echo " Fan $FP5 is $FS5" >> /path/to/output/file
echo " Fan $FP6 is $FS6" >> /path/to/output/file
cat /path/to/output/file | $MAILX -s "SL500 fans status" email_address,another_email_address