Menu

#560 Net-SNMP 5.2 Linux/LVM Patch

closed
nobody
None
1
2012-11-08
2005-04-18
Anonymous
No

The following one-liner add's support for LVM on Linux.

Discussion

  • Nobody/Anonymous

     
  • Dave Shield

    Dave Shield - 2005-04-29

    Logged In: YES
    user_id=88893

    Thanks for the patch, but it doesn't feel quite right.
    The two patterns are meant to specify individual
    characters or integer values (not strings),
    and the value pairs specify the appropriate ranges
    for these. Specifying a range of '0' .. '0' seems unlikely.
    Plus the second pattern string isn't even valid C syntax.

    What are the ranges of valid /dev/mapper/%s-%s
    style devices? And how does LVM indicate a
    "whole disk"?

     
  • Nobody/Anonymous

    Logged In: NO

    I didn't think it was a -proper- patch =) My C leaves alot
    to be desired, but it appears to work reliably here, so I
    thought I would pass it along.

    The format of /dev/mapper is <volumegroup>-<logicalvolname> </logicalvolname></volumegroup>

    Eg.

    /dev/mapper/myvg-home
    /dev/mapper/othervg-var

    A _whole_ disk is represented as a physical volume in LVM.
    And a volume group can be made up of any number of pv's. You
    carve logical volumes from the vg's.

    I didn't specify a any numerical ranges (ie, 0 - 0) because
    lvm doesn't use the same /dev format as say /dev/hda[0-9]

    Any pointers on improving the patch are appreciated =)

     
  • Radek

    Radek - 2005-05-10

    Logged In: YES
    user_id=1122867

    Maybe it would be much nicer to read /proc/partitions - this
    should add LVM support for Linux, but also will cover LVM2
    partitions, EVMS etc.

     
  • Radek

    Radek - 2005-05-10

    Logged In: YES
    user_id=1122867

    Further investigation - it would be at least nice to see all
    devmapper partitions, so I've tried to create my own patch

    @@ -172,6 +172,7 @@
    Add_HR_Disk_entry("/dev/sd%c%d", -1, -1, 'a', 'p',
    "/dev/sd%c", 1, 15);
    Add_HR_Disk_entry("/dev/md%d", -1, -1, 0, 3,
    "/dev/md%d", 0, 0);
    Add_HR_Disk_entry("/dev/fd%d", -1, -1, 0, 1,
    "/dev/fd%d", 0, 0);
    + Add_HR_Disk_entry("/dev/dm-%d", -1, -1, 0, 15,
    "/dev/dm-%d", 0, 15);
    #elif defined(hpux)
    #if defined(hpux10) || defined(hpux11)
    Add_HR_Disk_entry("/dev/rdsk/c%dt%xd%d", 0, 1, 0, 15,

    but it doesn't work :( Can you tell me the exact meaning of
    all values in the function and why is this not working. The
    format is based on the output of `blkid` which on my systems
    lists partions as

    /dev/hda1:
    /dev/sda1:
    /dev/sda5:
    /dev/sda6:
    /dev/sda7:
    /dev/sda8:
    /dev/sda9:
    /dev/dm-0:
    /dev/dm-1:
    /dev/dm-2:

     
  • Dave Shield

    Dave Shield - 2005-05-10

    Logged In: YES
    user_id=88893

    The first pattern matches disc partitions, the second pattern
    (the sixth parameter) matches whole discs.

    The other parameters should be viewed as range pairs.
    The second pair (parameters 4 & 5) are the list of discs
    and are inserted into both patterns.
    The third pair (parameters 7 & 8) are the partitions within
    a disc, and are inserted into the first pattern only.

    You can ignore the first pair (parameters 2 & 3).
    Any pair that's not used, should contain -1 or 0 (twice).

    In this case, try

    Add_HR_Disk_entry("/dev/dm-%d", -1, -1, 0, 15,
    "/dev/dm-%d", 0, 0);
    or
    Add_HR_Disk_entry("/dev/dm-%d", -1, -1, 0, 15,
    "/dev/dm-%d", -1, -1);

     
  • Radek

    Radek - 2005-05-11

    Logged In: YES
    user_id=1122867

    Doesn't work for me though. The dm partitions are still not
    listed :(

     
  • Robert Story

    Robert Story - 2005-06-02

    Logged In: YES
    user_id=76148

    drop priority, move to pending due to lack of properly
    functioning patch.

     
  • Radek

    Radek - 2005-11-15

    Logged In: YES
    user_id=1122867

    snmpd daemon reports

    trace: Add_HR_Disk_entry(): host/hr_disk.c, 619:
    host/hr_disk: WARNING! Add_HR_Disk_entry '/dev/dm-%d'
    incomplete, 0 created

    so I've changed the line to
    Add_HR_Disk_entry("/dev/dm-%d", -1, -1, 0, 0, "/dev/dm-%d",
    1, 15);

    now I get

    trace: Add_HR_Disk_entry(): host/hr_disk.c, 624:
    host/hr_disk: Add_HR_Disk_entry '/dev/dm-%d' completed, 1
    created

    which seems to be fine, but no partitions are reported. Why?

     
  • SourceForge Robot

    Logged In: YES
    user_id=1312539

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 180 days (the time period specified by
    the administrator of this Tracker).

     
  • Nobody/Anonymous

    Logged In: NO

    from freenode@#lvm: < asalor> /dev/dm-* are internal kernel names, use /dev/mapper/* only (vgscan creates nodes only in /dev/mapper + symlinks)

    so net-snmp needs to be extended to support more complicated patterns like /dev/mapper/xx-yyy

     
  • arekm

    arekm - 2007-12-12

    Logged In: YES
    user_id=139606
    Originator: NO

    Here is my approach to the problem. According to LVM devs only devices in /dev/ are "fine" for use. /dev/dm-X are internal kernel names exposed sometimes by udev rules that create such devices. LVM2 tools create only devices in /dev/mapper/.

    So we have /dev/mapper/[0-9a-zA-Z+_\.-]+-[0-9a-zA-Z+_\.-]+ as devices.

    My approach is do opendir(/dev/mapper/), look for such devices and add these with full name.

    I use disk_device_first == disk_device_last as indication that user want's full name without %d or %c expansions (this case was never supported earlier due to lodev < last_dev condition in for() loop so should be safe).

    HRD_type_index for lvm2 looks to be "4" in my testing.

    HRD_info.model is only 40 bytes so it's very short - that why I'm stripping "/dev/mapper/" there.

    Malloced LVM LV names are never freed - well, don't see other way unless there is some function called at "deinitialisation" of the thing (opposite to init_hr_disk) - don't see such one.

    Example output of snmpwalk:
    HOST-RESOURCES-MIB::hrDeviceIndex.1600 = INTEGER: 1600
    HOST-RESOURCES-MIB::hrDeviceType.1600 = OID: HOST-RESOURCES-TYPES::hrDeviceDiskStorage
    HOST-RESOURCES-MIB::hrDeviceDescr.1600 = STRING: LVM volume (vg_sys-lv_home)
    HOST-RESOURCES-MIB::hrDeviceID.1600 = OID: SNMPv2-SMI::zeroDotZero
    HOST-RESOURCES-MIB::hrDiskStorageAccess.1600 = INTEGER: readWrite(1)
    HOST-RESOURCES-MIB::hrDiskStorageMedia.1600 = INTEGER: unknown(2)
    HOST-RESOURCES-MIB::hrDiskStorageRemoveble.1600 = INTEGER: false(2)
    HOST-RESOURCES-MIB::hrDiskStorageCapacity.1600 = INTEGER: 419430400 KBytes
    HOST-RESOURCES-MIB::hrPartitionIndex.1600.1 = INTEGER: 1
    HOST-RESOURCES-MIB::hrPartitionLabel.1600.1 = STRING: "/dev/mapper/vg_sys-lv_home"
    HOST-RESOURCES-MIB::hrPartitionID.1600.1 = STRING: "0xfd00"
    HOST-RESOURCES-MIB::hrPartitionSize.1600.1 = INTEGER: 419299328 KBytes

     
  • arekm

    arekm - 2007-12-12

    Logged In: YES
    user_id=139606
    Originator: NO

    "...only devices in /dev/ are "fine" for use.". I mean "/dev/mapper/" of course. Uh, closed ticket. No way to attach a patch.

     
  • Wes Hardaker

    Wes Hardaker - 2007-12-12

    Logged In: YES
    user_id=76242
    Originator: NO

    Re-opening at request of arekm on irc to submit a patch.

     
  • arekm

    arekm - 2007-12-12

    Logged In: YES
    user_id=139606
    Originator: NO

    "...only devices in /dev/ are "fine" for use.". I mean "/dev/mapper/" of course. Uh, closed ticket. No way to attach a patch.

     
  • Wes Hardaker

    Wes Hardaker - 2007-12-12

    submitted by arekem

     
  • Wes Hardaker

    Wes Hardaker - 2007-12-12

    Logged In: YES
    user_id=76242
    Originator: NO

    File Added: net-snmp-lvm.patch

     
  • Magnus Fromreide

    Logged In: YES
    user_id=1124910
    Originator: NO

    The inverse function of init_hr_disk would e shutdown_hr_disk, I think you should use that to clean up your mallocs.

     
  • arekm

    arekm - 2007-12-13

    Logged In: YES
    user_id=139606
    Originator: NO

    [arekm@carme-pld net-snmp-5.4.1]$ grep -ri shutdown_hr_disk .
    [arekm@carme-pld net-snmp-5.4.1]$

    Don't see such one. Where do you see it?

     
  • Magnus Fromreide

    Logged In: YES
    user_id=1124910
    Originator: NO

    It does not exist yet, you have to write it.

    The point of using shutdown_<module\_name> is that the configure
    machinery will detect it and call it automatically during shutdown,
    just like it detects init_<module\_name> and calls it automatically
    during startup.</module\_name></module\_name>

    Try it - add

    void shutdown_hr_disk()
    {
    /* Do something detectable */
    }

    to hr_disk.c and rerun configure. Notice that shutdown_hr_disk get
    called during agent shutdown.

     
  • Jan Safranek

    Jan Safranek - 2008-01-30

    Logged In: YES
    user_id=1784238
    Originator: NO

    I submitted refactored version of this patch with required cleanup on shutdown, see patch #1882621: Linux LVM support II. Could you please review it?

     
  • Dave Shield

    Dave Shield - 2008-06-21

    Logged In: YES
    user_id=88893
    Originator: NO

    Superceded by patch #1882621, which has been incorporated
    into the main development code.

     

Log in to post a comment.

MongoDB Logo MongoDB