Created
April 11, 2014 04:07
-
-
Save lloydsheng/10440385 to your computer and use it in GitHub Desktop.
monit snmp with snmpwalk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
import datetime | |
command = 'snmpwalk -v3 -l NoAuthNoPriv -u cisco 192.168.1.1 "ifInOctets.10"' | |
r = os.popen(command).read() | |
last_octes = r.replace("\n", "").split(" ")[-1] | |
last_octes = int(last_octes) | |
per = 3 | |
while (True): | |
r = os.popen(command).read() | |
octes = r.replace("\n", "").split(" ")[-1] | |
octes = int(octes) | |
width = (octes - last_octes)/1024.0/1024.0/per*8 | |
print "%s: %.1fm" % (datetime.datetime.now().strftime("%H:%M:%S"), width) | |
last_octes = octes; | |
time.sleep(per) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment