Python Forum
is this possible in python? please support
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
is this possible in python? please support
#1
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
Reply
#2
This looks very similar to a plethora of previous posts that you have had.
Can't you garner enough from those posts to solve?
Reply
#3
(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.
Reply
#4
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Support Python loop ECDSA Secp256k1 MaxiMous 0 1,912 Mar-21-2021, 04:34 PM
Last Post: MaxiMous

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020