Feb-08-2018, 05:39 PM
Hi All,
#!/usr/bin/python import time import sys from easysnmp import snmp_get, snmp_set, snmp_walk start = time.time() host = sys.argv[1] oid = '.1.3.6.1.4.1.1286.1.3.18.2.1.1.1.7' PortUpCount = 0 PortDownCount = 0 # Perform an SNMP walk status= snmp_walk(oid, hostname=host, community='public', version=2) #print (status) portstatus = [] for item in status: portstatus.append(item.value) PortDownCount = portstatus.count('2') PortUpCount = portstatus.count('1') print('PortDownCount:{} PortUpCount:{}'.format(PortDownCount,PortUpCount)) print 'It took', time.time()-start, 'seconds.'this script is taking device ip as argument, post snmpwalk taking values in list and counting down and up port...
python EciPostStatus.py 10.114.1.20 PortDownCount:35 PortUpCount:29 It took 4.49605989456 seconds.currently its taking 4 to 9 seconds, output is provided to cacti for graph. Is there way to make this more faster.