Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 82591 - nagios-plugins has trouble with ps syntax
Summary: nagios-plugins has trouble with ps syntax
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Netmon project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-19 09:09 UTC by steveb
Modified: 2005-02-25 19:49 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
nagios-plugins-1.4.ebuild.diff (nagios-plugins-1.4.ebuild.diff,398 bytes, patch)
2005-02-19 13:13 UTC, Marcelo Goes (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description steveb 2005-02-19 09:09:24 UTC
Since I updated the plugins to 1.4, I only have trouble! I get all the time warnings. For example:

***** Nagios  *****
Notification Type: PROBLEM
Service: Total Processes
Host: xxxx
Address: xxx.xxx.xxx.xxx
State: WARNING

Date/Time: Sat Feb 19 15:57:03 CET 2005

Additional Info:

System call sent warnings to stderr



While starting manualy the check-process and using the -vv option I saw that the parameters for ps are the reason for the error:
# /usr/nagios/libexec/check_procs -w 150 -c 200 -vv
CMD: /bin/ps -axwo 'stat uid ppid vsz rss pcpu comm args'
STDERR: Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
System call sent warnings to stderr
PROCS WARNING: 138 processes
#



Hmm... looks like the file configure.in needs patching. I tried to modify a existing line to suit my needs, but failed (mainly because egrep once matches the line and once not. I don't know what is wrong with me or egrep. The same expression once works and once not. With same output! Anyway... AWK works perfectly in that case.). After I tried to do the same with AWK I was successfull. This is the patch I would like to include in the 1.4 ebuild:
diff -Naur nagios-plugins-1.4.org/configure.in nagios-plugins-1.4/configure.in
--- nagios-plugins-1.4.org/configure.in 2005-02-04 01:44:27.000000000 +0100
+++ nagios-plugins-1.4/configure.in     2005-02-19 17:44:48.349115040 +0100
@@ -586,10 +586,24 @@
 AC_PATH_PROG(PATH_TO_PS,ps)

 AC_MSG_CHECKING(for ps syntax)
+dnl For Gentoo to avoid "bad ps syntax, perhaps a bogus '-'" message
+dnl  STAT COMMAND            VSZ   RSS USER       UID  PPID COMMAND
+if ps awxo 'stat comm vsz rss user uid ppid args' 2>&1 | head --lines=1 | \
+       tr [a-z] [A-Z] | awk '{if ($1=="STAT" && ($2=="COMMAND" || \
+       $2=="UCOMMAND") && $3=="VSZ" && $4=="RSS" && $5=="USER" \
+       && $6=="UID" && $7=="PPID" && $8=="COMMAND") print "OK"}' | \
+       grep -q "^OK$"
+then
+       ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
+       ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid ppid vsz rss pcpu comm args'"
+       ac_cv_ps_format="%s %d %d %d %d %f %s %n"
+       ac_cv_ps_cols=8
+       AC_MSG_RESULT([$ac_cv_ps_command])
+
 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
 dnl Should also work for FreeBSD 5.2.1 and 5.3
 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
-if ps -axwo 'stat comm vsz rss user uid ppid args' 2>/dev/null | \
+elif ps -axwo 'stat comm vsz rss user uid ppid args' 2>/dev/null | \
        egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PPID +COMMAND"] > /dev/null
 then
        ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"



While doing my changes on a copy of the original nagios-plugins-1.4.ebuild, I realized that serval commands in configure.in are not in the ebuild as a dependency. I think the ebuild needs at least the following dependencies:
        sys-apps/grep
        sys-apps/coreutils
        sys-apps/procps

If using the patch above, then sys-apps/gawk would as well be needed for the patch to work.


cheers

SteveB


Reproducible: Always
Steps to Reproduce:
1.
2.
3.




Portage 2.0.51-r15 (hardened/x86, gcc-3.4.3, glibc-2.3.4.20040808-r1, 
2.6.11-rc4 i686) 
================================================================= 
System uname: 2.6.11-rc4 i686 AMD Athlon (TM) 
Gentoo Base System version 1.4.16 
Python:              dev-lang/python-2.3.4-r1 [2.3.4 (#1, Feb  7 2005, 
10:28:14)] 
distcc 2.16 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [enabled] 
ccache version 2.3 [enabled] 
dev-lang/python:     2.3.4-r1 
sys-devel/autoconf:  2.59-r6, 2.13 
sys-devel/automake:  1.6.3, 1.7.9-r1, 1.4_p6, 1.9.4, 1.8.5-r3, 1.5 
sys-devel/binutils:  2.15.92.0.2-r1 
sys-devel/libtool:   1.5.10-r4 
virtual/os-headers:  2.6.8.1-r2 
ACCEPT_KEYWORDS="x86" 
AUTOCLEAN="yes" 
CFLAGS="-march=athlon-tbird -Os -pipe -fforce-addr -fomit-frame-pointer 
-funroll-loops -falign-functions=4 -maccumulate-outgoing-args" 
CHOST="i686-pc-linux-gnu" 
CONFIG_PROTECT="/etc /etc/postfix /usr/kde/2/share/config /usr/kde/3/share/config /usr/share/config /var/bind /var/qmail/control /var/spool/vacation" 
CONFIG_PROTECT_MASK="/etc/gconf /etc/mail/dspam /etc/terminfo /etc/env.d" 
CXXFLAGS="-march=athlon-tbird -Os -pipe -fforce-addr -fomit-frame-pointer 
-funroll-loops -falign-functions=4 -maccumulate-outgoing-args" 
DISTDIR="/usr/portage/distfiles" 
FEATURES="autoaddcvs autoconfig buildpkg ccache distcc distlocks sandbox 
userpriv" 
GENTOO_MIRRORS="ftp://sunsite.cnlab-switch.ch/mirror/gentoo 
http://www.ibiblio.org/pub/Linux/distributions/gentoo 
http://gentoo.oregonstate.edu/" 
MAKEOPTS="-j13" 
PKGDIR="/usr/portage/packages" 
PORTAGE_TMPDIR="/var/tmp" 
PORTDIR="/usr/portage" 
PORTDIR_OVERLAY="/mnt/gentoo.overlay" 
SYNC="rsync://rsync.gentoo.org/gentoo-portage" 
USE="GAPING_SECURITY_HOLE X509 acl acpi apache2 autofs berkdb crypt curl 
dlloader erandom fam fastcgi fla freetds gd gdbm geoip gif gmp hardened icc 
icc-pgo imagemagick imap innodb j2ee java javacomm javamail jboss jce jikes jms 
jmx jpeg jta kerberos krb4 large-domain lcms ldap libwww lzw lzw-tiff maildir 
mbox mcal mmx mpeg mysql nagios-dns nagios-game nagios-ntp nagios-ping 
nagios-ssh ncurses neural nls nptl oav odbc pam pam-mysql pdflib pear-db perl 
php pic pie png python readline ruby samba sasl skey snmp spell sqlite sse ssl 
symlink tcpd tiff truetype vda vhosts wmf x86 xml xml2 yaz zlib" 
Unset:  ASFLAGS, CBUILD, CTARGET, LANG, LC_ALL, LDFLAGS
Comment 1 Marcelo Goes (RETIRED) gentoo-dev 2005-02-19 12:50:53 UTC
For other people having trouble, -vv seems to work fine with version 1.3.1-r1.
Also, I'm not sure if the dependencies you suggest are necessary, since they are already in `/usr/portage/profiles/base/packages`.
Comment 2 steveb 2005-02-19 13:01:12 UTC
Comment #1:
I know that the <1.4 release works. The patch I submitted allows you to use the 1.4 version of the plugins. Anyway... I think that this problem is probably not a show stopper for the plugins.
Comment 3 Marcelo Goes (RETIRED) gentoo-dev 2005-02-19 13:13:12 UTC
Created attachment 51611 [details, diff]
nagios-plugins-1.4.ebuild.diff

A much simpler fix to the ebuild, just a sed line...

I got the idea from
http://article.gmane.org/gmane.network.nagios.plugins.devel/2338

Worked for me, please tell if it works for you.
Comment 4 steveb 2005-02-19 14:09:05 UTC
Vanquirius: I did not run your patch. But the one line sed command is okay, from my point of view.

When I was doing my patch, I was thinking about making a generic approach because if it works okay, then we can submit it to the nagios creator. Your patch would break the portability of the nagios-plugins on other platforms.

Anyway... for the Gentoo setup your approach is shure okay.
Comment 5 Daniel Black (RETIRED) gentoo-dev 2005-02-25 19:49:43 UTC
Thanks Marcelo - patch added.