[Nagiosplug-checkins] nagiosplug/plugins check_nagios.c,1.25,1.26 check_procs.c,1.43,1.44
M. Sean Finney
seanius at users.sourceforge.net
Tue May 24 17:44:55 CEST 2005
Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30401/plugins
Modified Files:
check_nagios.c check_procs.c
Log Message:
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
Index: check_nagios.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_nagios.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- check_nagios.c 25 Dec 2004 23:17:44 -0000 1.25
+++ check_nagios.c 25 May 2005 00:43:20 -0000 1.26
@@ -49,6 +49,7 @@
char *temp_ptr;
FILE *fp;
int procuid = 0;
+ int procpid = 0;
int procppid = 0;
int procvsz = 0;
int procrss = 0;
Index: check_procs.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_procs.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- check_procs.c 30 Dec 2004 00:41:39 -0000 1.43
+++ check_procs.c 25 May 2005 00:43:20 -0000 1.44
@@ -85,7 +85,9 @@
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 @@
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 @@
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 @@
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 @@
(minutes * 60) +
seconds;
- if (verbose >= 3) {
- printf("seconds: %d\n", total);
- }
return total;
}
More information about the Commits
mailing list