getting extension output with python bindings

Kenny Rasschaert <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I'm using net-snmp 5.7.2 and the python bindings on CentOS 6. I've
added some extensions to my local net-snmp agent with the extend
keyword. They look like this:

extend galera-seqno /usr/local/sbin/galera-status.sh seqno
extend galera-status /usr/local/sbin/galera-status.sh short

With the snmp command line tools, they work as expected:
[root@db01 ~]# snmpwalk -v 2c -c public localhost
'NET-SNMP-EXTEND-MIB::nsExtendObjects'
NET-SNMP-EXTEND-MIB::nsExtendNumEntries.0 = INTEGER: 2
NET-SNMP-EXTEND-MIB::nsExtendCommand."galera-seqno" = STRING:
/usr/local/sbin/galera-status.sh
NET-SNMP-EXTEND-MIB::nsExtendCommand."galera-status" = STRING:
/usr/local/sbin/galera-status.sh
NET-SNMP-EXTEND-MIB::nsExtendArgs."galera-seqno" = STRING: seqno
NET-SNMP-EXTEND-MIB::nsExtendArgs."galera-status" = STRING: short
NET-SNMP-EXTEND-MIB::nsExtendInput."galera-seqno" = STRING:
NET-SNMP-EXTEND-MIB::nsExtendInput."galera-status" = STRING:
NET-SNMP-EXTEND-MIB::nsExtendCacheTime."galera-seqno" = INTEGER: 5
NET-SNMP-EXTEND-MIB::nsExtendCacheTime."galera-status" = INTEGER: 5
NET-SNMP-EXTEND-MIB::nsExtendExecType."galera-seqno" = INTEGER: exec(1)
NET-SNMP-EXTEND-MIB::nsExtendExecType."galera-status" = INTEGER: exec(1)
NET-SNMP-EXTEND-MIB::nsExtendRunType."galera-seqno" = INTEGER:
run-on-read(1)
NET-SNMP-EXTEND-MIB::nsExtendRunType."galera-status" = INTEGER:
run-on-read(1)
NET-SNMP-EXTEND-MIB::nsExtendStorage."galera-seqno" = INTEGER:
permanent(4)
NET-SNMP-EXTEND-MIB::nsExtendStorage."galera-status" = INTEGER:
permanent(4)
NET-SNMP-EXTEND-MIB::nsExtendStatus."galera-seqno" = INTEGER: active(1)
NET-SNMP-EXTEND-MIB::nsExtendStatus."galera-status" = INTEGER: active(1)
NET-SNMP-EXTEND-MIB::nsExtendOutput1Line."galera-seqno" = STRING: -1
NET-SNMP-EXTEND-MIB::nsExtendOutput1Line."galera-status" = STRING: stopped
NET-SNMP-EXTEND-MIB::nsExtendOutputFull."galera-seqno" = STRING: -1
NET-SNMP-EXTEND-MIB::nsExtendOutputFull."galera-status" = STRING: stopped
NET-SNMP-EXTEND-MIB::nsExtendOutNumLines."galera-seqno" = INTEGER: 1
NET-SNMP-EXTEND-MIB::nsExtendOutNumLines."galera-status" = INTEGER: 1
NET-SNMP-EXTEND-MIB::nsExtendResult."galera-seqno" = INTEGER: 0
NET-SNMP-EXTEND-MIB::nsExtendResult."galera-status" = INTEGER: 1
NET-SNMP-EXTEND-MIB::nsExtendOutLine."galera-seqno".1 = STRING: -1
NET-SNMP-EXTEND-MIB::nsExtendOutLine."galera-status".1 = STRING: stopped

and:
[root@db01 ~]# snmpget -v 2c -c public localhost
'NET-SNMP-EXTEND-MIB::nsExtendOutLine."galera-status".1'
NET-SNMP-EXTEND-MIB::nsExtendOutLine."galera-status".1 = STRING: stopped

I'm doing some python scripting where I would love to get this data
over snmp, I was very pleased to discover that net-snmp comes with
python bindings.

Walking over 'NET-SNMP-EXTEND-MIB::nsExtendObjects' works:
>>> import netsnmp session = netsnmp.Session(Version = 2,
>>> DestHost="localhost",
Community="public")
>>> 
session.walk(netsnmp.VarList(netsnmp.Varbind("NET-SNMP-EXTEND-MIB::nsExtendObjects")))
('2', '/usr/local/sbin/galera-status.sh',
'/usr/local/sbin/galera-status.sh', 'seqno', 'short', None, None, '5',
'5', '1', '1', '1', '1', '4', '4', '1', '1', '-1', 'stopped', '-1',
'stopped', '1', '1', '0', '1', '-1', 'stopped')

Getting the output for both my extensions has also worked:
>>> 
session.walk(netsnmp.VarList(netsnmp.Varbind("NET-SNMP-EXTEND-MIB::nsExtendOutLine")))
('-1', 'stopped')

I can not, however, seem to get just the output for a specific extension:
>>> 
session.walk(netsnmp.VarList(netsnmp.Varbind('NET-SNMP-EXTEND-MIB::nsExtendOutLine."galera-short"')))
()
>>> 
session.walk(netsnmp.VarList(netsnmp.Varbind('NET-SNMP-EXTEND-MIB::nsExtendOutLine."galera-short".1')))
()
>>> 
session.get(netsnmp.VarList(netsnmp.Varbind('NET-SNMP-EXTEND-MIB::nsExtendOutLine."galera-short".1')))
('',)

I have tried about 500 variations and have furiously googled and read
documentation, blogs, guides and tutorials... without success.

And now, in my hour of desperation, I turn to the mailing list.
Can you please point me in the right direction?

Humbly yours,
- -- 
Kenny Rasschaert
+32 497 72 27 69 | Open Source consultant - Inuits.eu
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJUf0MjAAoJEB9wRUEh5BQZcsoP/iCqoK765Q0yJqh/iZ3s/Vcq
9q+AJ0zA5C5nZwn+sr2M07Wmn3frtShTYj0n6al0Ii8bTgWIyVzQ55dHpQdkA82F
YLBljOnr3ZYCbT5bCd7EO2fSevmTh+2UUN7MP/YXGAAUweYKf5DyIwdZpTmlegu/
AVa6e8/6n8Ey/Lo7nvWXOrcRDSUT+QDl8iWaJ42KG/AlLSotSpMMEAKq+u9Xo2RW
gcC+wR0Jx67fRE80EfdM1kUFGDqhaC2/3loQw4357hRCEsU43yTJMbW5osHf9Poz
TK7Osm/oiEIedgnoYBp1fFO7BYxEmerVE8hSGx0H3D5KTpx5QQ9SYwB47eUTex31
VtEEcV3cVg/a3503ii+QMRIOy2tDMFytbw6p/XrA4nSOZPH7T2QKMAg3JA4zGwJ3
w5aWyGP7idxLIXBlgrmkCuzfWbrLxQSK3K1B5yywd9MXjlD7c0wk1Pn3cac91UQu
ojm0DWIKWFOBTZtuD/14jLTwVWRPUFqR6sRoAGJ4BvapzgWvkKMrthWH7lMxC9t8
km+GIXHTYkktuMKmlC+zMleIVY4MY2m0yJqEiU9XjlBaOKGXOwZVBObWMNbH3LzO
hrCOGUPAlzpILlvAZn96qaEv4c1CQ3W+KxXyrGZBWZ8SosD/eVGE0PGs56Cz+hDt
Y4++F6oarJu674Acl1Do
=jBsS
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.