ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject ambari git commit: AMBARI-22458 - SNMP Trap should contain sysuptime field filled (Amarnathreddy Pappu via jonathanhurley)
Date Tue, 28 Nov 2017 15:30:58 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 3fa1289ea -> 73d99d8c3


AMBARI-22458 - SNMP Trap should contain sysuptime field filled (Amarnathreddy Pappu via jonathanhurley)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/73d99d8c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/73d99d8c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/73d99d8c

Branch: refs/heads/trunk
Commit: 73d99d8c3f7f0067f06b1a0c04eccbcf9554c0bd
Parents: 3fa1289
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Tue Nov 28 10:29:59 2017 -0500
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Tue Nov 28 10:30:41 2017 -0500

----------------------------------------------------------------------
 .../notifications/dispatchers/AmbariSNMPDispatcher.java  | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/73d99d8c/ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/AmbariSNMPDispatcher.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/AmbariSNMPDispatcher.java
b/ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/AmbariSNMPDispatcher.java
index 596079b..8e397ed 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/AmbariSNMPDispatcher.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/AmbariSNMPDispatcher.java
@@ -38,9 +38,13 @@ import org.snmp4j.smi.OID;
 import org.snmp4j.smi.OctetString;
 import org.snmp4j.smi.VariableBinding;
 import org.snmp4j.util.DefaultPDUFactory;
+import org.snmp4j.smi.TimeTicks;
 
 import com.google.inject.Singleton;
 
+import java.lang.management.RuntimeMXBean;
+import java.lang.management.ManagementFactory;
+
 /**
  * The {@link AmbariSNMPDispatcher} class is used to dispatch {@link AlertNotification} via
SNMP using predefined Ambari OIDs.
  *
@@ -113,7 +117,12 @@ public class AmbariSNMPDispatcher extends SNMPDispatcher {
         }
 
         pdu.setType(snmpVersion.getTrapType());
-        // Set trap oid for PDU
+    
+        RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
+        long uptimeInMillis = runtimeMXBean.getUptime();
+        pdu.add(new VariableBinding(SnmpConstants.sysUpTime, new TimeTicks(uptimeInMillis)));
+
+       // Set trap oid for PDU
         pdu.add(new VariableBinding(SnmpConstants.snmpTrapOID, new OID(AMBARI_ALERT_TRAP_OID)));
         // Set notification body and subject for PDU objects with identifiers specified in
dispatch properties.
         AlertNoticeDispatchService.AlertInfo alertInfo = alertNotification.getAlertInfo();


Mime
View raw message