G
Guest
Hey list,
I was given a task, to reproduce functionality of command specified
below by writing proper python functions to reuse in some monitoring
script:
rivendell# snmpwalk -Os -mALL -v1 -cgabilgathol 10.0.6.66
..1.3.6.1.4.1.2636.5.1.1.2
jnxBgpM2PeerIdentifier.0.ipv4."".unknown."".0.1.38.101.87.145 =
STRING: 66.250.1.253
jnxBgpM2PeerIdentifier.0.ipv4.38.101.161.119.1.38.101.161.118 =
STRING: 66.28.1.85
jnxBgpM2PeerIdentifier.0.ipv4.64.200.59.74.1.64.200.59.73 = STRING: 64.200.68.12
jnxBgpM2PeerIdentifier.0.ipv4.72.37.131.250.1.72.37.131.249 = STRING:
64.235.224.240
jnxBgpM2PeerState.0.ipv4."".unknown."".0.1.38.101.87.145 = INTEGER:
established(6)
jnxBgpM2PeerState.0.ipv4.38.101.161.119.1.38.101.161.118 = INTEGER:
established(6)
jnxBgpM2PeerState.0.ipv4.64.200.59.74.1.64.200.59.73 = INTEGER: established(6)
jnxBgpM2PeerState.0.ipv4.72.37.131.250.1.72.37.131.249 = INTEGER: established(6)
(more output)
I have already found a pysnmp library to fetch the data from the
device with a minimal amount of code:
from pysnmp.entity.rfc3413.oneliner import cmdgen
from pysnmp.smi import *
import string
cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBinds =
cmdgen.CommandGenerator().nextCmd(cmdgen.CommunityData('AmonMuil',
'gabilgathol', 0),
cmdgen.UdpTransportTarget(('fw-1.datacenter.gondor.net', 161)),
(1,3,6,1,4,1,2636,5,1,1,2))
print errorIndication, errorStatus
for i in varBinds:
print i
The problem is that I have completely stuck on the result I am
experiencing being totally human unreadable, like this:
rivendell# python snmp.py
None 0
[(ObjectName('1.3.6.1.4.1.2636.5.1.1.2.1.1.1.1.0.1.0.0.0.0.1.38.101.87.145'),
OctetString('B\xfa\x01\xfd'))]
[(ObjectName('1.3.6.1.4.1.2636.5.1.1.2.1.1.1.1.0.1.38.101.161.119.1.38.101.161.118'),
OctetString('B\x1c\x01U'))]
[(ObjectName('1.3.6.1.4.1.2636.5.1.1.2.1.1.1.1.0.1.64.200.59.74.1.64.200.59.73'),
OctetString('@\xc8D\x0c'))]
[(ObjectName('1.3.6.1.4.1.2636.5.1.1.2.1.1.1.1.0.1.72.37.131.250.1.72.37.131.249'),
OctetString('@\xeb\xe0\xf0'))]
[(ObjectName('1.3.6.1.4.1.2636.5.1.1.2.1.1.1.2.0.1.0.0.0.0.1.38.101.87.145'),
Integer32('6'))]
[(ObjectName('1.3.6.1.4.1.2636.5.1.1.2.1.1.1.2.0.1.38.101.161.119.1.38.101.161.118'),
Integer32('6'))]
[(ObjectName('1.3.6.1.4.1.2636.5.1.1.2.1.1.1.2.0.1.64.200.59.74.1.64.200.59.73'),
Integer32('6'))]
[(ObjectName('1.3.6.1.4.1.2636.5.1.1.2.1.1.1.2.0.1.72.37.131.250.1.72.37.131.249'),
Integer32('6'))]
[(ObjectName('1.3.6.1.4.1.2636.5.1.1.2.1.1.1.3.0.1.0.0.0.0.1.38.101.87.145'),
Integer32('2'))]
Since I cant find any way to translate these numbers to the same thing
snmpwalk produce, is there any clue on how to achieve that? Is it
possible at all for different devices (this one happend to be Juniper
firewall if that does matter). Also, how can I know where does this
magic oid ends and where does additional information starts (like ip
addresses added to oid 0 they all looks like another oid string
numbers) ?
Any sample of code, or hint to another lib will be very appreciated!
I was given a task, to reproduce functionality of command specified
below by writing proper python functions to reuse in some monitoring
script:
rivendell# snmpwalk -Os -mALL -v1 -cgabilgathol 10.0.6.66
..1.3.6.1.4.1.2636.5.1.1.2
jnxBgpM2PeerIdentifier.0.ipv4."".unknown."".0.1.38.101.87.145 =
STRING: 66.250.1.253
jnxBgpM2PeerIdentifier.0.ipv4.38.101.161.119.1.38.101.161.118 =
STRING: 66.28.1.85
jnxBgpM2PeerIdentifier.0.ipv4.64.200.59.74.1.64.200.59.73 = STRING: 64.200.68.12
jnxBgpM2PeerIdentifier.0.ipv4.72.37.131.250.1.72.37.131.249 = STRING:
64.235.224.240
jnxBgpM2PeerState.0.ipv4."".unknown."".0.1.38.101.87.145 = INTEGER:
established(6)
jnxBgpM2PeerState.0.ipv4.38.101.161.119.1.38.101.161.118 = INTEGER:
established(6)
jnxBgpM2PeerState.0.ipv4.64.200.59.74.1.64.200.59.73 = INTEGER: established(6)
jnxBgpM2PeerState.0.ipv4.72.37.131.250.1.72.37.131.249 = INTEGER: established(6)
(more output)
I have already found a pysnmp library to fetch the data from the
device with a minimal amount of code:
from pysnmp.entity.rfc3413.oneliner import cmdgen
from pysnmp.smi import *
import string
cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBinds =
cmdgen.CommandGenerator().nextCmd(cmdgen.CommunityData('AmonMuil',
'gabilgathol', 0),
cmdgen.UdpTransportTarget(('fw-1.datacenter.gondor.net', 161)),
(1,3,6,1,4,1,2636,5,1,1,2))
print errorIndication, errorStatus
for i in varBinds:
print i
The problem is that I have completely stuck on the result I am
experiencing being totally human unreadable, like this:
rivendell# python snmp.py
None 0
[(ObjectName('1.3.6.1.4.1.2636.5.1.1.2.1.1.1.1.0.1.0.0.0.0.1.38.101.87.145'),
OctetString('B\xfa\x01\xfd'))]
[(ObjectName('1.3.6.1.4.1.2636.5.1.1.2.1.1.1.1.0.1.38.101.161.119.1.38.101.161.118'),
OctetString('B\x1c\x01U'))]
[(ObjectName('1.3.6.1.4.1.2636.5.1.1.2.1.1.1.1.0.1.64.200.59.74.1.64.200.59.73'),
OctetString('@\xc8D\x0c'))]
[(ObjectName('1.3.6.1.4.1.2636.5.1.1.2.1.1.1.1.0.1.72.37.131.250.1.72.37.131.249'),
OctetString('@\xeb\xe0\xf0'))]
[(ObjectName('1.3.6.1.4.1.2636.5.1.1.2.1.1.1.2.0.1.0.0.0.0.1.38.101.87.145'),
Integer32('6'))]
[(ObjectName('1.3.6.1.4.1.2636.5.1.1.2.1.1.1.2.0.1.38.101.161.119.1.38.101.161.118'),
Integer32('6'))]
[(ObjectName('1.3.6.1.4.1.2636.5.1.1.2.1.1.1.2.0.1.64.200.59.74.1.64.200.59.73'),
Integer32('6'))]
[(ObjectName('1.3.6.1.4.1.2636.5.1.1.2.1.1.1.2.0.1.72.37.131.250.1.72.37.131.249'),
Integer32('6'))]
[(ObjectName('1.3.6.1.4.1.2636.5.1.1.2.1.1.1.3.0.1.0.0.0.0.1.38.101.87.145'),
Integer32('2'))]
Since I cant find any way to translate these numbers to the same thing
snmpwalk produce, is there any clue on how to achieve that? Is it
possible at all for different devices (this one happend to be Juniper
firewall if that does matter). Also, how can I know where does this
magic oid ends and where does additional information starts (like ip
addresses added to oid 0 they all looks like another oid string
numbers) ?
Any sample of code, or hint to another lib will be very appreciated!