Bug 1472852

Summary: systemd returns 0 prCount when net-snmpd collect number of running processes
Product: [Fedora] Fedora Reporter: Josef Ridky <jridky>
Component: net-snmpAssignee: Josef Ridky <jridky>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 27CC: jridky, jsafrane, masanari.iida, qe-baseos-security, thozza
Target Milestone: ---Keywords: Patch
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1461666 Environment:
Last Closed: 2018-03-27 09:06:42 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:

Description Josef Ridky 2017-07-19 14:13:49 UTC
+++ This bug was initially created as a clone of Bug #1461666 +++

Description of problem:
Configure  following lines in /etc/snmp/snmpd.conf, 
in order to monitor number of runnig processes by net-snmp.
proc systemd
proc sshd

In case of systemd, the snmpd failed to collect number
of running processes.
In case of "other than systemd", the snmpd successfully
collect number of running processes.

Affected version
net-snmp-5.7.3


How reproducible:
Always

Steps to Reproduce:
1. Add following 2 lines in /etc/snmp/snmpd.conf

proc systemd
proc sshd

2.  Restart net-snmpd 
# systemctl restart snmpd.service

3.  Access MIB
snmpwalk -v 2c -c public 127.0.0.1 .1.3.6.1.4.1.2021.2

Actual results:
# snmpwalk -v 2c -c public 127.0.0.1 .1.3.6.1.4.1.2021.2
UCD-SNMP-MIB::prIndex.1 = INTEGER: 1
UCD-SNMP-MIB::prIndex.2 = INTEGER: 2
UCD-SNMP-MIB::prNames.1 = STRING: systemd
UCD-SNMP-MIB::prNames.2 = STRING: sshd
UCD-SNMP-MIB::prMin.1 = INTEGER: 1
UCD-SNMP-MIB::prMin.2 = INTEGER: 1
UCD-SNMP-MIB::prMax.1 = INTEGER: 0
UCD-SNMP-MIB::prMax.2 = INTEGER: 0
UCD-SNMP-MIB::prCount.1 = INTEGER: 0  <== Always 0
UCD-SNMP-MIB::prCount.2 = INTEGER: 8  <== Expected 
UCD-SNMP-MIB::prErrorFlag.1 = INTEGER: error(1) <= Not expected
UCD-SNMP-MIB::prErrorFlag.2 = INTEGER: noError(0)
UCD-SNMP-MIB::prErrMessage.1 = STRING: No systemd process running  <= not expected
UCD-SNMP-MIB::prErrMessage.2 = STRING:
UCD-SNMP-MIB::prErrFix.1 = INTEGER: noError(0)
UCD-SNMP-MIB::prErrFix.2 = INTEGER: noError(0)
UCD-SNMP-MIB::prErrFixCmd.1 = STRING:
UCD-SNMP-MIB::prErrFixCmd.2 = STRING:


Expected results:
prCount for systemd should be same as running systemd processes.


Additional info:
Same test on Fedora 24, the prCount for systemd is 1.
systemd-229-20.fc24.x86_64
net-snmp-5.7.3-13.fc24.x86_64

Judging from these test result, I suspect something wrong 
wrong with systemd-219 side.

--- Additional comment from Lukáš Nykrýn on 2017-06-15 07:27:58 EDT ---

Well I know nothing about net-snmp especially how it determines running processes.
ALso the results on fedora looks fishy, since systemd runs as one process.

Reassigning to net-snmp, so someone more qualified in this area could check it.

--- Additional comment from Josef Ridky on 2017-07-19 10:03 EDT ---

I apologize for later answer.

Here is proposed patch, which solves described problem.
Issue was caused by wrongly used iterator, which iterates thru net-snmp structure and always ignore first record.

Comment 1 Jan Kurik 2017-08-15 09:07:47 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 27 development cycle.
Changing version to '27'.