#!/usr/local/bin/bash # --------------------------------- # The Hovgaard Klan, DH, 2006-05-07 # --------------------------------- # This script fetches the total WAN incoming bytes from my internet # router (a Soekris/m0n0wall box) through SNMP. # The counter is created as "SNMP mode" which means it will # automatically calculate the total bytes into bytes per second # (this can be changed). # # Run command: # ./wan_in.sh # # I call this script once in a minute from my crontab. # # Enable debug information #set -x # My router IP address and my counter ID (CID) - change this to your own router_ip=192.168.1.1 counter_id=07297b2f75fc27f8cd95cf748850784a9b1570d3 snmp_get=`/usr/local/bin/snmpget -v2c -Oqvt -c public $router_ip system.sysUpTime.0 interfaces.ifTable.ifEntry.ifInOctets.2` bytes=`echo $snmp_get | /usr/bin/awk '{print $2}'` /usr/local/bin/curl --silent http://data.hovmon.com/?cid=$counter_id\&val=$bytes > /dev/null echo Total incoming bytes: $bytes bytes