Apr-03-2018, 09:19 AM
import time import sys from easysnmp import snmp_get, snmp_set, snmp_walk from collections import Counter start = time.time() host = '172.19.2.130' custoid = '.1.3.6.1.4.1.3902.1082.500.10.2.3.3.1.2' onuoid ='.1.3.6.1.4.1.3902.1082.500.10.2.3.3.1.3' onustatoid='.1.3.6.1.4.1.3902.1082.500.10.2.3.8.1.4' ponportiod='.1.3.6.1.2.1.31.1.1.1.1' Admstatusoid='.1.3.6.1.2.1.2.2.1.7' Opestatusoid='.1.3.6.1.2.1.2.2.1.8' customer = [] onu=[] onustatus=[] ponport=[] Admstatus=[] Operstatus=[] # Perform an SNMP walk custwalk = snmp_walk(custoid, hostname=host, community='sky123', version=2) #print (status) cust = [item.value for item in custwalk] customer.append(cust) onuwalk = snmp_walk(onuoid, hostname=host, community='sky123', version=2) onudetails = [item.value for item in onuwalk] onu.append(onudetails) onustatwalk = snmp_walk(onustatoid, hostname=host, community='sky123', version=2) status = [item.value for item in onustatwalk] onustatus.append(status) ponportwalk = snmp_walk(ponportiod, hostname=host, community='sky123', version=2) ponportdetails = [item.value for item in ponportwalk] ponport.append(ponportdetails) Admstatwalk = snmp_walk(Admstatusoid, hostname=host, community='sky123', version=2) admstatusdetails=[item.value for item in Admstatwalk] Admstatus.append(admstatusdetails) for i in range(len(customer)): print('{} {} {} {} {}\n'.format(host,customer[i],onu[i],onustatus[i],ponport[i],Admstatus[i]))in above script, length of array is different, customer array is long in lenth. I am not able to print in one line
like below
PON Port admin status op Status ONU Customer ONU Status
output is as below
Output:172.19.2.130 [u'TEST 2', u'TEST 1', u'ONU-2:1', u'Customer ID - C2100010833 Mr Adithya BJ Port 1/2/2 ONU Id - 2', u'Customer ID - C2100011918 Mrs Vijayalakshmi A Port 1/2/2 ONU Id - 4', u'Customer ID - C2100011948 Mr. Balasundaram Port 1/2/2 ONU Id - 5', u'Customer ID - C2100012259 Mr Ramkumar S Port 1/2/2 ONU Id - 6', u'Customer ID - C2100012980 Mr Muthukumar K Port 1/2/2 ONU Id - 7', u'Customer ID-C2100016300 Mr Ramakrishnamission Ashrama Port 1/2/2 ONU Id - 8', u'Customer ID - C2100010851 Mr Ramesh Kumar R Port 1/2/3 ONU Id - 5', u'Customer ID - C2100015339 Mr Silambarasan R Port 1/2/4 ONU Id - 1', u'Customer ID - C2100015304 Mr Surendharkarna K Port 1/2/4 ONU Id - 2', u'Customer ID - C2100010960 Mr Ramanan R Port 1/2/4 ONU Id - 10', u'Customer ID - C2100011883 Mr Kannan Nateshan Port 1/2/5 ONU Id - 1', u'Customer ID - C2100012558 Mr Harish R 1/2/5 ONU Id - 2', u'Customer ID - C2100012760 Mr Vetrivel S Port 1/2/5 ONU Id - 3', u'Customer ID - C2100013406 Mr Ashok Kumar K Port 1/2/5 ONU Id - 5', u'Customer ID - C2100013794 Mrs Kirithiachpal K Port 1/2/5 ONU Id - 6', u'Customer ID - C2100011040 Mr. Sumathi A TK Port 1/2/5 ONU Id - 7', u'Custome