Bug 1641997

Summary: The libvirtMib_subagent sends SNMP traps with wrong objects OIDs. [rhel-7.5.z]
Product: Red Hat Enterprise Linux 7 Reporter: Oneata Mircea Teodor <toneata>
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, jiyan, lmen, mmartinv, mprivozn, mtessun, smoroney, xuzhang, yalzhang
Target Milestone: rcKeywords: Upstream, ZStream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-snmp-0.0.3-5.el7_5.1 Doc Type: Bug Fix
Doc Text:
Previously, the libvirtMib subagent sent SNMP traps to the snmptrapd trap daemon with the wrong object identifiers (OIDs). As a consequence, libvirt-snmp did not display objects under their assigned OIDs. This update fixes the issue by attaching the assigned OID to the correct object.
Story Points: ---
Clone Of: 1624839 Environment:
Last Closed: 2018-12-18 14:46:44 UTC Type: ---
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: 1624839    
Bug Blocks:    

Description Oneata Mircea Teodor 2018-10-23 10:46:22 UTC
This bug has been copied from bug #1624839 and has been proposed to be backported to 7.5 z-stream (EUS).

Comment 4 jiyan 2018-11-26 02:49:48 UTC
Reproducing this issue in "libvirt-snmp-0.0.3-5.el7.x86_64"

Version:
kernel-3.10.0-862.el7.x86_64
qemu-kvm-rhev-2.12.0-18.el7_6.1.x86_64
libvirt-3.9.0-14.virtcov.el7_5.8.x86_64
libvirt-snmp-0.0.3-5.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. Check the log on "Terminal 2" 
# tail -f  /var/log/messages | grep --line-buffered "localhost [UDP: [127.0.0.1]"

3. Run snmpwalk to query and change domain status on "Terminal 3"
# snmpwalk -m ALL -v 2c -c public -OX localhost libvirtMIB
LIBVIRT-MIB::libvirtGuestName[STRING: 1c86ab6c-4b95-4644-8e47-565b266e1372] = STRING: "test1"
LIBVIRT-MIB::libvirtGuestState[STRING: 1c86ab6c-4b95-4644-8e47-565b266e1372] = INTEGER: running(1)
LIBVIRT-MIB::libvirtGuestCpuCount[STRING: 1c86ab6c-4b95-4644-8e47-565b266e1372] = Gauge32: 2
LIBVIRT-MIB::libvirtGuestMemoryCurrent[STRING: 1c86ab6c-4b95-4644-8e47-565b266e1372] = Gauge32: 1024
LIBVIRT-MIB::libvirtGuestMemoryLimit[STRING: 1c86ab6c-4b95-4644-8e47-565b266e1372] = Gauge32: 1024

# snmpset -m ALL -v 2c -c public localhost libvirtGuestState.\'1c86ab6c-4b95-4644-8e47-565b266e1372\' = paused
LIBVIRT-MIB::libvirtGuestState.'...lK.FD.GV[&n.r' = INTEGER: paused(3)

4. Check the log
# tail -f  /var/log/messages | grep --line-buffered "localhost [UDP: [127.0.0.1]"
Nov 25 21:40:08 ibm-x3850x5-08 snmptrapd[2364]: localhost [UDP: [127.0.0.1]:52546->[127.0.0.1]:162]: Trap , DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (19931) 0:03:19.31, SNMPv2-MIB::snmpTrapOID.0 = OID: LIBVIRT-MIB::libvirtGuestNotif, LIBVIRT-MIB::libvirtGuestName.0 = STRING: "test1", LIBVIRT-MIB::libvirtGuestUUID.1 = STRING: 1c86ab6c-4b95-4644-8e47-565b266e1372, LIBVIRT-MIB::libvirtGuestState.2 = INTEGER: paused(3), LIBVIRT-MIB::libvirtGuestRowStatus.3 = INTEGER: active(1)
Nov 25 21:40:08 ibm-x3850x5-08 snmptrapd[2364]: localhost [UDP: [127.0.0.1]:52546->[127.0.0.1]:162]: Trap , DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (19931) 0:03:19.31, SNMPv2-MIB::snmpTrapOID.0 = OID: LIBVIRT-MIB::libvirtGuestNotif, LIBVIRT-MIB::libvirtGuestName.0 = STRING: "test1", LIBVIRT-MIB::libvirtGuestUUID.1 = STRING: 1c86ab6c-4b95-4644-8e47-565b266e1372, LIBVIRT-MIB::libvirtGuestState.2 = INTEGER: paused(3), LIBVIRT-MIB::libvirtGuestRowStatus.3 = INTEGER: active(1)

Comment 5 jiyan 2018-11-26 02:55:52 UTC
Verifying this bug in "libvirt-snmp-0.0.3-5.el7_5.1.x86_64"

Version:
kernel-3.10.0-862.el7.x86_64
libvirt-snmp-0.0.3-5.el7_5.1.x86_64
qemu-kvm-rhev-2.12.0-18.el7_6.1.x86_64
libvirt-3.9.0-14.virtcov.el7_5.8.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. Check the log on "Terminal 2" 
# tail -f  /var/log/messages | grep --line-buffered "localhost [UDP: [127.0.0.1]"

3. Run snmpwalk to query and change domain status on "Terminal 3"
# snmpwalk -m ALL -v 2c -c public -OX localhost libvirtMIB
LIBVIRT-MIB::libvirtGuestName[STRING: 1c86ab6c-4b95-4644-8e47-565b266e1372] = STRING: "test1"
LIBVIRT-MIB::libvirtGuestState[STRING: 1c86ab6c-4b95-4644-8e47-565b266e1372] = INTEGER: running(1)
LIBVIRT-MIB::libvirtGuestCpuCount[STRING: 1c86ab6c-4b95-4644-8e47-565b266e1372] = Gauge32: 2
LIBVIRT-MIB::libvirtGuestMemoryCurrent[STRING: 1c86ab6c-4b95-4644-8e47-565b266e1372] = Gauge32: 1024
LIBVIRT-MIB::libvirtGuestMemoryLimit[STRING: 1c86ab6c-4b95-4644-8e47-565b266e1372] = Gauge32: 1024
LIBVIRT-MIB::libvirtGuestCpuTime[STRING: 1c86ab6c-4b95-4644-8e47-565b266e1372] = Counter64: 16590000000
LIBVIRT-MIB::libvirtGuestRowStatus[STRING: 1c86ab6c-4b95-4644-8e47-565b266e1372] = INTEGER: active(1)

# snmpset -m ALL -v 2c -c public localhost libvirtGuestState.\'1c86ab6c-4b95-4644-8e47-565b266e1372\' = paused
LIBVIRT-MIB::libvirtGuestState.'...lK.FD.GV[&n.r' = INTEGER: paused(3)

4. Check the log
Nov 25 21:52:58 ibm-x3850x5-08 snmptrapd[2820]: localhost [UDP: [127.0.0.1]:49404->[127.0.0.1]:162]: Trap , DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (3587) 0:00:35.87, SNMPv2-MIB::snmpTrapOID.0 = OID: LIBVIRT-MIB::libvirtGuestNotif, LIBVIRT-MIB::libvirtGuestName.0 = STRING: "test1", LIBVIRT-MIB::libvirtGuestUUID.0 = STRING: 1c86ab6c-4b95-4644-8e47-565b266e1372, LIBVIRT-MIB::libvirtGuestState.0 = INTEGER: paused(3), LIBVIRT-MIB::libvirtGuestRowStatus.0 = INTEGER: active(1)
Nov 25 21:52:58 ibm-x3850x5-08 snmptrapd[2820]: localhost [UDP: [127.0.0.1]:49404->[127.0.0.1]:162]: Trap , DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (3588) 0:00:35.88, SNMPv2-MIB::snmpTrapOID.0 = OID: LIBVIRT-MIB::libvirtGuestNotif, LIBVIRT-MIB::libvirtGuestName.0 = STRING: "test1", LIBVIRT-MIB::libvirtGuestUUID.0 = STRING: 1c86ab6c-4b95-4644-8e47-565b266e1372, LIBVIRT-MIB::libvirtGuestState.0 = INTEGER: paused(3), LIBVIRT-MIB::libvirtGuestRowStatus.0 = INTEGER: active(1)

The result in Step-4 is as expected, move this bug to be verified.

Comment 16 errata-xmlrpc 2018-12-18 14:46:44 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-2018:3848