From 4e19425ce697ce17257b0db904a656e3c8557911 Mon Sep 17 00:00:00 2001 From: "M. Sean Finney" Date: Wed, 25 May 2005 00:43:20 +0000 Subject: fixes for check_procs: - added support for printing the pid in all the ps outputs - don't use the proc name to ignore self, use the pid vs getpid(). - initialize procetime to null string otherwise -vvv can have funny results git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1177 f882894a-f735-0410-b71e-b25c423dba1c diff --git a/configure.in b/configure.in index 256fb29..df516c5 100644 --- a/configure.in +++ b/configure.in @@ -593,58 +593,69 @@ dnl #### Process table test AC_PATH_PROG(PATH_TO_PS,ps) AC_MSG_CHECKING(for ps syntax) +dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo. +dnl so test for this first... +if ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ + egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null +then + ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" + ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'" + ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" + ac_cv_ps_cols=9 + 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 | \ - egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PPID +COMMAND"] > /dev/null +elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ + egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null 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_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" + ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'" + ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" + ac_cv_ps_cols=9 AC_MSG_RESULT([$ac_cv_ps_command]) dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. dnl Limitation: Only first 16 chars returned for ucomm field dnl Must come before ps -weo -elif ps -axwo 'stat uid ppid vsz rss pcpu ucomm command' 2>/dev/null | \ - egrep -i ["^ *STAT +UID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null +elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \ + egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null 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 ucomm command'" - ac_cv_ps_format="%s %d %d %d %d %f %s %n" - ac_cv_ps_cols=8 + ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" + ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'" + ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" + ac_cv_ps_cols=9 AC_MSG_RESULT([$ac_cv_ps_command]) dnl STAT UCOMM VSZ RSS USER UID PPID COMMAND -elif ps -weo 'stat comm vsz rss user uid ppid etime args' 2>/dev/null | \ - egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null +elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \ + egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null then - ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]" - ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid ppid vsz rss pcpu etime comm args'" - ac_cv_ps_format="%s %d %d %d %d %f %s %s %n" - ac_cv_ps_cols=9 + ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]" + ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'" + ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n" + ac_cv_ps_cols=10 AC_MSG_RESULT([$ac_cv_ps_command]) dnl FreeBSD -elif ps waxco 'state command vsz rss uid user ppid' 2>/dev/null | \ - egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PPID"] >/dev/null +elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \ + egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null then - ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" - ac_cv_ps_command="$PATH_TO_PS waxco 'state uid ppid vsz rss pcpu command command'" - ac_cv_ps_format="%s %d %d %d %d %f %s %n" - ac_cv_ps_cols=8 + ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" + ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'" + ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" + ac_cv_ps_cols=9 AC_MSG_RESULT([$ac_cv_ps_command]) dnl BSD-like mode in RH 6.1 -elif ps waxno 'state comm vsz rss uid user ppid args' 2>/dev/null | \ - egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null +elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \ + egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null then - ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" - ac_cv_ps_command="$PATH_TO_PS waxno 'state 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_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" + ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'" + ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" + ac_cv_ps_cols=9 AC_MSG_RESULT([$ac_cv_ps_command]) dnl SunOS 4.1.3: @@ -653,10 +664,10 @@ dnl Need the head -1 otherwise test will work because arguments are found elif ps -laxnwww 2>/dev/null | head -1 | \ egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null then - ac_cv_ps_varlist="[&procuid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]" + ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]" ac_cv_ps_command="$PATH_TO_PS -laxnwww" - ac_cv_ps_format="%*s %d %*s %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s" - ac_cv_ps_cols=8 + ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s" + ac_cv_ps_cols=9 AC_MSG_RESULT([$ac_cv_ps_command]) dnl Debian Linux / procps v1.2.9: @@ -666,109 +677,110 @@ dnl elif ps laxnwww 2>/dev/null | \ egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null then - ac_cv_ps_varlist="[&procuid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]" + ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]" ac_cv_ps_command="$PATH_TO_PS laxnwww" - ac_cv_ps_format="%*s %d %*s %d %*s %*s %d %d %*s %s %*s %*s %n%s" - ac_cv_ps_cols=8 + ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s" + ac_cv_ps_cols=9 AC_MSG_RESULT([$ac_cv_ps_command]) dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs) -elif ps -axo 'stat comm vsz rss user uid ppid args' 2>/dev/null | \ - egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null +elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ + egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null then - ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" - ac_cv_ps_command="$PATH_TO_PS -axo '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_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" + ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'" + ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" + ac_cv_ps_cols=9 AC_MSG_RESULT([$ac_cv_ps_command]) dnl Tru64 - needs %*[ +] in PS_FORMAT -elif ps -ao 'stat comm vsz rss user uid ppid args' 2>/dev/null | \ - egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null +elif ps -ao 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ + egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null then - ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" - ac_cv_ps_command="$PATH_TO_PS -ao '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_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" + ac_cv_ps_command="$PATH_TO_PS -ao 'stat uid pid ppid vsz rss pcpu comm args'" + ac_cv_ps_format=["%s%*[ +] %d %d %d %d %d %f %s %n"] + ac_cv_ps_cols=9 AC_MSG_RESULT([$ac_cv_ps_command]) -elif ps -eo 's comm vsz rss user uid ppid args' 2>/dev/null | \ - egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null +XXX +elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \ + egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null then - ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" - ac_cv_ps_command="$PATH_TO_PS -eo 's 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_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procrss,&procpcpu,procprog,&pos]" + ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'" + ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" + ac_cv_ps_cols=9 AC_MSG_RESULT([$ac_cv_ps_command]) dnl AIX 4.3.3 and 5.1 do not have an rss field -elif ps -eo 'stat uid ppid vsz pcpu comm args' 2>/dev/null | \ - egrep -i ["^ *S[TAUES]* +UID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null +elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \ + egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null then - ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procpcpu,procprog,&pos]" - ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid ppid vsz pcpu comm args'" - ac_cv_ps_format="%s %d %d %d %f %s %n" - ac_cv_ps_cols=7 + ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procpcpu,procprog,&pos]" + ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz 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 - with no RSS]) dnl Solaris 2.6 -elif ps -Ao 's comm vsz rss uid user ppid args' 2>/dev/null | \ - egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null +elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \ + egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null then - ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" - ac_cv_ps_command="$PATH_TO_PS -Ao 's uid ppid vsz rss pcpu comm args'" + ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procrss,&procpcpu,procprog,&pos]" + ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'" # There must be no space between the %s and %n due to a wierd problem in sscanf where # it will return %n as longer than the line length - ac_cv_ps_format="%s %d %d %d %d %f %s%n" - ac_cv_ps_cols=8 + ac_cv_ps_format="%s %d %d %d %d %d %f %s%n" + ac_cv_ps_cols=9 AC_MSG_RESULT([$ac_cv_ps_command]) -elif ps -Ao 'status comm vsz rss uid user ppid args' 2>/dev/null | \ - egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null +elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \ + egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null then - ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" - ac_cv_ps_command="$PATH_TO_PS -Ao 'status 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_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procrss,&procpcpu,procprog,&pos]" + ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'" + ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" + ac_cv_ps_cols=9 AC_MSG_RESULT([$ac_cv_ps_command]) -elif ps -Ao 'state comm vsz rss uid user ppid args' 2>/dev/null | \ - egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null +elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \ + egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null then - ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" - ac_cv_ps_command="$PATH_TO_PS -Ao 'state 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_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procrss,&procpcpu,procprog,&pos]" + ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'" + ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" + ac_cv_ps_cols=9 AC_MSG_RESULT([$ac_cv_ps_command]) dnl wonder who takes state instead of stat -elif ps -ao 'state command vsz rss user ppid args' 2>/dev/null | \ - egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null +elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \ + egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null then - ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" - ac_cv_ps_command="$PATH_TO_PS -ao 'state uid ppid vsz rss pcpu command args'" - ac_cv_ps_format="%s %d %d %d %d %f %s %n" - ac_cv_ps_cols=7 + ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procrss,&procpcpu,procprog,&pos]" + ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'" + ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" + ac_cv_ps_cols=8 AC_MSG_RESULT([$ac_cv_ps_command]) dnl IRIX 53 elif ps -el 2>/dev/null | \ egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null then - ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&pos,procprog]" + ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procrss,&pos,procprog]" ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)" - ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s" - ac_cv_ps_cols=7 + ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s" + ac_cv_ps_cols=8 AC_MSG_RESULT([$ac_cv_ps_command]) dnl IRIX 63 elif ps -el 2>/dev/null | \ egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null then - ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]" + ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&pos,procprog]" ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)" - ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s" - ac_cv_ps_cols=5 + ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s" + ac_cv_ps_cols=6 AC_MSG_RESULT([$ac_cv_ps_command]) dnl AIX 4.1: @@ -777,20 +789,20 @@ dnl 303 A 0 0 0 120 16 -- 1c07 20 24 - 0:45 elif ps -el 2>/dev/null | \ egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null then - ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]" + ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&pos,procprog]" ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)" - ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s" - ac_cv_ps_cols=5 + ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s" + ac_cv_ps_cols=6 AC_MSG_RESULT([$ac_cv_ps_command]) dnl AIX? elif ps glaxen 2>/dev/null | \ egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null then - ac_cv_ps_varlist="[&procuid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]" + ac_cv_ps_varlist="[&procuid,&procpid,&procpid,&procvsz,&procrss,procstat,&pos,procprog]" ac_cv_ps_command="$PATH_TO_PS glaxen" - ac_cv_ps_format="%*s %d %*s %d %*s %*s %d %d %*s %s %*s %*s %n%s" - ac_cv_ps_cols=7 + ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s" + ac_cv_ps_cols=8 AC_MSG_RESULT([$ac_cv_ps_command]) dnl MacOSX / Darwin @@ -798,24 +810,25 @@ dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT dnl Some truncation will happen in UCOMM column dnl STAT VSZ RSS UID PPID %CPU UCOMM COMMAND dnl Ss 52756 22496 501 1 6.9 Window Manager /System/Library/CoreServices/WindowServer -daemon -elif ps wwaxo 'state vsz rss uid ppid pcpu ucomm command' 2>/dev/null | \ +elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \ egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null then - ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid ppid pcpu ucomm command'" - ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procppid,&procpcpu,procprog,&pos]" - ac_cv_ps_format="%s %d %d %d %d %f %s %n" - ac_cv_ps_cols=7 + ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'" + ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procpid,&procpcpu,procprog,&pos]" + ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" + ac_cv_ps_cols=8 AC_MSG_RESULT([$ac_cv_ps_command]) dnl UnixWare elif ps -Al 2>/dev/null | \ egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null then - ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]" + ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&pos,procprog]" ac_cv_ps_command="$PATH_TO_PS -Al" - ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s" - ac_cv_ps_cols=7 + ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s" + ac_cv_ps_cols=8 AC_MSG_RESULT([$ac_cv_ps_command]) +XXX else AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled]) diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c index 0176983..089ff66 100644 --- a/plugins/check_nagios.c +++ b/plugins/check_nagios.c @@ -49,6 +49,7 @@ main (int argc, char **argv) char *temp_ptr; FILE *fp; int procuid = 0; + int procpid = 0; int procppid = 0; int procvsz = 0; int procrss = 0; diff --git a/plugins/check_procs.c b/plugins/check_procs.c index 15ec76f..671190c 100644 --- a/plugins/check_procs.c +++ b/plugins/check_procs.c @@ -85,7 +85,9 @@ main (int argc, char **argv) char *input_line; char *procprog; + pid_t mypid = 0; int procuid = 0; + int procpid = 0; int procppid = 0; int procvsz = 0; int procrss = 0; @@ -106,11 +108,12 @@ main (int argc, char **argv) int expected_cols = PS_COLS - 1; int warn = 0; /* number of processes in warn state */ int crit = 0; /* number of processes in crit state */ + procetime[0]='\0'; /* keep this clean because -vvv always prints it */ int i = 0; int result = STATE_UNKNOWN; - setlocale (LC_ALL, ""); + //setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); @@ -123,6 +126,9 @@ main (int argc, char **argv) if (process_arguments (argc, argv) == ERROR) usage4 (_("Could not parse arguments")); + /* get our pid */ + mypid = getpid(); + /* Set signal handling and alarm timeout */ if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) { usage4 (_("Cannot catch SIGALRM")); @@ -182,15 +188,13 @@ main (int argc, char **argv) procseconds = convert_to_seconds(procetime); if (verbose >= 3) - printf ("%d %d %d %d %d %.2f %s %s %s %s\n", + printf ("%d %d %d %d %d %d %.2f %s %s %s %s\n", procs, procuid, procvsz, procrss, - procppid, procpcpu, procstat, + procpid, procppid, procpcpu, procstat, procetime, procprog, procargs); /* Ignore self */ - if (strcmp (procprog, progname) == 0) { - continue; - } + if (mypid == procpid) continue; if ((options & STAT) && (strstr (statopts, procstat))) resultsum |= STAT; @@ -639,9 +643,6 @@ convert_to_seconds(char *etime) { (minutes * 60) + seconds; - if (verbose >= 3) { - printf("seconds: %d\n", total); - } return total; } -- cgit v0.10-9-g596f