Commit 0ca48c8a authored by Michal Privoznik's avatar Michal Privoznik

Send sysUpTime in traps

https://bugzilla.redhat.com/show_bug.cgi?id=1624879

According to RFC 1905:

  The first two variable bindings in the variable binding list of
  an SNMPv2-Trap-PDU are sysUpTime.0 and snmpTrapOID.0
  respectively.

We are setting the snmpTrapOID.0 variable but not sysUpTime.0.

Based on work of: Miguel Martin <mmartinv@redhat.com>
Signed-off-by: 's avatarMichal Privoznik <mprivozn@redhat.com>
parent 5ec2f88d
......@@ -28,6 +28,7 @@
#include "libvirtGuestTable_enums.h"
#include "libvirtSnmpError.h"
static const oid sysuptime_oid[] = { 1, 3, 6, 1, 2, 1, 1, 3, 0 };
static const oid snmptrap_oid[] = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 };
int
......@@ -49,6 +50,7 @@ send_libvirtGuestNotif_trap(virDomainPtr dom)
unsigned char domUUID[VIR_UUID_BUFLEN];
virDomainInfo info;
int rowstatus = ROWSTATUS_ACTIVE;
u_long uptime = netsnmp_get_agent_uptime();
if (virDomainGetUUID(dom, domUUID) < 0) {
printLibvirtError("Failed to get domain UUID");
......@@ -76,6 +78,15 @@ send_libvirtGuestNotif_trap(virDomainPtr dom)
break;
};
/*
* Set the sysUptime.0 value
*/
snmp_varlist_add_variable(&var_list,
sysuptime_oid, OID_LENGTH(sysuptime_oid),
ASN_TIMETICKS,
(u_char*)&uptime,
sizeof(uptime));
/*
* Set the snmpTrapOid.0 value
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment