如何设置陷阱严重性?
以下代码
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();
谢谢,
答案 0 :(得分:3)
没有标准方法来指定陷阱的严重性。发送“警报”陷阱的大多数代理将定义一个专有的MIB,其中包含严重性的varbind。