我特別試圖發送SNMP陷阱到包括一個CPU值(cpuValue),我從SNMPGET函數獲得的管理器。然而,我無法找到如何做到這一點的方法。任何幫助,將不勝感激。謝謝。pysnmp addVarbinds通知CPU值
這是我的pysnmp腳本的狙擊手。
cpuValue = GetCPU(cpuMontype)
if cpuValue == -1:
printString = "Could not poll %s CPU value " %(cpuMontype)
printString += "from device %s" %(name)
print printString
elif cpuValue > 1.0:
mibBuilder = builder.MibBuilder().loadModules('UCD-SNMP-MIB')
mibNode, = mibBuilder.importSymbols('UCD-SNMP-MIB', 'laLoad')
errorIndication, errorStatus, errorIndex, varBinds = next(
sendNotification(SnmpEngine(snmpEngineId),
UsmUserData ('authOnlyUser', 'password', 'password',
authProtocol=ntforg.usmHMACSHAAuthProtocol,
privProtocol=ntforg.usmAesCfb128Protocol),
UdpTransportTarget(('localhost', 162)),
ContextData(),
'trap',
NotificationType(
ObjectIdentity('1.3.6.1.2.1.88.2.1.5')
).**addVarBinds(ObjectType(ObjectIdentity('DISMAN-EVENT-MIB', 'mteHotValue', 0))**
)
)
)
感謝您的例子。 – Ken