first hrSWInstalledIndex is 0, should be 1

Bug #1314760 reported by Vince N
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
net-snmp (Ubuntu)
Fix Released
Medium
Christian Ehrhardt 

Bug Description

According to RFC 2790 the hrSWInstalledIndex should start at 1:

  hrSWInstalledIndex OBJECT-TYPE
       SYNTAX Integer32 (1..2147483647)
       MAX-ACCESS read-only
       STATUS current
       DESCRIPTION
           "A unique value for each piece of software installed
           on the host. This value shall be in the range from 1
           to the number of pieces of software installed on the
           host."
       ::= { hrSWInstalledEntry 1 }

However, when grabbing the hrSWInstalledTable, my first entry is at index 0.
Example:
$ snmpbulkget -v2c -c public -Cn1 -Cr1 -ObentU localhost 1.3.6.1.2.1.25.6.3
.1.3.6.1.2.1.25.6.3.1.1.0 = INTEGER: 0

For a CentOS 6 host the behavior is according to spec:
$ snmpbulkget -v2c -c public -Cn1 -Cr1 -ObentU centos6_srv.example.com 1.3.6.1.2.1.25.6.3
.1.3.6.1.2.1.25.6.3.1.1.1 = INTEGER: 1

I found this issue while trying to read HOST-RESOURCES-MIB::hrSWRunPerfTable with pysnmp, but kept getting an exception:
ConstraintsIntersection(ConstraintsIntersection(ConstraintsIntersection(), ValueRangeConstraint(-2147483648, 2147483647)), ValueRangeConstraint(1, 2147483647)) failed at: "ValueRangeConstraint(1, 2147483647) failed at: "0"" at Integer32
---
ApportVersion: 2.12.5-0ubuntu2.2
Architecture: amd64
DistroRelease: Ubuntu 13.10
InstallationDate: Installed on 2011-04-30 (1095 days ago)
InstallationMedia: Ubuntu 11.04 "Natty Narwhal" - Release amd64 (20110427.1)
MarkForUpload: True
Package: net-snmp (not installed)
ProcVersionSignature: Ubuntu 3.11.0-19.33-generic 3.11.10.5
Tags: saucy
Uname: Linux 3.11.0-19-generic x86_64
UpgradeStatus: Upgraded to saucy on 2013-10-18 (194 days ago)
UserGroups: adm admin cdrom dialout libvirtd lpadmin netdev plugdev sambashare wireshark

Revision history for this message
Vince N (libertyshadow) wrote : ProcEnviron.txt

apport information

tags: added: apport-collected saucy
description: updated
Robie Basak (racb)
Changed in net-snmp (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Eugene M. Kim (astralblue) wrote :

The upstream has a bugfix (yet to be released), which I am attaching here. Please consider locally applying it for the time being.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in net-snmp (Ubuntu):
status: New → Confirmed
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "The upstream fix for the bug" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
tags: added: server-next
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
Changed in net-snmp (Ubuntu):
assignee: nobody → ChristianEhrhardt (paelzer)
status: Confirmed → In Progress
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Hmm,
this is unfortunate.
We really have everything together for a fix to be pushed, except valid steps to reproduce.
And I'm not snmp'ish enough to fix it up (in the constraint of my patience) it seems.

The initially reported command always gives me:
.1.3.6.1.2.1.25.6.3 = No more variables left in this MIB View (It is past the end of the MIB tree)

I tried to modify the command, installed extra MIB libraries, ...
Nothing worked so far :-/

I can get up to uptime .1.3.6.1.2.1.25.1.1.0
But nothing else in .1.3.6.1.2.1.25 seems populated.

# snmpwalk -v2c -c public localhost 1.3.6.1.2.1.25
iso.3.6.1.2.1.25.1.1.0 = Timeticks: (143971700) 16 days, 15:55:17.00
iso.3.6.1.2.1.25.1.2.0 = Hex-STRING: 07 E2 02 17 07 03 3B 00 2B 00 00
iso.3.6.1.2.1.25.1.3.0 = INTEGER: 393216
iso.3.6.1.2.1.25.1.4.0 = STRING: "BOOT_IMAGE=/boot/vmlinuz-4.4.0-109-generic.efi.signed root=UUID=7da7e070-6e58-4b1b-ad8b-11ddb9c46992 ro quiet splash crashkernel"
iso.3.6.1.2.1.25.1.5.0 = Gauge32: 0
iso.3.6.1.2.1.25.1.6.0 = Gauge32: 75
iso.3.6.1.2.1.25.1.7.0 = INTEGER: 0
iso.3.6.1.2.1.25.1.7.0 = No more variables left in this MIB View (It is past the end of the MIB tree)

I think we should be able to test this before pushing I have to ask the reporter (or anyone else) if you'd know how to prepare that?

Not giving up yet ...

Changed in net-snmp (Ubuntu):
status: In Progress → Incomplete
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

I thought I found it.

1. get extra MIBs (I had that already before)
$ apt install snmp-mibs-downloader

# modify to actually load all of them
$ cat /etc/snmp/snmp.conf
mibs +ALL

# restart the daemon
$ systemctl restart snmpd

But this exposes maybe another bug:
Bad operator (INTEGER): At line 73 in /usr/share/snmp/mibs/ietf/SNMPv2-PDU
But does not give me populated entries where I need them.

Even though it shows up in snmptranslate -Tp now at least :-/

Hmm - actually is this RPM only, no there are dpkg-query commands in there ...
Waiting for an snmp experienced user to tell me how to test this :-/

Revision history for this message
Vince N (libertyshadow) wrote :

Happy to help. Sorry my current testing environment is not suited for this, I hope docker is OK enough.

Attaching snmpd.conf, steps to follow.

Revision history for this message
Vince N (libertyshadow) wrote :

Download attached dockerfile and build a docker image
$ docker build -t snmptest:latest .

Start snmpd container:
$ docker run --name snmpd --rm -it snmptest:latest

Run the snmpbulkget in another ephemeral container:
$ docker run --network="container:snmpd" --rm -it snmptest:latest \
snmpbulkget -v2c -c public -Cn1 -Cr1 -Os localhost HOST-RESOURCES-MIB::hrSWInstalledTable

Result:
hrSWInstalledIndex.0 = INTEGER: 0

If these steps are not good enough for your processes I can try to reproduce it from a 17.10 virtual machine.

Revision history for this message
Vince N (libertyshadow) wrote :

@paelzer Check your snmpd.conf, make sure the OID you are searching for (.1.3.6.1.2.1.25.6) is included in the view for the community you are using.

Revision history for this message
Vince N (libertyshadow) wrote :

Attaching a rough pysnmp (4.2.5) test

$ python ./hrSwInstall.py centos6_srv.example.com 161 v2comm
HOST-RESOURCES-MIB::hrSWInstalledIndex."1" 1
HOST-RESOURCES-MIB::hrSWInstalledIndex."2" 2
HOST-RESOURCES-MIB::hrSWInstalledIndex."3" 3
HOST-RESOURCES-MIB::hrSWInstalledIndex."4" 4
HOST-RESOURCES-MIB::hrSWInstalledIndex."5" 5
$ python ./hrSwInstall.py ubuntu_srv.example.com 161 v2comm
Failed: ConstraintsIntersection(ConstraintsIntersection(ConstraintsIntersection(), ValueRangeConstraint(-2147483648, 2147483647)), ValueRangeConstraint(1, 2147483647)) failed at: "ValueRangeConstraint(1, 2147483647) failed at: "0"" at Integer32

Hope these resources help with testing. I've worked around this for a few years now; it would be nice to see an upstream fix merged.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

I agree to "I've worked around this for a few years now; it would be nice to see an upstream fix merged.". If the upstream policy on releasing would not be that bad Debian and Ubuntu would also have that for years already.

Anyway no time to complain ... with your suggestions I got a repro case:

On any Bionic system:
$ apt install snmpd snmp snmp-mibs-downloader
# Add to /etc/snmp/snmpd.conf
  view systemonly included .1.3.6.1.2.1.25
  rocommunity public localhost
$ systemctl restart snmpd
$ snmpbulkget -v2c -c public -Cn1 -Cr1 -Os localhost HOST-RESOURCES-MIB::hrSWInstalledTable
hrSWInstalledIndex.0 = INTEGER: 0

Installed from the ppa:
$ snmpbulkget -v2c -c public -Cn1 -Cr1 -Os localhost HOST-RESOURCES-MIB::hrSWInstalledTable
hrSWInstalledIndex.1 = INTEGER: 1

Also the upgrade was smooth, with all that in place (MP, Test, ...) ready to upload.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Needed some help in proposed migration, but it is ready now.
Yet it is blocked behind the perl migration - once that succeeds it will get into bionic-release as well.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package net-snmp - 5.7.3+dfsg-1.8ubuntu3

---------------
net-snmp (5.7.3+dfsg-1.8ubuntu3) bionic; urgency=medium

  * d/p/0001-swinst_apt.c-Fix-indexing-of-hrSWInstalledTable-to-s.patch:
    set first hrSWInstalledIndex to 1 to follow RFC 2790 (LP: #1314760)

 -- Christian Ehrhardt <email address hidden> Tue, 20 Feb 2018 15:24:41 +0100

Changed in net-snmp (Ubuntu):
status: Incomplete → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.