[Nagiosplug-devel] [ nagiosplug-Bugs-837535 ] check_procs - still counts itself with -a

SourceForge.net noreply at sourceforge.net
Fri Nov 7 07:45:26 CET 2003


Bugs item #837535, was opened at 2003-11-06 15:04
Message generated for change (Comment added) made by bwhaley
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=837535&group_id=29880

Category: Parsing problem
Group: CVS
Status: Open
Resolution: None
Priority: 5
Submitted By: Ben Whaley (bwhaley)
Assigned to: Ton Voon (tonvoon)
Summary: check_procs - still counts itself with -a

Initial Comment:
This is a continuation of the bug 
[ 820125 ] check_procs arg-array check matches itself @ sol8

The CVS fix for this problem was:

/* Ignore self */
if (strcmp (procprog, progname) == 0) {
continue;
}

However, this is comparing progname to procprog. procprog will be 
whatever the program was called as (i.e. /tmp/nagios-plugins-1.3.
1/plugins/check_proc, /usr/local/nagios/libexec/check_proc, 
whatever) while progname will _always_ be simply check_proc. To fix 
this, I did the following:


/* Changed this to "char *progname = "" *; */
const char *progname = "check_procs";
const char *revision = "$Revision: 1.22 $";
const char *copyright = "2000-2003";
const char *email = "nagiosplug-devel at lists.sourceforge.net";
....

in main():

int result = STATE_UNKNOWN;

/* Added this */
progname = argv[0];

setlocale (LC_ALL, "");
....


Also, is there something going on with the version numbers? With 
the 1.3.1 release of nagios-plugins, check_procs --version says 1.
9.2.1. The CVS version, however, is 1.22. 


Thanks,
Ben


----------------------------------------------------------------------

>Comment By: Ben Whaley (bwhaley)
Date: 2003-11-07 08:44

Message:
Logged In: YES 
user_id=277968

I think I've made a mistake..

I built 1.3.1 and ran into the problem. I then downloaded the CVS 
version, ran into some configure problems, and in all the confusion 
I think I ended up using the check_procs from 1.3.1. Please accept 
my apologies. I am having problems building from CVS but I'm 
sure you are correct. Thank you for the (very) timely response.

Keep up the good work.

Regards,
Ben


----------------------------------------------------------------------

Comment By: Ton Voon (tonvoon)
Date: 2003-11-07 01:53

Message:
Logged In: YES 
user_id=664364

Ben,

Thanks for the report. Easy question first: version 1.22 is 
CVS version, 1.9.2.1 is the branch for 1.3.1 fixes.

For the main issue, I can't see a problem. Trying v1.22 on a 
Solairis 8 box (compiled on a Solaris 2.6) seems okay:

$ ./check_procs -v -v -v -c 1: -a inetd
CMD: /usr/bin/ps -Ao 's uid ppid vsz rss pcpu comm args'
0 0 0 0 0 0.00 T sched sched
0 0 824 272 0 0.10 S init /etc/init -
[snip]
0 0 2672 1936 1 0.00 S vold /usr/sbin/vold
0 0 2536 2040 1 0.00 S inetd /usr/sbin/inetd -s -t
1 0 3632 1448 1 0.00 S keyserv /usr/sbin/keyserv
1 0 3568 2992 1 0.00 S nis_cachemgr /usr/sbin/nis_cachemgr
[snip]
1 1000 172472 32520 1 0.00 S oracleGTXFRST1 
oracleGTXFRST1 (LOCAL=NO)
1 10301 1688 1128 17376 0.10 S 
check_procs ./check_procs -v -v -v -c 1: -a inetd
1 1000 134768 24624 1 0.00 S oracleSTOFRST1 
oracleSTOFRST1 (LOCAL=NO)
[snip]
PROCS OK: 1 process with args 'inetd'

The number in the first column is the count. As you can see, 
it is counting the process /usr/sbin/inetd, but has ignored the 
check_procs.

I take your point re: sometimes procprog has a full path 
returned. There is a bit of code that removes the path:

/* Some ps return full pathname for command. This removes 
path */
temp_string = strtok ((char *)procprog, "/");
while (temp_string) {
  strcpy(procprog, temp_string);
  temp_string = strtok (NULL, "/");
}


What command are you running to cause the problem?

Ton

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=837535&group_id=29880




More information about the Devel mailing list