Opened 14 years ago

Closed 14 years ago

#28801 closed defect (fixed)

nagios-plugins 1.4.15 check_procs broken, fixed on Sourceforge

Reported by: sonikbuddha@… Owned by: markd@…
Priority: Normal Milestone:
Component: ports Version: 1.9.2
Keywords: Cc:
Port: nagios-plugins

Description

The 1.4.15 version of nagios-plugins contains a broken check_procs due to a wrong ps command, listed below. I've built from the version on Sourceforge (frustratingly with the same release number) and the bug is fixed. Please upgrade to the version on Sourceforge.

http://sourceforge.net/projects/nagiosplug/files/nagiosplug/

Problem: The macports released version of 1.4.15 containing check_procs runs this ps command:

CMD: /bin/ps -axwo 'stat uid pid ppid vsz rss pcpu etime comm args'

The 'comm' argument does not present the command without the path, causing all command searches (check_procs -C <command>) to fail. In this release this plug-in will never process command searches properly.

The fixed version, on Sourceforge now, runs this command:

CMD: /bin/ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'

The 'ucomm' properly presents the command without the path and allows the plug-in to properly process a '-C'. I'm presenting this as a priority fix as a) its simply a package upgrade, not even a version change b) as is, this monitoring plug-in presents incorrect information.

For those seeing a temporary work around, the nagios-plugins source package on Sourceforge builds natively on at least Snow Leopard. OR run check_procs -a <command>, which has similar functionality.

Change History (14)

comment:1 Changed 14 years ago by sonikbuddha@…

Cc: sonikbuddha@… added

Cc Me!

comment:2 Changed 14 years ago by jmroot (Joshua Root)

Cc: sonikbuddha@… removed
Owner: changed from macports-tickets@… to markd@…
Type: updatedefect

Please remember to cc the maintainer. You do not need to be in cc when you are the reporter.

comment:3 Changed 14 years ago by markd@…

We don't use snapshots in macports normally. Can you do a diff of the check_procs.c between the released tar file and the git version and submit it? Instructions for making patches are in the guide.

comment:4 Changed 14 years ago by markd@…

I found the patch from the git repository for check_procs.c and applied it in r76989. Please test and report if it fixes it.

comment:5 Changed 14 years ago by sonikbuddha@…

I've upgraded to 1.4.15_2 and I'm still getting the broken ps command.

check_procs -C bash -vvv CMD: /bin/ps -axwo 'stat uid pid ppid vsz rss pcpu etime comm args'

comment:6 Changed 14 years ago by markd@…

Well I can't fix it if you can't tell me what fixed it for you.

comment:7 Changed 14 years ago by sonikbuddha@…

When I compiled from the source available on Sourceforge's download site it worked for me; I have not tried the source in the nagios-plugin git repository. http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/

Could your experience suggest the problem is upstream?

comment:8 Changed 14 years ago by markd@…

Oh I'm sorry, I understand now. I just realized the problem must be in the configure switches. Do a 'port ed nagios-plugins' (if your EDITOR variable is set) and you'll see these options. Tell me what mods need to be made.

--with-ps-command="/bin/ps -axwo 'stat uid pid ppid vsz --with-ps-format="%s %d %d %d %d %d %f %s %s %n" \ --with-ps-cols=10 \ --with-ps-varlist="procstat,&procuid,&procpid,&procppid,

comment:9 Changed 14 years ago by sonikbuddha@…

In my configure, I passed no arguments. Its interesting that the source package that you've pulled does not have the same defaults. I spelunked a bit through what I had and found this. Please be patient, I rarely dig into the build process or have troubleshoot issues beyond passing configure arguments.

From my local build that I made from the Sourceforge package, my config.log lists | #define PS_VARLIST procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos | #define PS_COMMAND "/bin/ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'" | #define PS_FORMAT "%s %d %d %d %d %d %f %s %n" | #define PS_COLS 9

And the config.h: /* Number of columns in ps command */ #define PS_COLS 9

/* Verbatim command to execute for ps in check_procs */ #define PS_COMMAND "/bin/ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"

/* Format string for scanning ps output in check_procs */ #define PS_FORMAT "%s %d %d %d %d %d %f %s %n"

/* Whether the ps utility uses the "procetime" field */ /* #undef PS_USES_PROCETIME */

/* Variable list for sscanf of 'ps' output */ #define PS_VARLIST procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos

Taking your advice, based on this, I changed

--with-ps-command="/bin/ps -axwo 'stat uid pid ppid vsz rss pcpu etime comm args'" \ --with-ps-format="%s %d %d %d %d %d %f %s %s %n" \ --with-ps-cols=10 \ --with-ps-varlist="procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos"

to

--with-ps-command="/bin/ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'" \ --with-ps-format="%s %d %d %d %d %d %f %s %n" \ --with-ps-cols=9 \ --with-ps-varlist="procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos"

And rebuilt.

The result worked: check_procs -C bash -vvv CMD: /bin/ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' ... PROCS OK: 1 process with command name 'bash'

Just because I was worried that there was no configure option for proctime (which I removed from the ps args list), I compared my config.h to the macports config.h I just generated and the lines match. I can share the config.log/config.h/Makefile, if necessary.

I hope this helps.

comment:10 Changed 14 years ago by sonikbuddha@…

Ah, missed the wiki formatting. More readable:

From my local build that I made from the Sourceforge package, my config.log lists

| #define PS_VARLIST procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos
| #define PS_COMMAND "/bin/ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
| #define PS_FORMAT "%s %d %d %d %d %d %f %s %n"
| #define PS_COLS 9

And the config.h:

/* Number of columns in ps command */
#define PS_COLS 9

/* Verbatim command to execute for ps in check_procs */
#define PS_COMMAND "/bin/ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"

/* Format string for scanning ps output in check_procs */
#define PS_FORMAT "%s %d %d %d %d %d %f %s %n"

/* Whether the ps utility uses the "procetime" field */
/* #undef PS_USES_PROCETIME */

/* Variable list for sscanf of 'ps' output */
#define PS_VARLIST procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos

Taking your advice, based on this, I changed

--with-ps-command="/bin/ps -axwo 'stat uid pid ppid vsz rss pcpu etime comm args'" \
--with-ps-format="%s %d %d %d %d %d %f %s %s %n" \
--with-ps-cols=10 \
--with-ps-varlist="procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos" 

to

--with-ps-command="/bin/ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'" \
--with-ps-format="%s %d %d %d %d %d %f %s %n" \
--with-ps-cols=9 \
--with-ps-varlist="procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos"

And rebuilt.

The result worked:

check_procs -C bash -vvv
CMD: /bin/ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'
...
PROCS OK: 1 process with command name 'bash'

The rest you can gather from above (next time I'll preview)

comment:11 Changed 14 years ago by markd@…

Okay, I made the changes. Thank you very much @sonikbuddha.

You know, I originally did not specify any --with-ps config switches, and someone made a ticket and told me to make them as they were. This raises the question: should the --with-ps- switches be specified at all, or should they be omitted and just let the defaults be used? What do you think would be best?

comment:12 Changed 14 years ago by markd@…

Changed in r77000.

comment:13 Changed 14 years ago by sonikbuddha@…

Cleaned and upgraded to 1.4.15_3, tested, and worked!

check_procs -C bash -vv
CMD: /bin/ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'
Matched: uid=1043 vsz=2435548 rss=1076 pid=47905 ppid=47899 pcpu=0.00 stat=Ss etime= prog=bash args=-bash
Matched: uid=1043 vsz=2435548 rss=1140 pid=35774 ppid=35773 pcpu=0.00 stat=S etime= prog=bash args=bash
Matched: uid=1043 vsz=2435548 rss=1128 pid=36368 ppid=36367 pcpu=0.00 stat=S+ etime= prog=bash args=bash
Matched: uid=1043 vsz=2435548 rss=1140 pid=36417 ppid=36416 pcpu=0.00 stat=S+ etime= prog=bash args=bash
PROCS OK: 4 processes with command name 'bash'

If the defaults are the same in the source package you have and the package I downloaded from Sourceforge I'd go with those since they, well, work. That is, based upon this experience. I can't speak to the reasoning behind the prior ticket.

Thanks for your quick responses!

comment:14 Changed 14 years ago by markd@…

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.