문제

How can I set a trap severity?

Code below

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();

Thanks,

도움이 되었습니까?

해결책

There is no standard way to specify the severity for a trap. Most agents that send "alarm" traps will define a proprietary MIB that includes a varbind for severity.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top