Add the Sysuptime in SNMP trap

As per the rfc3416 https://tools.ietf.org/search/rfc3416#page-22
The first two variable bindings in the variable binding list
of an SNMPv2-Trap-PDU are sysUpTime.0 [RFC3418] and snmpTrapOID.0
[RFC3418].

This commit adds the sysUpTime.0 [RFC3418] in the SNMP trap.

Signed-off-by: Ratan Gupta <ratagupt@linux.vnet.ibm.com>
Change-Id: Ie1a28ac2bbf30e05f0be498c278d866e9bf9c8a2
diff --git a/snmp_notification.cpp b/snmp_notification.cpp
index 420cc01..db19ecc 100644
--- a/snmp_notification.cpp
+++ b/snmp_notification.cpp
@@ -102,10 +102,25 @@
             elog<InternalFailure>();
         }
 
+        // https://tools.ietf.org/search/rfc3416#page-22
+        // add the sysUpTime.0 [RFC3418]
+        auto sysuptime = get_uptime();
+        std::string sysuptimeStr = std::to_string(sysuptime);
+
+        if (snmp_add_var(pdu, sysuptimeOID, sizeof(sysuptimeOID) / sizeof(oid),
+                         't', sysuptimeStr.c_str()))
+
+        {
+            log<level::ERR>("Failed to add the SNMP var(systime)");
+            snmp_free_pdu(pdu);
+            elog<InternalFailure>();
+        }
+
         pdu->trap_type = SNMP_TRAP_ENTERPRISESPECIFIC;
 
         auto trapInfo = getTrapOID();
 
+        // add the snmpTrapOID.0 [RFC3418]
         if (!snmp_pdu_add_variable(pdu, SNMPTrapOID,
                                    sizeof(SNMPTrapOID) / sizeof(oid),
                                    ASN_OBJECT_ID, trapInfo.first.data(),
diff --git a/snmp_notification.hpp b/snmp_notification.hpp
index 0905828..5f2bf69 100644
--- a/snmp_notification.hpp
+++ b/snmp_notification.hpp
@@ -55,6 +55,7 @@
 using Value = std::variant<uint32_t, uint64_t, int32_t, std::string>;
 // Generic snmp trap ID
 oid SNMPTrapOID[] = {1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0};
+oid sysuptimeOID[] = {1, 3, 6, 1, 2, 1, 1, 3, 0};
 
 using Object = std::tuple<OID, OID_LEN, Type, Value>;