BB Unix Network Monitor - Message

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

{bb} ucd-snmpwalk scripts



ok so I lied. I got inspired so I got them and cleaned a little.

I tested them out with my config.

the snmptab file format is:

hostname.domain.org:value

they don't have to be there you can set a default for all of them in the
script..

it should make sense when you read it.

its all very simple


anyway here it is below

#!/bin/sh
if [ "$DEBUG" = "ON" ]
   then
      set -x
fi

SNMPCMD="snmpwalk" #duh!
SNMPPARM="" #any special mibs go here
HOSTS="/opt/bb/etc/bb-hosts"
TABFILE="/opt/bb/etc/snmptab"
COMMUNITYNAME="public"
#set the below yo your own values - you can see i'm in the enterprises tree
#it must be a variable that will give back a single response - if it doesn't
#it's not going to work.
SNMPVARIABLE=".iso.org.dod.internet.private.enterprises.etc etc etc"
HOSTFILEGREPARG="snmp"    #tag in bb-hosts goes here

DEFVARLIMIT=60 #default limit for the variable 
grep -v "^#" $HOSTS | grep -v group | grep -v noping | grep -v "^$" | grep -i $HOSTFILEGREPARG | 

while read line
do
   set $line
   HOSTIP=$1
   MACHNAME=$2
   resvar=`$SNMPCMD $SNMPPARM $HOSTIP $COMMUNITYNAME 2> /dev/null \
 #if anyone can clean up the below I'm open to suggestions
   $SNMPVARIABLE |
     cut -d= -f2 | sed "s/ //g"`
      if [ "$resvar" != "" ]
        then
        tabarg=`grep -v "^#" $TABFILE | grep -i $MACHNAME | cut -d: -f2`
        if [ "$tabarg" = "" ]
             then
                varlimit=$DEFVARLIMIT
        else
           set `echo $tabarg`
                varlimit=$1
        fi

             #comparison based on ones in tab file
             if [ $resvar -le $varlimit ]
              then
                echo ALERT $MACHNAME - $HOSTIP = $resvar
             else
           echo $MACHNAME = $resvar
        fi
        else
     echo "ALERT: No response from host - $MACHNAME"
     fi
done



I'd love comments on my sh scripting.
thanks

-sv

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Please send mail for the mailing list to: bb@taex001.tamu.edu
  To [un]subscribe to this list, send e-mail to majordomo@taex001.tamu.edu
     with [un]subscribe bb in the BODY of the message.
  Please contact the mailing-list-owner as: bb-owner@taex001.tamu.edu


Home | Main Index | Thread Index