rhtyd closed pull request #2045: Fix snmptrap alert bug
URL: https://github.com/apache/cloudstack/pull/2045
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/plugins/alert-handlers/snmp-alerts/src/org/apache/cloudstack/alert/snmp/SnmpHelper.java
 
b/plugins/alert-handlers/snmp-alerts/src/org/apache/cloudstack/alert/snmp/SnmpHelper.java
index 576abf3020f..80f07af8c93 100644
--- 
a/plugins/alert-handlers/snmp-alerts/src/org/apache/cloudstack/alert/snmp/SnmpHelper.java
+++ 
b/plugins/alert-handlers/snmp-alerts/src/org/apache/cloudstack/alert/snmp/SnmpHelper.java
@@ -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.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 @@ private PDU createPDU(SnmpTrapInfo snmpTrapInfo) {
 
         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 @@ private PDU createPDU(SnmpTrapInfo snmpTrapInfo) {
     private OID getOID(String oidString) {
         return new OID(oidString);
     }
-}
\ No newline at end of file
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to