0

我正在使用 pysnmp 生成 v3 陷阱

应该如何用陷阱发送触发信息的时间

4

1 回答 1

0

您可能可以使用sysUpTime对象来传达 SNMP 系统正常运行时间信息。

或者,您可以使用专用于携带时间信息的特殊自定义 OID(通过添加它.addVarBinds())。

from pysnmp.hlapi import *

errorIndication, errorStatus, errorIndex, varBinds = next(
    sendNotification(
        SnmpEngine(),
        UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
        UdpTransportTarget(('demo.snmplabs.com', 162)),
        ContextData(),
        'trap',
        NotificationType(
            # your trap type
            ObjectIdentity('1.3.6.1.6.3.1.1.5.2')
        ).addVarBinds(
             # sysUpTime in hundredths of a second
             ObjectType(ObjectIdentity('1.3.6.1.2.1.1.3.0'), 123456)
        )
    )
)
于 2018-11-28T10:27:27.267 回答