From: SourceForge.net <no...@so...> - 2011-09-05 10:09:42
|
Bugs item #3403433, was opened at 2011-09-02 13:17 Message generated for change (Comment added) made by blentz You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112694&aid=3403433&group_id=12694 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: aix Status: Open Resolution: None Priority: 5 Private: No Submitted By: blentz (blentz) Assigned to: Nobody/Anonymous (nobody) Summary: Issues with hrSWRunName and Parameters on AIX Initial Comment: 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. ---------------------------------------------------------------------- >Comment By: blentz (blentz) Date: 2011-09-05 05:09 Message: 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. ---------------------------------------------------------------------- Comment By: blentz (blentz) Date: 2011-09-03 19:39 Message: 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. ---------------------------------------------------------------------- Comment By: blentz (blentz) Date: 2011-09-03 19:29 Message: 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??? ---------------------------------------------------------------------- Comment By: Thomas Anders (tanders) Date: 2011-09-03 16:14 Message: 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. ---------------------------------------------------------------------- Comment By: blentz (blentz) Date: 2011-09-02 13:26 Message: 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...@li... $ 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" ---------------------------------------------------------------------- Comment By: blentz (blentz) Date: 2011-09-02 13:22 Message: 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...@li... $ 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 = "" ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112694&aid=3403433&group_id=12694 |