aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_procs.c
diff options
context:
space:
mode:
authorGravatar M. Sean Finney <seanius@users.sourceforge.net> 2005-05-25 00:43:20 +0000
committerGravatar M. Sean Finney <seanius@users.sourceforge.net> 2005-05-25 00:43:20 +0000
commit4e19425ce697ce17257b0db904a656e3c8557911 (patch)
tree493a0d1ee9441a1c57a46cde4dab504b295f20e4 /plugins/check_procs.c
parent8134ec30d1fdf9b9921885154c900d2a88707676 (diff)
downloadmonitoring-plugins-4e19425ce697ce17257b0db904a656e3c8557911.tar.gz
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
Diffstat (limited to 'plugins/check_procs.c')
-rw-r--r--plugins/check_procs.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index 15ec76f5..671190ca 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;
}