Menu

#1168 Issues with hrSWRunName and Parameters on AIX

closed
None
5
2012-11-09
2011-09-02
blentz
No

In 5.4.2.1, we had a problem where the HOST-RESOURCES-MIB::hrSWRunParameters entries were always empty. hrSWRunName works fine.

On 5.7.1.pre2, hrSWRunName is completely empty (!) and hrSWRunParameters contains the process basenames with the first character truncated.

I will provide query samples of both versions.

Please help to fix this.

Discussion

  • blentz

    blentz - 2011-09-02

    Issue on 5.4.2.1:

    $ /opt/local/net-snmp/sbin/snmpd -v

    NET-SNMP version: 5.4.2.1
    Web: http://www.net-snmp.org/
    Email: net-snmp-coders@lists.sourceforge.net

    $ ps -ef | grep snmpd
    root 9437364 3276946 0 Nov 08 - 104:46 /opt/local/net-snmp/sbin/snmpd -Lf /dev/null -p /opt/local/net-snmp/var/run/snmpd.pid -a -f 0.0.0.0:16161
    $ /opt/local/net-snmp/bin/snmpwalk -v 2c -c aix2011 localhost:16161 HOST-RESOURCES-MIB::hrSWRunName | grep snmpd
    HOST-RESOURCES-MIB::hrSWRunName.9437364 = STRING: "snmpd"
    $ /opt/local/net-snmp/bin/snmpwalk -v 2c -c aix2011 localhost:16161 HOST-RESOURCES-MIB::hrSWRunName.9437364
    HOST-RESOURCES-MIB::hrSWRunName.9437364 = STRING: "snmpd"
    $ /opt/local/net-snmp/bin/snmpwalk -v 2c -c aix2011 localhost:16161 HOST-RESOURCES-MIB::hrSWRunParameters.9437364
    HOST-RESOURCES-MIB::hrSWRunParameters.9437364 = ""

     
  • blentz

    blentz - 2011-09-02

    Issue on 5.7.1.pre2:

    $ /opt/local/net-snmp/sbin/snmpd -v

    NET-SNMP version: 5.7.1.pre2
    Web: http://www.net-snmp.org/
    Email: net-snmp-coders@lists.sourceforge.net

    $ ps -ef | grep [s]nmpd
    root 680156 159858 0 14:08:01 - 0:00 /opt/local/net-snmp/sbin/snmpd -Lf /dev/null -p /opt/local/net-snmp/var/run/snmpd.pid -a -f 0.0.0.0:16161
    $ /opt/local/net-snmp/bin/snmpwalk -v 2c -c aix2011 localhost:16161 HOST-RESOURCES-MIB::hrSWRunName | grep snmpd
    $ /opt/local/net-snmp/bin/snmpwalk -v 2c -c aix2011 localhost:16161 HOST-RESOURCES-MIB::hrSWRunParameters | grep .nmpd
    HOST-RESOURCES-MIB::hrSWRunParameters.680156 = STRING: "nmpd"
    $ /opt/local/net-snmp/bin/snmpwalk -v 2c -c aix2011 localhost:16161 HOST-RESOURCES-MIB::hrSWRunName.680156
    HOST-RESOURCES-MIB::hrSWRunName.680156 = ""
    $ /opt/local/net-snmp/bin/snmpwalk -v 2c -c aix2011 localhost:16161 HOST-RESOURCES-MIB::hrSWRunParameters.680156
    HOST-RESOURCES-MIB::hrSWRunParameters.680156 = STRING: "nmpd"

     
  • Thomas Anders

    Thomas Anders - 2011-09-03

    The relevant code for AIX is in agent/mibgroup/host/data_access/swrun_procinfo.c which is a rewrite compared to 5.4.x. Please let us know what you find out.

     
  • blentz

    blentz - 2011-09-04

    Thanks. I'm a sysadmin by trade and I'm not a C programmer. I took a course in college but I'm afraid I'm in way over my head here.

    I used to know how to do this stuff, but whatever **p (char *) stuff is not covered by any of the texts I know of and I know absolutely no one who can help me with writing C code.

    I have net-snmp 5.4.2.1 deployed to about 250 AIX systems and I've been living with this limitation for about 2 years and I'm dying to get it resolved. So much so, that I've been hacking away at the code for about 12 hours now but I'm starting to get highly frustrated. I've looked at the source code for lsof, procps, and some processtable Perl modules (which support AIX) for clues but nothing seems to work.

    The argv0 equivalent has the full path which we should be able to split for RunPath and RunName. argv1 is also accessible, but what I can't figure out is how to access argv2 - argvN, smush them together, and put them in RunParameters.

    I got a code sample working with normal arrays but this pointer crap is not something I'm wrapping my head around.

    The function getargs(&proc_table[i], sizeof(struct procsinfo), src, sizeof(src)); will place the /path/to/process/basename -arg1 -arg2 -arg3 data into "src" as what IBM says is:

    Specifies the address of an array of characters to be filled with a series of strings representing the parameters that are needed. An extra NULL character marks the end of the list. This array must be allocated by the caller.

    See http://publib.boulder.ibm.com/infocenter/aix/v6r1/topic/com.ibm.aix.basetechref/doc/basetrf1/getargs.htm for more information.

    This also gives some clues:

    http://groups.google.com/group/comp.unix.aix/browse_thread/thread/c3faa9a4d291eb04/f9aeb4cfd38961e2?fwc=1

    The Proc::ProcessTable perl CPAN module also has this source file, specific for AIX, that has some clues:

    http://cpansearch.perl.org/src/DURIST/Proc-ProcessTable-0.45/os/aix_getprocs.c

    In terms of joining argv2 - argvN, he goes through the array and converts all the nulls and spaces to effectively concatenate the whole thing together. I tried this and couldn't get it to work.

    I've read through my old college textbook to try and get back up to speed on this stuff. I can't see to cope with whatever pointer array crap is coming out in this variable. But from what I can tell, it *should* be a much better choice to producing the correct strings for RunName, RunPath, and RunParameters that are - right now - all totally broken in 5.7.1.pre2 for the AIX platform.

    If I hack some debugging fprintf into it:

        /\*
         \*  Split pi\_comm into two:
         \*     argv\[0\]   is hrSWRunPath
         \*     argv\[1..\] is hrSWRunParameters
         \*/
    

    fprintf(stderr, "proc_table[i].pi_comm: %s\n", proc_table[i].pi_comm);

    char src[8192][8192];
    memset(src, 0, 8192);
    int x = 0;

    getargs(&proc_table[i], sizeof(struct procsinfo), src, sizeof(src));
    fprintf(stderr, "src: %s\n", src);
    fprintf(stderr, "&src: %.*s\n",(int)200,&src[strlen(src)+1]);

        for \( cp1 = proc\_table\[i\].pi\_comm; ' ' == \*cp1; cp1++ \)
            ;
    

    And I rerun the daemon and walk the tree:

    proc_table[i].pi_comm: snmpwalk
    src: /opt/local/net-snmp/bin/snmpwalk
    &src:

    but still nothing I can give to RunParameters.

    I had at least the first argument printing yesterday, not sure what happened :-(

    Can you help???

     
  • blentz

    blentz - 2011-09-04

    Hmmm...

    Given:

    char src[8192];
    getargs(&proc_table[i], sizeof(struct procsinfo), src, sizeof(src));
    src[8192-1] = '\0';
    fprintf(stderr, "src: %s\n", src);
    fprintf(stderr, "&src: %.*s\n",(int)200,&src[strlen(src)+1]);

    I can return:

    proc_table[i].pi_comm: snmpwalk
    src: /opt/local/net-snmp/bin/snmpwalk
    &src: -v

    As you can see, one parameter out of several (where's the version? heh) is returned.

     
  • blentz

    blentz - 2011-09-05

    I managed to build a small program on AIX that will pull the full argument list from the AIX process table and just print it out.

    I will attempt to smush this into Net-SNMP and produce a patch against the ./agent/mibgroup/host/data_access/swrun_procinfo.c when I get some time, hopefully I can manage this.

    The attached code compiles on AIX using gcc -Wall -pedantic.

     
  • blentz

    blentz - 2011-09-05
     
  • blentz

    blentz - 2011-09-05
     
  • blentz

    blentz - 2011-09-05

    I've attached a preliminary patch that appears to test well on my system. Here's a sample:

    [blentz@optaix53ts /home/blentz]$ ps -ef | grep [s]nmpd
    root 598202 159858 0 17:23:57 - 0:00 /opt/local/net-snmp/sbin/snmpd -Lf /dev/null -p /opt/local/net-snmp/var/run/snmpd.pid -a -f 0.0.0.0:16161
    [blentz@optaix53ts /home/blentz]$ /opt/local/net-snmp/bin/snmpwalk -v 2c -c aix2011 localhost:16161 HOST-RESOURCES-MIB::hrSWRunName.598202
    HOST-RESOURCES-MIB::hrSWRunName.598202 = STRING: "snmpd"
    [blentz@optaix53ts /home/blentz]$ /opt/local/net-snmp/bin/snmpwalk -v 2c -c aix2011 localhost:16161 HOST-RESOURCES-MIB::hrSWRunPath.598202
    HOST-RESOURCES-MIB::hrSWRunPath.598202 = STRING: "/opt/local/net-snmp/sbin"
    [blentz@optaix53ts /home/blentz]$ /opt/local/net-snmp/bin/snmpwalk -v 2c -c aix2011 localhost:16161 HOST-RESOURCES-MIB::hrSWRunParameters.598202
    HOST-RESOURCES-MIB::hrSWRunParameters.598202 = STRING: "-Lf /dev/null -p /opt/local/net-snmp/var/run/snmpd.pid -a -f 0.0.0.0:16161"

    I realize there are probably flaws with it. Please review.

     
  • Thomas Anders

    Thomas Anders - 2011-09-05

    moving to patches

     
  • Wes Hardaker

    Wes Hardaker - 2012-07-31

    Thanks for the patch! It has been applied to the 5.5.x and later code branches and the main development tree, and will appear in future releases of the Net-SNMP package.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.