simple snmp counter script

this is a simple little script to count the errors and other things out put over snmp during the course of one minute.

i didnt leave the output portion of this script on the bottom of it since i was using it for a couple of different things.

#!/bin/bash -x

# count is a "counter" for snmp objects of type count

case $1 in

    'count')

      # to check errors - try oid "ifInErrors.x" & ifOutErrors.x"
      COUNT_IN=/tmp/count_in.snmp
      SNMP_IN=`snmpwalk -v 1 -c svipoll -Oqv <ip address> ifInOctets.1`
      SNMPFILEIN=`cat $COUNT_IN`
      let SNMPSUB=$SNMP_IN-$SNMPFILEIN
      echo "Echoing total number of counts from the last minute"
      echo "$SNMPSUB in the last minute"
      echo $SNMP_IN > $COUNT_IN
    ;;

    *) echo "<count|bw>, vi $0 to see it work"
esac
«
»

    Leave a Reply

    Your email address will not be published. Required fields are marked *