Feb-08-2018, 07:27 PM
try
import time import sys from easysnmp import snmp_get, snmp_set, snmp_walk from collections import Counter start = time.time() host = sys.argv[1] oid = '.1.3.6.1.4.1.1286.1.3.18.2.1.1.1.7' # Perform an SNMP walk walk = snmp_walk(oid, hostname=host, community='public', version=2) #print (status) portstatus = [item.value for item in walk] cntr = Counter(portstatus) PortUpCount = cntr['1'] PortDownCount = cntr['2'] print('PortDownCount:{} PortUpCount:{}'.format(PortDownCount, PortUpCount)) print('It took', time.time()-start, 'seconds.')in any case if there is no other status (i.e. only '1' or '2') in your code you don't need to count both