0

I am trying to retrieve some columns in an snmp table. Depending on the permissions of the agent, sometimes columns are not returned. When that happens, the OID of the next valid response is duplicated in the varBindTable.

Is there any marker or flat that shows that the row does not contain what I requested? My application expects the result to be the same as the input.

How is a programmer supposed to notice that something is wrong with the data.

Lets start with an example: This the high level synchronous version. I am grabbing a table where the number of rows and their indexes are not known in advance.

from pysnmp.entity.rfc3413.oneliner import cmdgen

cmdGen = cmdgen.CommandGenerator()

errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.nextCmd(
    cmdgen.CommunityData('public', mpModel=0),
    cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
    'somewhere.1',
    'somewhere.2,
    'somewhere.3,
)

Lets assume that 1 and 3 exist and 2 does not. Also lets assume that these are part of a table with indexes rows of 10 and 20. What should be in varBindTable?

[   ['somewhere.1', 'Result1'],
    ['somewhere.3', 'Result3'],
    ['somewhere.3', 'Result3'] ]

or

[   ['somewhere.1', 'Result1'],
    [None, None],
    ['somewhere.3', 'Result3'] ]

I get the first. It would be nice if I got the second. Whats the point of the duplicate garbage data?

4

1 回答 1

0

当 OID 不可用时,代理会跳过它并继续使用它拥有的下一个 OID。

因此,如果您的代理在允许访问所有这些 OID 时拥有 OID 1、2 和 3,您请求 GETNEXT 1 和 2,您会收到 2 和 3 作为响应。当对 OID 2 的访问被拒绝时,您请求 GETNEXT 1 和 2,您会收到 3 和 3(因为代理跳过了 2)。

为了证明这一点,您可以启用 pysnmp 调试并查看在 Manager 和 Agent 之间实际交换了哪些 OID。

如果您正在寻找特定的 OID 并想查看它是否可用,只需使用 GET 请求,Agent 就会以值或错误响应。

于 2014-02-08T15:25:46.720 回答