Python Forum

Full Version: is this possible in python? please support
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

I am polling ZTE OLT, and getting different length List from 6 different OIDs, as below, suggestion required to print

### Operation status of the interface###
[root@localhost ~]# snmpwalk -v2c -c sky123 172.19.2.130 1.3.6.1.2.1.2.2.1.8.285278722
IF-MIB::ifOperStatus.285278722 = INTEGER: up(1)

### Admin status of interface ###
[root@localhost ~]# snmpwalk -v2c -c sky123 172.19.2.130 1.3.6.1.2.1.2.2.1.7.285278722
IF-MIB::ifAdminStatus.285278722 = INTEGER: up(1)


### Name of interface ###

[root@localhost ~]# snmpwalk -v2c -c sky123 172.19.2.130 1.3.6.1.2.1.31.1.1.1.1.285278722
IF-MIB::ifName.285278722 = STRING: gpon_1/2/2

### ONU ports ####

[root@localhost ~]# snmpwalk -v2c -c sky123 172.19.2.130 1.3.6.1.4.1.3902.1082.500.10.2.3.3.1.3.285278722
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.3.1.3.285278722.1 = STRING: "ONU-2:1"
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.3.1.3.285278722.2 = STRING: "ONU-2:2"
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.3.1.3.285278722.4 = STRING: "ONU-2:4"
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.3.1.3.285278722.5 = STRING: "ONU-2:5"
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.3.1.3.285278722.6 = STRING: "ONU-2:6"
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.3.1.3.285278722.7 = STRING: "ONU-2:7"
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.3.1.3.285278722.8 = STRING: "ONU-2:8"

### Connected customers ###

[root@localhost ~]# snmpwalk -v2c -c sky123 172.19.2.130 1.3.6.1.4.1.3902.1082.500.10.2.3.3.1.2.285278722
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.3.1.2.285278722.1 = STRING: "ONU-2:1"
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.3.1.2.285278722.2 = STRING: "Customer ID - C2100010833 Mr Adithya BJ Port 1/2/2 ONU Id - 2"
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.3.1.2.285278722.4 = STRING: "Customer ID - C2100011918 Mrs Vijayalakshmi A Port 1/2/2 ONU Id - 4"
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.3.1.2.285278722.5 = STRING: "Customer ID - C2100011948 Mr. Balasundaram Port 1/2/2 ONU Id - 5"
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.3.1.2.285278722.6 = STRING: "Customer ID - C2100012259 Mr Ramkumar S Port 1/2/2 ONU Id - 6"
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.3.1.2.285278722.7 = STRING: "Customer ID - C2100012980 Mr Muthukumar K Port 1/2/2 ONU Id - 7"
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.3.1.2.285278722.8 = STRING: "Customer ID-C2100016300 Mr Ramakrishnamission Ashrama Port 1/2/2 ONU Id - 8"

### status of ports ###
[root@localhost ~]# snmpwalk -v2c -c sky123 172.19.2.130 1.3.6.1.4.1.3902.1082.500.10.2.3.8.1.4.285278722
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.8.1.4.285278722.1 = INTEGER: 7
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.8.1.4.285278722.2 = INTEGER: 4
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.8.1.4.285278722.4 = INTEGER: 4
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.8.1.4.285278722.5 = INTEGER: 4
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.8.1.4.285278722.6 = INTEGER: 5
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.8.1.4.285278722.7 = INTEGER: 4
SNMPv2-SMI::enterprises.3902.1082.500.10.2.3.8.1.4.285278722.8 = INTEGER: 5

possible to print output in below format? please guide

PON Port admin status op Status ONU Customer ONU Status
gpon_1/2/2 Up Up ONU-2:1 1 7
gpon_1/2/2 Up Up ONU-2:2 2 5
gpon_1/2/2 Up Up ONU-2:3 3 4
gpon_1/2/2 Up Up ONU-2:4 4 4
gpon_1/2/2 Up Up ONU-2:5 5 4
gpon_1/2/2 Up Up ONU-2:6 6 4
gpon_1/2/2 Up Up ONU-2:7 7 4
gpon_1/2/2 Up Up ONU-2:8 8 4
This looks very similar to a plethora of previous posts that you have had.
Can't you garner enough from those posts to solve?
(Apr-04-2018, 10:28 AM)Larz60+ Wrote: [ -> ]This looks very similar to a plethora of previous posts that you have had.
Can't you garner enough from those posts to solve?

Frankly speaking, not able to solve.
import itertools
from itertools import izip_longest
a=['ONU-2:1','Customer ID - C2100010833 Mr Adithya BJ Port 1/2/2 ONU Id - 2'                                                                                        

,'Customer ID - C2100011918 Mrs Vijayalakshmi A Port 1/2/2 ONU Id - 4','Customer                                                                                        

 ID - C2100011948 Mr. Balasundaram Port 1/2/2 ONU Id - 5','Customer ID - C210001                                                                                        

2259 Mr Ramkumar S  Port 1/2/2 ONU Id - 6','Customer ID - C2100012980 Mr Muthuku                                                                                        

mar K  Port 1/2/2 ONU Id - 7','Customer ID-C2100016300   Mr Ramakrishnamission A                                                                                        

shrama  Port 1/2/2 ONU Id - 8']
b=['gpon_1/2/2']

for x, y in izip_longest(a, b, fillvalue=b[0]):
    print("{0:20s}\t{1:20s}".format(x,y))
Output:
ONU-2:1 gpon_1/2/2 Customer ID - C2100010833 Mr Adithya BJ Port 1/2/2 ONU Id - 2 gpon_1/2/2 Customer ID - C2100011918 Mrs Vijayalakshmi A Port 1/2/2 ONU Id - 4 gpon_1/2/2 Customer ID - C2100011948 Mr. Balasundaram Port 1/2/2 ONU Id - 5 gpon_1/2/2 Customer ID - C2100012259 Mr Ramkumar S Port 1/2/2 ONU Id - 6 gpon_1/2/2 Customer ID - C2100012980 Mr Muthukumar K Port 1/2/2 ONU Id - 7 gpon_1/2/2 Customer ID-C2100016300 Mr Ramakrishnamission Ashrama Port 1/2/2 ONU Id - 8 gpon_1/2/2
this is solving purpose for two list, how to implement for multiple list.