mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-10208: Fix snmptrap alert bug (#2045)
Fix snmptrap alerts info omit to send the field of SnmpConstants.sysUpTime Fix SnmpConstants.sysUpTime expression Remove unused import java.util.Date
This commit is contained in:
parent
7544ebe248
commit
d95ba438f6
@ -18,6 +18,7 @@
|
||||
package org.apache.cloudstack.alert.snmp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
|
||||
import org.snmp4j.CommunityTarget;
|
||||
import org.snmp4j.PDU;
|
||||
@ -27,6 +28,7 @@ import org.snmp4j.smi.OID;
|
||||
import org.snmp4j.smi.OctetString;
|
||||
import org.snmp4j.smi.UdpAddress;
|
||||
import org.snmp4j.smi.UnsignedInteger32;
|
||||
import org.snmp4j.smi.TimeTicks;
|
||||
import org.snmp4j.smi.VariableBinding;
|
||||
import org.snmp4j.transport.DefaultUdpTransportMapping;
|
||||
|
||||
@ -65,6 +67,8 @@ public class SnmpHelper {
|
||||
|
||||
int alertType = snmpTrapInfo.getAlertType() + 1;
|
||||
if (alertType > 0) {
|
||||
long sysUpTimeTicks = ManagementFactory.getRuntimeMXBean().getUptime() / 10;
|
||||
trap.add(new VariableBinding(SnmpConstants.sysUpTime, new TimeTicks(sysUpTimeTicks)));
|
||||
trap.add(new VariableBinding(SnmpConstants.snmpTrapOID, getOID(CsSnmpConstants.TRAPS_PREFIX + alertType)));
|
||||
if (snmpTrapInfo.getDataCenterId() != 0) {
|
||||
trap.add(new VariableBinding(getOID(CsSnmpConstants.DATA_CENTER_ID), new UnsignedInteger32(snmpTrapInfo.getDataCenterId())));
|
||||
@ -99,4 +103,4 @@ public class SnmpHelper {
|
||||
private OID getOID(String oidString) {
|
||||
return new OID(oidString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user