Bug 1624839

Summary: The libvirtMib_subagent sends SNMP traps with wrong objects OIDs.
Product: Red Hat Enterprise Linux 7 Reporter: Miguel Martin <mmartinv>
Component: libvirt-snmpAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: jiyan <jiyan>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 7.5CC: dyuan, fsoppels, gveitmic, jherrman, jiyan, lmen, mprivozn, mtessun, xuzhang, yalzhang
Target Milestone: rcKeywords: Upstream, ZStream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-snmp-0.0.3-6.el7 Doc Type: Bug Fix
Doc Text:
Previously, libvirt-snmp used incompatible placeholders for object identifiers (OIDs), which caused incorrect OIDs to be sent in SNMP traps. With this update, the placeholders have been corrected and are now replaced properly.
Story Points: ---
Clone Of:
: 1641995 1641997 (view as bug list) Environment:
Last Closed: 2019-08-06 12:01:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1641995, 1641997    

Description Miguel Martin 2018-09-03 12:16:44 UTC
Description of problem:
The libvirtMib_subagent sends SNMP traps with wrong objects OIDs.
 
Version-Release number of selected component (if applicable):
libvirt-snmp-0.3

How reproducible:
Always

Actual results:
The objects OIDs sent by the guest agent are:
libvirtGuestName.0
libvirtGuestUUID.1
libvirtGuestState.2
libvirtGuestRowStatus.3


Expected results:
The expected libvirtGuestNotif objects OID would be:
libvirtGuestName.0
libvirtGuestUUID.0
libvirtGuestState.0
libvirtGuestRowStatus.0

Comment 7 jiyan 2018-10-17 05:36:47 UTC
Hi Michal
I am trying to ack this BZ. I tried this Scenario in libvirt-snmp-0.0.3-1.el7_6.root1539744678.x86_64.
During the following scenario, I change the status of VM by 'snmpset' and obtain the related log info.
It seems like that the object OIDs sent by libvirtMib_subagent is as expected.
Could you please have a check about it? THX.

Version:
libvirt-snmp-0.0.3-1.el7_6.root1539744678.x86_64
libvirt-4.5.0-10.virtcov.el7_6.2.x86_64

Steps:
# virsh list --all
 Id    Name                           State
----------------------------------------------------
 1     test1                          running

# snmpwalk -m ALL -v 2c -c public -OX localhost libvirtMIB
LIBVIRT-MIB::libvirtGuestName[STRING: 20ae5bfa-a34c-4246-8f3e-f80096771360] = STRING: "test1"
LIBVIRT-MIB::libvirtGuestState[STRING: 20ae5bfa-a34c-4246-8f3e-f80096771360] = INTEGER: running(1)
LIBVIRT-MIB::libvirtGuestCpuCount[STRING: 20ae5bfa-a34c-4246-8f3e-f80096771360] = Gauge32: 1
LIBVIRT-MIB::libvirtGuestMemoryCurrent[STRING: 20ae5bfa-a34c-4246-8f3e-f80096771360] = Gauge32: 1024
LIBVIRT-MIB::libvirtGuestMemoryLimit[STRING: 20ae5bfa-a34c-4246-8f3e-f80096771360] = Gauge32: 1024
LIBVIRT-MIB::libvirtGuestCpuTime[STRING: 20ae5bfa-a34c-4246-8f3e-f80096771360] = Counter64: 84740000000
LIBVIRT-MIB::libvirtGuestRowStatus[STRING: 20ae5bfa-a34c-4246-8f3e-f80096771360] = INTEGER: active(1)

# snmpget -m ALL -v 2c -c public localhost libvirtGuestState.\'20ae5bfa-a34c-4246-8f3e-f80096771360\'
LIBVIRT-MIB::libvirtGuestState.' .[..LBF.>...w.`' = INTEGER: running(1)

# snmpset -m ALL -v 2c -c private localhost libvirtGuestState.\'20ae5bfa-a34c-4246-8f3e-f80096771360\' = paused
LIBVIRT-MIB::libvirtGuestState.' .[..LBF.>...w.`' = INTEGER: paused(3)

# tail -f /var/log/messages|grep libvirtGuestNotif
Oct 17 01:32:19 ibm-x3850x6-03 snmptrapd[16138]: localhost [UDP: [127.0.0.1]:41368->[127.0.0.1]:162]: Trap , DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (54609) 0:09:06.09, SNMPv2-MIB::snmpTrapOID.0 = OID: LIBVIRT-MIB::libvirtGuestNotif, LIBVIRT-MIB::libvirtGuestName.0 = STRING: "test1", LIBVIRT-MIB::libvirtGuestUUID.0 = STRING: 20ae5bfa-a34c-4246-8f3e-f80096771360, LIBVIRT-MIB::libvirtGuestState.0 = INTEGER: paused(3), LIBVIRT-MIB::libvirtGuestRowStatus.0 = INTEGER: active(1)
Oct 17 01:32:19 ibm-x3850x6-03 snmptrapd[16138]: localhost [UDP: [127.0.0.1]:41368->[127.0.0.1]:162]: Trap , DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (54609) 0:09:06.09, SNMPv2-MIB::snmpTrapOID.0 = OID: LIBVIRT-MIB::libvirtGuestNotif, LIBVIRT-MIB::libvirtGuestName.0 = STRING: "test1", LIBVIRT-MIB::libvirtGuestUUID.0 = STRING: 20ae5bfa-a34c-4246-8f3e-f80096771360, LIBVIRT-MIB::libvirtGuestState.0 = INTEGER: paused(3), LIBVIRT-MIB::libvirtGuestRowStatus.0 = INTEGER: active(1)

Comment 13 Michal Privoznik 2018-10-23 10:23:31 UTC
The fix as accepted upstream:

commit 9dcfc08d8c967e66271d310d8f3f2630df751562
Author:     Miguel Martin <mmartinv>
AuthorDate: Mon Sep 3 14:44:38 2018 +0200
Commit:     Michal Privoznik <mprivozn>
CommitDate: Tue Sep 4 16:26:19 2018 +0200

    Fix wrong object OIDs sent by libvirtMib_subagent
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1624839
    
    The objects OIDs sent by the guest agent are:
    libvirtGuestName.0
    libvirtGuestUUID.1
    libvirtGuestState.2
    libvirtGuestRowStatus.3
    
    The expected libvirtGuestNotif objects OID would be:
    libvirtGuestName.0
    libvirtGuestUUID.0
    libvirtGuestState.0
    libvirtGuestRowStatus.0
    
    Signed-off-by: Miguel Martin <mmartinv>

v0.0.3-7-g9dcfc08

Comment 16 yalzhang@redhat.com 2018-10-24 05:54:07 UTC
I can reproduce on libvirt-snmp-0.0.3-5.el7.x86_64, and update to the upstream version, the bug is fixed.

1. after configuration, run below command on one terminal:
# LIBVIRT_DEFAULT_URI="qemu:///system" libvirtMib_subagent -f -L 

2. on 2nd terminal, run 
# tail -f /var/log/messages | grep --line-buffered 127.0.0.1

3. destroy one guest, then check the 2nd terminal:

Oct 24 13:41:09 rhel7 snmptrapd[8239]: localhost [UDP: [127.0.0.1]:35743->[127.0.0.1]:162]: Trap , DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (198017) 0:33:00.17, SNMPv2-MIB::snmpTrapOID.0 = OID: LIBVIRT-MIB::libvirtGuestNotif, LIBVIRT-MIB::libvirtGuestName.0 = STRING: "rhel", LIBVIRT-MIB::libvirtGuestUUID.1 = STRING: 345e02af-425a-4f4d-bf7f-da3daee9bb3c, LIBVIRT-MIB::libvirtGuestState.2 = INTEGER: shutoff(5), LIBVIRT-MIB::libvirtGuestRowStatus.3 = INTEGER: notInService(2)

it shows:
libvirtGuestName.0
libvirtGuestUUID.1
libvirtGuestState.2
libvirtGuestRowStatus.3

git clone the upstream libvirt-snmp, and compile the rpm package as libvirt-snmp-0.0.3-1.el7.root1540359970.x86_64 just as comment 7, the bug is fixed.

test with the same steps above, the log shows:
Oct 24 13:50:12 rhel7 snmptrapd[13497]: localhost [UDP: [127.0.0.1]:33789->[127.0.0.1]:162]: Trap , DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (6524) 0:01:05.24, SNMPv2-MIB::snmpTrapOID.0 = OID: LIBVIRT-MIB::libvirtGuestNotif, LIBVIRT-MIB::libvirtGuestName.0 = STRING: "rhel", LIBVIRT-MIB::libvirtGuestUUID.0 = STRING: 345e02af-425a-4f4d-bf7f-da3daee9bb3c, LIBVIRT-MIB::libvirtGuestState.0 = INTEGER: shutoff(5), LIBVIRT-MIB::libvirtGuestRowStatus.0 = INTEGER: notInService(2)

it is expected:
libvirtGuestName.0
libvirtGuestUUID.0
libvirtGuestState.0
libvirtGuestRowStatus.0

Comment 18 jiyan 2018-11-08 06:44:23 UTC
Version:
libvirt-snmp-0.0.3-6.el7.x86_64
libvirt-4.5.0-10.virtcov.el7_6.2.x86_64
qemu-kvm-rhev-2.12.0-19.el7_6.2.x86_64
kernel-3.10.0-957.el7.x86_64

Configuration:
1. Install libvirt-snmp, libvirt-snmp-debuginfo, net-snmp net-snmp-libs, net-snmp-utils components
2. Modify "/etc/snmp/snmpd.conf" as following: 
   # cat /etc/snmp/snmpd.conf
   rwcommunity public
   master agentx
   trapcommunity public
   trap2sink localhost
3. Modify "/etc/snmp/snmptrapd.conf" as following: 
   # cat /etc/snmp/snmptrapd.conf 
   authCommunity log,execute,net public 
logOption f /var/log/snmptraps.log
4. Modify "/etc/sysconfig/snmptrapd" as following: 
   # cat /etc/sysconfig/snmptrapd 
   OPTIONS="-m ALL -p /var/run/snmptrapd.pid"
5. Restart related service
   # systemctl restart snmpd
   # systemctl restart snmptrapd
   # systemctl restart libvirtd


Steps:
1. Run libvirt snmp agent daemon through the following cmd on "Terminal 1"
# LIBVIRT_DEFAULT_URI="qemu:///system" libvirtMib_subagent -f -L -D ALL

2. Run snmpwalk to query domain status on "Terminal 2"
# snmpwalk -m ALL -v 2c -c public -OX localhost libvirtMIB
LIBVIRT-MIB::libvirtGuestName[STRING: 15966392-65dc-4306-9dfe-3bd92e641436] = STRING: "test1"
LIBVIRT-MIB::libvirtGuestState[STRING: 15966392-65dc-4306-9dfe-3bd92e641436] = INTEGER: running(1)
LIBVIRT-MIB::libvirtGuestCpuCount[STRING: 15966392-65dc-4306-9dfe-3bd92e641436] = Gauge32: 1
LIBVIRT-MIB::libvirtGuestMemoryCurrent[STRING: 15966392-65dc-4306-9dfe-3bd92e641436] = Gauge32: 1024
LIBVIRT-MIB::libvirtGuestMemoryLimit[STRING: 15966392-65dc-4306-9dfe-3bd92e641436] = Gauge32: 1024
LIBVIRT-MIB::libvirtGuestCpuTime[STRING: 15966392-65dc-4306-9dfe-3bd92e641436] = Counter64: 18030000000
LIBVIRT-MIB::libvirtGuestRowStatus[STRING: 15966392-65dc-4306-9dfe-3bd92e641436] = INTEGER: active(1)

which is identical with the output of 'virsh' cmd:
# virsh domstate test1
running

3. Open ths third terminal to check the log
# tail -f  /var/log/messages | grep --line-buffered "localhost [UDP: [127.0.0.1]"

4. Set the status of the domain through 'snmpset' cmd
# snmpset -m ALL -v 2c -c public localhost libvirtGuestState.\'15966392-65dc-4306-9dfe-3bd92e641436\' = paused
LIBVIRT-MIB::libvirtGuestState.'..c.e.C...;..d.6' = INTEGER: paused(3)

Verify the status of domain through 'virsh' cmd:
# virsh list --all
 Id    Name                           State
----------------------------------------------------
 3     test1                          paused

5. Check the log
# tail -f  /var/log/messages | grep --line-buffered "localhost [UDP: [127.0.0.1]"
Nov  8 01:30:33 ibm-x3250m6-05 snmptrapd[28711]: localhost [UDP: [127.0.0.1]:55609->[127.0.0.1]:162]: Trap , DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (6843) 0:01:08.43, SNMPv2-MIB::snmpTrapOID.0 = OID: LIBVIRT-MIB::libvirtGuestNotif, LIBVIRT-MIB::[***libvirtGuestName.0***] = STRING: "test1", LIBVIRT-MIB::[***libvirtGuestUUID.0***] = STRING: 15966392-65dc-4306-9dfe-3bd92e641436, LIBVIRT-MIB::[***libvirtGuestState.0***] = INTEGER: paused(3), LIBVIRT-MIB::[***libvirtGuestRowStatus.0***] = INTEGER: active(1)

Nov  8 01:30:33 ibm-x3250m6-05 snmptrapd[28711]: localhost [UDP: [127.0.0.1]:55609->[127.0.0.1]:162]: Trap , DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (6844) 0:01:08.44, SNMPv2-MIB::snmpTrapOID.0 = OID: LIBVIRT-MIB::libvirtGuestNotif, LIBVIRT-MIB::[***libvirtGuestName.0***] = STRING: "test1", LIBVIRT-MIB::[***libvirtGuestUUID.0***] = STRING: 15966392-65dc-4306-9dfe-3bd92e641436, LIBVIRT-MIB::[***libvirtGuestState.0***] = INTEGER: paused(3), LIBVIRT-MIB::[***libvirtGuestRowStatus.0***] = INTEGER: active(1)


The result in step-5 is as expected, move this bug to be verified.

Comment 21 errata-xmlrpc 2019-08-06 12:01:52 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2019:2013