Bug 595325 - hrStorage does not seem to keep track of indexes
Summary: hrStorage does not seem to keep track of indexes
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: net-snmp (Show other bugs)
(Show other bugs)
Version: 6.0
Hardware: All Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Jan Safranek
QA Contact: Karel Srot
URL:
Whiteboard:
Keywords: Patch
Depends On: 532672
Blocks: 485811 595322
TreeView+ depends on / blocked
 
Reported: 2010-05-24 11:42 UTC by Jan Safranek
Modified: 2010-11-10 21:12 UTC (History)
4 users (show)

Fixed In Version: net-snmp-5.5-21.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 532672
Environment:
Last Closed: 2010-11-10 21:12:10 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

Description Jan Safranek 2010-05-24 11:42:16 UTC
+++ This bug was initially created as a clone of Bug #532672 +++

Created an attachment (id=367291)
Proposed patch for net-snmp 5.1.2

Description of problem:

The indexes of the filesystems as reported by hrStorage are not persistent across mount/umoumts.

That breaks third party tools that rely on persistent indexes, as specified in the RFC1514:

 http://tools.ietf.org/html/rfc1514#page-6

 hrFSIndex OBJECT-TYPE
      SYNTAX INTEGER (1..2147483647)
      ACCESS read-only
      STATUS mandatory
      DESCRIPTION
              "A unique value for each file system local to this
              host.  The value for each file system must remain
              constant at least from one re-initialization of
              the agent to the next re-initialization."


Version-Release number of selected component (if applicable):

net0snmp-5.1.2

How reproducible:

Always

Steps to Reproduce:
1. Make sure the MIB for hrStorage is available:

    # cat /etc/snmp/snmpd.conf
    com2sec notConfigUser  default       public
    group   notConfigGroup v1           notConfigUser
    group   notConfigGroup v2c           notConfigUser
    view    systemview    included   .1
    access  notConfigGroup ""      any       noauth    exact  systemview none none

2. Make sure different filesystems are mounted:

    # mount
    /dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
    none on /proc type proc (rw)
    none on /sys type sysfs (rw)
    none on /dev/pts type devpts (rw,gid=5,mode=620)
    usbfs on /proc/bus/usb type usbfs (rw)
    /dev/hda1 on /boot type ext3 (rw)
    none on /dev/shm type tmpfs (rw)
    none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
    sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
    /dev/sda1 on /mnt/sda1 type ext3 (rw)
    /dev/sdb1 on /mnt/sdb1 type ext3 (rw)
    /dev/sda2 on /mnt/sda2 type ext3 (rw)
    /dev/sdb2 on /mnt/sdb2 type ext3 (rw)
    /dev/sda3 on /mnt/sda3 type ext3 (rw)
    /dev/sdb3 on /mnt/sdb3 type ext3 (rw)
    /dev/sda5 on /mnt/sda5 type ext3 (rw)
    /dev/sdb5 on /mnt/sdb5 type ext3 (rw)

3. query the hrStorage MIB with snmpwalk

    # snmpwalk -v1 -c public localhost HOST-RESOURCES-MIB::hrStorage

    HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: Memory Buffers
    HOST-RESOURCES-MIB::hrStorageDescr.2 = STRING: Real Memory
    HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: Swap Space
    HOST-RESOURCES-MIB::hrStorageDescr.4 = STRING: /
    HOST-RESOURCES-MIB::hrStorageDescr.5 = STRING: /sys
    HOST-RESOURCES-MIB::hrStorageDescr.6 = STRING: /proc/bus/usb
    HOST-RESOURCES-MIB::hrStorageDescr.7 = STRING: /boot
    HOST-RESOURCES-MIB::hrStorageDescr.8 = STRING: /proc/sys/fs/binfmt_misc
    HOST-RESOURCES-MIB::hrStorageDescr.9 = STRING: /var/lib/nfs/rpc_pipefs
    HOST-RESOURCES-MIB::hrStorageDescr.10 = STRING: /mnt/sda1
    HOST-RESOURCES-MIB::hrStorageDescr.11 = STRING: /mnt/sdb1
    HOST-RESOURCES-MIB::hrStorageDescr.12 = STRING: /mnt/sda2
    HOST-RESOURCES-MIB::hrStorageDescr.13 = STRING: /mnt/sdb2
    HOST-RESOURCES-MIB::hrStorageDescr.14 = STRING: /mnt/sda3
    HOST-RESOURCES-MIB::hrStorageDescr.15 = STRING: /mnt/sdb3
    HOST-RESOURCES-MIB::hrStorageDescr.16 = STRING: /mnt/sda5
    HOST-RESOURCES-MIB::hrStorageDescr.17 = STRING: /mnt/sdb5

4. umoung one of the file systems in the middle and remount it

    # umount /mnt/sda2
    # mount /dev/sda2 /mnt/sda2
    
5. query the hrStorage MIB with snmpwalk again

Actual results:

    HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: Memory Buffers
    HOST-RESOURCES-MIB::hrStorageDescr.2 = STRING: Real Memory
    HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: Swap Space
    HOST-RESOURCES-MIB::hrStorageDescr.4 = STRING: /
    HOST-RESOURCES-MIB::hrStorageDescr.5 = STRING: /sys
    HOST-RESOURCES-MIB::hrStorageDescr.6 = STRING: /proc/bus/usb
    HOST-RESOURCES-MIB::hrStorageDescr.7 = STRING: /boot
    HOST-RESOURCES-MIB::hrStorageDescr.8 = STRING: /proc/sys/fs/binfmt_misc
    HOST-RESOURCES-MIB::hrStorageDescr.9 = STRING: /var/lib/nfs/rpc_pipefs
    HOST-RESOURCES-MIB::hrStorageDescr.10 = STRING: /mnt/sda1
    HOST-RESOURCES-MIB::hrStorageDescr.11 = STRING: /mnt/sdb1
    HOST-RESOURCES-MIB::hrStorageDescr.12 = STRING: /mnt/sdb2
    HOST-RESOURCES-MIB::hrStorageDescr.13 = STRING: /mnt/sda3
    HOST-RESOURCES-MIB::hrStorageDescr.14 = STRING: /mnt/sdb3
    HOST-RESOURCES-MIB::hrStorageDescr.15 = STRING: /mnt/sda5
    HOST-RESOURCES-MIB::hrStorageDescr.16 = STRING: /mnt/sdb5
    HOST-RESOURCES-MIB::hrStorageDescr.17 = STRING: /mnt/sda2

=> Notice all indexes are shifted, and /mnt/sda2 now appearas in pos 14 instead of 12 previously

Expected results:

    HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: Memory Buffers
    HOST-RESOURCES-MIB::hrStorageDescr.2 = STRING: Real Memory
    HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: Swap Space
    HOST-RESOURCES-MIB::hrStorageDescr.4 = STRING: /
    HOST-RESOURCES-MIB::hrStorageDescr.5 = STRING: /sys
    HOST-RESOURCES-MIB::hrStorageDescr.6 = STRING: /proc/bus/usb
    HOST-RESOURCES-MIB::hrStorageDescr.7 = STRING: /boot
    HOST-RESOURCES-MIB::hrStorageDescr.8 = STRING: /proc/sys/fs/binfmt_misc
    HOST-RESOURCES-MIB::hrStorageDescr.9 = STRING: /var/lib/nfs/rpc_pipefs
    HOST-RESOURCES-MIB::hrStorageDescr.10 = STRING: /mnt/sda1
    HOST-RESOURCES-MIB::hrStorageDescr.11 = STRING: /mnt/sdb1
    HOST-RESOURCES-MIB::hrStorageDescr.12 = STRING: /mnt/sda2
    HOST-RESOURCES-MIB::hrStorageDescr.13 = STRING: /mnt/sdb2
    HOST-RESOURCES-MIB::hrStorageDescr.14 = STRING: /mnt/sda3
    HOST-RESOURCES-MIB::hrStorageDescr.15 = STRING: /mnt/sdb3
    HOST-RESOURCES-MIB::hrStorageDescr.16 = STRING: /mnt/sda5
    HOST-RESOURCES-MIB::hrStorageDescr.17 = STRING: /mnt/sdb5

=> indexes are persistent across umounts/mounts.

Additional info:

Later versions of net-snmp implement persistent storage indexes, but that introduces another bug:

    http://sourceforge.net/tracker/index.php?func=detail&aid=1689551&group_id=12694&atid=112694
    
Basically, indexes are now stored in a slist, but as the filesystems are taken from the mtab, and that the mtab reproduces the mounts order, unmouting/remouting a filesystem makes it appear last with a lower index, which is rejected because the index have to increase monotonically.

This is due to a side effect of the "monotonically increasing" index, a filesystem that had a lower index does not show when remounted because its index is smaller than the latest filesystem listed (as the filesystems are evaluated in the mtab order).

The following patch avoids that problem by using a replacement for the system's getmntent() which works as follow:

 - It looks first in the list for the next entry based on an index that we increment each time. The index is used to search first in the slist "filesys" that ensures persistent index values.

 - If there is no value for that index, it's the end of the slist, the function returns the next getmntent() as usual.

 - However, if there is an entry in the slist for that index, then it searches in the fstab for that name. This is because the filesystem might have been unmounted, yet we still have it in the slist.

 - If it's found, the function returns the corresponding entry. If not, it returns the next getmntent() as usual, as it means that the entry in the list is ought to be ignored as it's not mounted.

So in the end, the order is preserved, even across mounts and umounts.

Example with net-snmp 5.1.2 with the patch included:

    # snmpwalk -v1 -c public localhost HOST-RESOURCES-MIB::hrStorage

    HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: Memory Buffers
    HOST-RESOURCES-MIB::hrStorageDescr.2 = STRING: Real Memory
    HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: Swap Space
    HOST-RESOURCES-MIB::hrStorageDescr.4 = STRING: /
    HOST-RESOURCES-MIB::hrStorageDescr.6 = STRING: /proc/bus/usb
    HOST-RESOURCES-MIB::hrStorageDescr.7 = STRING: /boot
    HOST-RESOURCES-MIB::hrStorageDescr.8 = STRING: /var/lib/nfs/rpc_pipefs
    HOST-RESOURCES-MIB::hrStorageDescr.9 = STRING: /mnt/sda1
    HOST-RESOURCES-MIB::hrStorageDescr.10 = STRING: /mnt/sdb1
    HOST-RESOURCES-MIB::hrStorageDescr.11 = STRING: /mnt/sda2
    HOST-RESOURCES-MIB::hrStorageDescr.12 = STRING: /mnt/sdb2
    HOST-RESOURCES-MIB::hrStorageDescr.13 = STRING: /mnt/sda3
    HOST-RESOURCES-MIB::hrStorageDescr.14 = STRING: /mnt/sdb3
    HOST-RESOURCES-MIB::hrStorageDescr.15 = STRING: /mnt/sda5
    HOST-RESOURCES-MIB::hrStorageDescr.16 = STRING: /mnt/sdb5

    # mount /dev/sda2 /mnt/sda2
    # snmpwalk -v1 -c public localhost HOST-RESOURCES-MIB::hrStorage

    HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: Memory Buffers
    HOST-RESOURCES-MIB::hrStorageDescr.2 = STRING: Real Memory
    HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: Swap Space
    HOST-RESOURCES-MIB::hrStorageDescr.4 = STRING: /
    HOST-RESOURCES-MIB::hrStorageDescr.6 = STRING: /proc/bus/usb
    HOST-RESOURCES-MIB::hrStorageDescr.7 = STRING: /boot
    HOST-RESOURCES-MIB::hrStorageDescr.8 = STRING: /var/lib/nfs/rpc_pipefs
    HOST-RESOURCES-MIB::hrStorageDescr.9 = STRING: /mnt/sda1
    HOST-RESOURCES-MIB::hrStorageDescr.10 = STRING: /mnt/sdb1
    HOST-RESOURCES-MIB::hrStorageDescr.12 = STRING: /mnt/sdb2
    HOST-RESOURCES-MIB::hrStorageDescr.13 = STRING: /mnt/sda3
    HOST-RESOURCES-MIB::hrStorageDescr.14 = STRING: /mnt/sdb3
    HOST-RESOURCES-MIB::hrStorageDescr.15 = STRING: /mnt/sda5
    HOST-RESOURCES-MIB::hrStorageDescr.16 = STRING: /mnt/sdb5

=> notice that the indexes are preserved. there is no index 11 (previously /mnt/sda2 that is now unmounted)

    # umount /mnt/sda2
    # snmpwalk -v1 -c public localhost HOST-RESOURCES-MIB::hrStorage

    HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: Memory Buffers
    HOST-RESOURCES-MIB::hrStorageDescr.2 = STRING: Real Memory
    HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: Swap Space
    HOST-RESOURCES-MIB::hrStorageDescr.4 = STRING: /
    HOST-RESOURCES-MIB::hrStorageDescr.6 = STRING: /proc/bus/usb
    HOST-RESOURCES-MIB::hrStorageDescr.7 = STRING: /boot
    HOST-RESOURCES-MIB::hrStorageDescr.8 = STRING: /var/lib/nfs/rpc_pipefs
    HOST-RESOURCES-MIB::hrStorageDescr.9 = STRING: /mnt/sda1
    HOST-RESOURCES-MIB::hrStorageDescr.10 = STRING: /mnt/sdb1
    HOST-RESOURCES-MIB::hrStorageDescr.11 = STRING: /mnt/sda2
    HOST-RESOURCES-MIB::hrStorageDescr.12 = STRING: /mnt/sdb2
    HOST-RESOURCES-MIB::hrStorageDescr.13 = STRING: /mnt/sda3
    HOST-RESOURCES-MIB::hrStorageDescr.14 = STRING: /mnt/sdb3
    HOST-RESOURCES-MIB::hrStorageDescr.15 = STRING: /mnt/sda5
    HOST-RESOURCES-MIB::hrStorageDescr.16 = STRING: /mnt/sdb5

=> notice that the index are still preserved, and /mnt/sda2 remains at the same position 11

Comment 1 Jan Safranek 2010-05-24 11:43:03 UTC
There is finally working re-implementation upstream, see:
agent/mibgroup/hardware/fsys/*
agent/mibgroup/host/hrh_filesys.*
agent/mibgroup/host/hrh_storage.*
include/net-snmp/agent/hardware/fsys.h

(too many SVN revisions to count)

Comment 2 RHEL Product and Program Management 2010-05-24 11:46:04 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux major release.  Product Management has requested further
review of this request by Red Hat Engineering, for potential inclusion in a Red
Hat Enterprise Linux Major release.  This request is not yet committed for
inclusion.

Comment 10 releng-rhel@redhat.com 2010-11-10 21:12:10 UTC
Red Hat Enterprise Linux 6.0 is now available and should resolve
the problem described in this bug report. This report is therefore being closed
with a resolution of CURRENTRELEASE. You may reopen this bug report if the
solution does not work for you.


Note You need to log in before you can comment on or make changes to this bug.