TCP-MIB::tcpConnectionTable
を歩いているうちに、resolveWithMib()
を呼び出した後にテーブルインデックスが未解決のまま残っていることに気付きました。 MIB機器のデバッグをオンにすると、サイズ制約のチェックがテキストのIPアドレス値に適用され、raw(4バイト)値には適用されないことが明らかになりました。 IF-MIB::ifIndex
のように、IPアドレス以外のテーブルインデックスでは問題は発生しません。 ObjectIdentity.resolveWithMib()がInetAddressIPv4タイプのインスタンスインデックスの解決に失敗しました
from pysnmp.smi.rfc1902 import ObjectIdentity
from pysnmp.smi.builder import MibBuilder
from pysnmp.smi.compiler import addMibCompiler
from pysnmp.smi.view import MibViewController
from pysnmp.debug import Debug, setLogger
builder = MibBuilder()
addMibCompiler(builder)
builder.loadModules('IF-MIB')
builder.loadModules('TCP-MIB')
view = MibViewController(builder)
def doit(*poargs):
print(ObjectIdentity(*poargs).resolveWithMib(view).getMibSymbol())
setLogger(Debug('all'))
doit('.1.3.6.1.2.1.2.2.1.2.1')
doit('.1.3.6.1.2.1.6.19.1.7.1.9.49.48.46.48.46.48.46.49.49.22.1.14.49.57.50.46.49.54.57.46.50.48.46.49.53.52.2629')
戻り値:
2017-09-28 19:14:35,045 pysnmp: running pysnmp version 4.3.9
2017-09-28 19:14:35,045 pysnmp: debug category 'all' enabled
2017-09-28 19:14:35,045 pysnmp: resolving .1.3.6.1.2.1.2.2.1.2.1 as OID or label
2017-09-28 19:14:35,046 pysnmp: indexMib: re-indexing MIB view
2017-09-28 19:14:35,049 pysnmp: getNodeNameByOid: resolved :1.3.6.1.2.1.2.2.1.2.1 -> ('iso', 'org', 'dod', 'internet', 'mgmt', 'mib-2', 'interfaces', 'ifTable', 'ifEntry', 'ifDescr').1
2017-09-28 19:14:35,049 pysnmp: resolved ('.1.3.6.1.2.1.2.2.1.2.1',) into prefix ObjectName('1.3.6.1.2.1.2.2.1.2') and suffix ObjectName('1')
2017-09-28 19:14:35,049 pysnmp: getNodeNameByOid: resolved :1.3.6.1.2.1.2.2.1.2 -> ('iso', 'org', 'dod', 'internet', 'mgmt', 'mib-2', 'interfaces', 'ifTable', 'ifEntry', 'ifDescr').()
2017-09-28 19:14:35,049 pysnmp: resolved prefix ObjectName('1.3.6.1.2.1.2.2.1.2') into MIB node MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 2), DisplayString(subtypeSpec=ConstraintsIntersection(ValueSizeConstraint(0, 65535), ValueSizeConstraint(0, 255), ValueSizeConstraint(0, 255))))
2017-09-28 19:14:35,049 pysnmp: getNodeNameByOid: resolved :(1, 3, 6, 1, 2, 1, 2, 2, 1) -> ('iso', 'org', 'dod', 'internet', 'mgmt', 'mib-2', 'interfaces', 'ifTable', 'ifEntry').()
2017-09-28 19:14:35,049 pysnmp: resolved indices are (InterfaceIndex(1),)
('IF-MIB', 'ifDescr', (InterfaceIndex(1),))
2017-09-28 19:14:35,050 pysnmp: resolving .1.3.6.1.2.1.6.19.1.7.1.9.49.48.46.48.46.48.46.49.49.22.1.14.49.57.50.46.49.54.57.46.50.48.46.49.53.52.2629 as OID or label
2017-09-28 19:14:35,051 pysnmp: getNodeNameByOid: resolved :1.3.6.1.2.1.6.19.1.7.1.9.49.48.46.48.46.48.46.49.49.22.1.14.49.57.50.46.49.54.57.46.50.48.46.49.53.52.2629 -> ('iso', 'org', 'dod', 'internet', 'mgmt', 'mib-2', 'tcp', 'tcpConnectionTable', 'tcpConnectionEntry', 'tcpConnectionState').1.9.49.48.46.48.46.48.46.49.49.22.1.14.49.57.50.46.49.54.57.46.50.48.46.49.53.52.2629
2017-09-28 19:14:35,051 pysnmp: resolved ('.1.3.6.1.2.1.6.19.1.7.1.9.49.48.46.48.46.48.46.49.49.22.1.14.49.57.50.46.49.54.57.46.50.48.46.49.53.52.2629',) into prefix ObjectName('1.3.6.1.2.1.6.19.1.7') and suffix ObjectName('1.9.49.48.46.48.46.48.46.49.49.22.1.14.49.57.50.46.49.54.57.46.50.48.46.49.53.52.2629')
2017-09-28 19:14:35,051 pysnmp: getNodeNameByOid: resolved :1.3.6.1.2.1.6.19.1.7 -> ('iso', 'org', 'dod', 'internet', 'mgmt', 'mib-2', 'tcp', 'tcpConnectionTable', 'tcpConnectionEntry', 'tcpConnectionState').()
2017-09-28 19:14:35,051 pysnmp: resolved prefix ObjectName('1.3.6.1.2.1.6.19.1.7') into MIB node MibTableColumn((1, 3, 6, 1, 2, 1, 6, 19, 1, 7), Integer32(subtypeSpec=ConstraintsIntersection(ValueRangeConstraint(-2147483648, 2147483647), ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12))), NamedValues((('synReceived', 4), ('established', 5), ('finWait2', 7), ('timeWait', 11), ('finWait1', 6), ('lastAck', 9), ('closeWait', 8), ('deleteTCB', 12), ('closed', 1), ('closing', 10), ('listen', 2), ('synSent', 3)))))
2017-09-28 19:14:35,051 pysnmp: getNodeNameByOid: resolved :(1, 3, 6, 1, 2, 1, 6, 19, 1) -> ('iso', 'org', 'dod', 'internet', 'mgmt', 'mib-2', 'tcp', 'tcpConnectionTable', 'tcpConnectionEntry').()
2017-09-28 19:14:35,052 pysnmp: error resolving table indices at MibTableRow, (9, 49, 48, 46, 48, 46, 48, 46, 49, 49, 22, 1, 14, 49, 57, 50, 46, 49, 54, 57, 46, 50, 48, 46, 49, 53, 52, 2629): ConstraintsIntersection(ValueSizeConstraint(0, 65535), ValueSizeConstraint(4, 4)) failed at: ValueConstraintError("ValueSizeConstraint(4, 4) failed at: ValueConstraintError('10.0.0.11',)",) at InetAddressIPv4
2017-09-28 19:14:35,052 pysnmp: resolved indices are ((9, 49, 48, 46, 48, 46, 48, 46, 49, 49, 22, 1, 14, 49, 57, 50, 46, 49, 54, 57, 46, 50, 48, 46, 49, 53, 52, 2629),)
('TCP-MIB', 'tcpConnectionState', ((9, 49, 48, 46, 48, 46, 48, 46, 49, 49, 22, 1, 14, 49, 57, 50, 46, 49, 54, 57, 46, 50, 48, 46, 49, 53, 52, 2629),))
のインスタンスインデックス((9, 49, 48, 46, ...),)
として未解決のままにしてIF-MIB::ifDescr
'TCP-MIB::tcpConnectionState
をしながら、Sインスタンスインデックスが(InterfaceIndex(1),)
に正しく解決された' どのように注意してください。
この問題を解決するにはどうすればよいですか?
感謝をあなたは応答のために!私は、OID自体が不正であることに同意します。それはNet-SNMPから取られているので、そこで質問をリダイレクトします。 – astralblue
一方、エージェントから返された不正なOIDを処理するために、要求から取得したOIDをSNMPEngineインスタンスのリゾルバビューに渡す前に、プログラム可能なフックを挿入する方法はありますか? – astralblue