diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2003-01-31 18:40:40 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2003-01-31 18:40:40 +0000 |
commit | 89ec266178a3303e5a2c82f02a4155a34fd04b3f (patch) | |
tree | 6b892510c86bb63ab7387cb92ba9651607756f09 /plugins | |
parent | 7f323619baf41c48da52b2319e0a7c59a9125b1e (diff) | |
download | monitoring-plugins-89ec266178a3303e5a2c82f02a4155a34fd04b3f.tar.gz |
Fix for zombie processes on Solaris (Bug 677803 - Matthew Brown)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@277 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_procs.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/plugins/check_procs.c b/plugins/check_procs.c index 05318b6a..755ed860 100644 --- a/plugins/check_procs.c +++ b/plugins/check_procs.c | |||
@@ -77,6 +77,7 @@ char *prog = ""; | |||
77 | char *args = ""; | 77 | char *args = ""; |
78 | char *fmt = ""; | 78 | char *fmt = ""; |
79 | char tmp[MAX_INPUT_BUFFER]; | 79 | char tmp[MAX_INPUT_BUFFER]; |
80 | const char *zombie = "Z"; | ||
80 | 81 | ||
81 | int | 82 | int |
82 | main (int argc, char **argv) | 83 | main (int argc, char **argv) |
@@ -93,6 +94,7 @@ main (int argc, char **argv) | |||
93 | int found = 0; /* counter for number of lines returned in `ps` output */ | 94 | int found = 0; /* counter for number of lines returned in `ps` output */ |
94 | int procs = 0; /* counter for number of processes meeting filter criteria */ | 95 | int procs = 0; /* counter for number of processes meeting filter criteria */ |
95 | int pos; /* number of spaces before 'args' in `ps` output */ | 96 | int pos; /* number of spaces before 'args' in `ps` output */ |
97 | int cols; /* number of columns in ps output */ | ||
96 | 98 | ||
97 | int result = STATE_UNKNOWN; | 99 | int result = STATE_UNKNOWN; |
98 | 100 | ||
@@ -115,14 +117,18 @@ main (int argc, char **argv) | |||
115 | fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); | 117 | fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); |
116 | 118 | ||
117 | while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { | 119 | while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { |
118 | if ( | ||
119 | #ifdef USE_PS_VARS | 120 | #ifdef USE_PS_VARS |
120 | sscanf (input_buffer, PS_FORMAT, PS_VARLIST) >= 4 | 121 | cols = sscanf (input_buffer, PS_FORMAT, PS_VARLIST); |
121 | #else | 122 | #else |
122 | sscanf (input_buffer, PS_FORMAT, procstat, &procuid, &procppid, &pos, | 123 | cols = sscanf (input_buffer, PS_FORMAT, procstat, &procuid, |
123 | procprog) >= 4 | 124 | &procppid, &pos, procprog); |
124 | #endif | 125 | #endif |
125 | ) { | 126 | /* Zombie processes do not give a procprog command */ |
127 | if ( cols == 3 && strstr(procstat, zombie) ) { | ||
128 | strcpy(procprog, ""); | ||
129 | cols = 4; | ||
130 | } | ||
131 | if ( cols >= 4 ) { | ||
126 | found++; | 132 | found++; |
127 | resultsum = 0; | 133 | resultsum = 0; |
128 | asprintf (&procargs, "%s", input_buffer + pos); | 134 | asprintf (&procargs, "%s", input_buffer + pos); |
@@ -147,6 +153,10 @@ main (int argc, char **argv) | |||
147 | #endif | 153 | #endif |
148 | if (options == resultsum) | 154 | if (options == resultsum) |
149 | procs++; | 155 | procs++; |
156 | } | ||
157 | /* This should not happen */ | ||
158 | else if (verbose) { | ||
159 | printf("Not parseable: %s", input_buffer); | ||
150 | } | 160 | } |
151 | } | 161 | } |
152 | 162 | ||