1
如何設置陷阱嚴重性?SNMP4j陷阱嚴重性
代碼如下
TransportMapping transport = new DefaultUdpTransportMapping();
Snmp snmp = new Snmp(transport);
CommunityTarget localtarget = new CommunityTarget();
localtarget.setCommunity(new OctetString("public"));
localtarget.setAddress(new UdpAddress(managerIpAdd + "/162"));
localtarget.setVersion(SnmpConstants.version2c);
localtarget.setRetries(3);
localtarget.setTimeout(2000);
PDU pdu = new PDU();
// need to specify the system up time
pdu.add(new VariableBinding(SnmpConstants.sysUpTime, new OctetString(new Date().toString())));
pdu.add(new VariableBinding(SnmpConstants.snmpTrapOID, targetOID));
pdu.add(new VariableBinding(SnmpConstants.snmpTrapAddress, new IpAddress(ApplicationUtil.getMachineIpAddress())));
// variable binding for Enterprise Specific objects, Severity (should be defined in MIB file)
pdu.add(new VariableBinding(targetOID, new OctetString(message)));
pdu.setType(PDU.TRAP);
snmp.send(pdu, localtarget);
snmp.close();
感謝,
感謝您的回覆。那麼你說什麼是每個SNMP管理器都有自己的MIB來指定陷阱的嚴重性? – Jin 2010-08-12 07:45:29
我在談論經紀人,而不是經理。該代理可以擁有專有的MIB,也可以不支持嚴重性的想法。 經理可以選擇接受代理分配的嚴重性,分配它自己的或完全忽略它。它沒有如何完成的標準。 – hallidave 2010-08-12 17:21:35
除了上面討論的陷阱之外,代理通常會提供一種獲取當前活動警報(包括嚴重性字段)的方法。但正如@hallidave所提到的,通常這是不合適的。 – k1eran 2014-09-16 12:51:52