Open VertexML opened 6 years ago
Hi Jay!
e.g. Get Description & Index only
With netsnmptable 0.1.3 you can only select by index(es) as mentioned in this example. You can't select by column yet. You can do that:
import netsnmp
import netsnmptable
session = netsnmp.Session(Version=2, DestHost='localhost', Community='public')
table = session.table_from_mib('HOST-RESOURCES-MIB::hrStorageTable')
tbldict = table.get_entries(iid=[3])
iid=[3]
will limit the underlaying getbulk to only transmit a single row of OIDs where hrStorageIndex == 3 ('Virtual memory', for my system). If you want to select on columns (like hrStorageDescr) too, you needed something like
tbldict = table.get_entries(iid = [3], columns = ['hrStorageDescr'])
Is, it? Seems to be a good idea. It should be relatively easy to implement by limiting OIDs in the initial getbulk request. I will try to add it.
Please note that netsnmptable has the same fundamental flaws as the original Net-SNMP bindings (because it's based on them):
I'm not aware of mature alternative bindings. Afaik, as of 2018, Python + Net-SNMP is in a surprisingly bad state. If there'd be a few more developers and a few users who care, I'd join and try to help to improve the situation.
Hi, I am struggling to find a python library where I can be selective of Table columns.
The example 3 - seams almost complete for my needs.
It is possible to be selective on a Table element oids in the SNMP bulk request?
e.g. Get Description & Index only - as named (if possible) or numerical oids - from hrStorageTable (for example)
I have be using the whole ifTable as per your example1 - and parsing the results I need. But I only need a few columns, and the requests take a lot longer than needed on large tables.- especailly catalyst Cisco switches with sometimes hundreds of rows. I just need OperationalStatus and ifAlias for example.
Cheers,
Jay