summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 683cd51..ac421e5 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -12,7 +12,7 @@ LIBS = @LIBINTL@ @LIBS@
12 12
13libexec_PROGRAMS = check_disk check_dummy check_http check_load \ 13libexec_PROGRAMS = check_disk check_dummy check_http check_load \
14 check_mrtg check_mrtgtraf check_nwstat check_overcr check_ping \ 14 check_mrtg check_mrtgtraf check_nwstat check_overcr check_ping \
15 check_procs check_real check_smtp check_ssh check_tcp check_time \ 15 check_real check_smtp check_ssh check_tcp check_time \
16 check_udp check_ups check_users negate urlize \ 16 check_udp check_ups check_users negate urlize \
17 @EXTRAS@ 17 @EXTRAS@
18 18
@@ -21,7 +21,7 @@ check_tcp_programs = check_ftp check_imap check_nntp check_pop check_udp2 \
21 21
22EXTRA_PROGRAMS = check_mysql check_radius check_pgsql check_snmp check_hpjd \ 22EXTRA_PROGRAMS = check_mysql check_radius check_pgsql check_snmp check_hpjd \
23 check_swap check_fping check_ldap check_game check_dig \ 23 check_swap check_fping check_ldap check_game check_dig \
24 check_nagios check_by_ssh check_dns check_nt check_ide-smart 24 check_nagios check_by_ssh check_dns check_nt check_ide-smart check_procs
25 25
26EXTRA_DIST = t utils.c netutils.c popen.c utils.h netutils.h popen.h common.h \ 26EXTRA_DIST = t utils.c netutils.c popen.c utils.h netutils.h popen.h common.h \
27 getaddrinfo.c getaddrinfo.h gethostbyname.c gethostbyname.h 27 getaddrinfo.c getaddrinfo.h gethostbyname.c gethostbyname.h
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index e0ee524..a868fcf 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -89,6 +89,7 @@ main (int argc, char **argv)
89 char procstat[8]; 89 char procstat[8];
90 char procprog[MAX_INPUT_BUFFER]; 90 char procprog[MAX_INPUT_BUFFER];
91 char *procargs; 91 char *procargs;
92 char *temp_string;
92 93
93 const char *zombie = "Z"; 94 const char *zombie = "Z";
94 95
@@ -97,6 +98,7 @@ main (int argc, char **argv)
97 int procs = 0; /* counter for number of processes meeting filter criteria */ 98 int procs = 0; /* counter for number of processes meeting filter criteria */
98 int pos; /* number of spaces before 'args' in `ps` output */ 99 int pos; /* number of spaces before 'args' in `ps` output */
99 int cols; /* number of columns in ps output */ 100 int cols; /* number of columns in ps output */
101 int expected_cols = PS_COLS - 1;
100 int warn = 0; /* number of processes in warn state */ 102 int warn = 0; /* number of processes in warn state */
101 int crit = 0; /* number of processes in crit state */ 103 int crit = 0; /* number of processes in crit state */
102 int i = 0; 104 int i = 0;
@@ -135,18 +137,35 @@ main (int argc, char **argv)
135 cols = sscanf (input_buffer, PS_FORMAT, PS_VARLIST); 137 cols = sscanf (input_buffer, PS_FORMAT, PS_VARLIST);
136 138
137 /* Zombie processes do not give a procprog command */ 139 /* Zombie processes do not give a procprog command */
138 if ( cols == 6 && strstr(procstat, zombie) ) { 140 if ( cols == (expected_cols - 1) && strstr(procstat, zombie) ) {
139 cols = 7; 141 cols = expected_cols;
140 /* Set some value for procargs for the strip command further below 142 /* Set some value for procargs for the strip command further below
141 Seen to be a problem on some Solaris 7 and 8 systems */ 143 Seen to be a problem on some Solaris 7 and 8 systems */
142 input_buffer[pos] = '\n'; 144 input_buffer[pos] = '\n';
143 input_buffer[pos+1] = 0x0; 145 input_buffer[pos+1] = 0x0;
144 } 146 }
145 if ( cols >= 7 ) { 147 if ( cols >= expected_cols ) {
146 resultsum = 0; 148 resultsum = 0;
147 asprintf (&procargs, "%s", input_buffer + pos); 149 asprintf (&procargs, "%s", input_buffer + pos);
148 strip (procargs); 150 strip (procargs);
149 151
152 /* Some ps return full pathname for command. This removes path */
153 temp_string = strtok ((char *)procprog, "/");
154 while (temp_string) {
155 strcpy(procprog, temp_string);
156 temp_string = strtok (NULL, "/");
157 }
158
159 if (verbose >= 3)
160 printf ("%d %d %d %d %d %.2f %s %s %s\n",
161 procs, procuid, procvsz, procrss,
162 procppid, procpcpu, procstat, procprog, procargs);
163
164 /* Ignore self */
165 if (strcmp (procprog, progname) == 0) {
166 continue;
167 }
168
150 if ((options & STAT) && (strstr (statopts, procstat))) 169 if ((options & STAT) && (strstr (statopts, procstat)))
151 resultsum |= STAT; 170 resultsum |= STAT;
152 if ((options & ARGS) && procargs && (strstr (procargs, args) != NULL)) 171 if ((options & ARGS) && procargs && (strstr (procargs, args) != NULL))
@@ -164,15 +183,6 @@ main (int argc, char **argv)
164 if ((options & PCPU) && (procpcpu >= pcpu)) 183 if ((options & PCPU) && (procpcpu >= pcpu))
165 resultsum |= PCPU; 184 resultsum |= PCPU;
166 185
167 if (verbose >= 3)
168 printf ("%d %d %d %d %d %.2f %s %s %s\n",
169 procs, procuid, procvsz, procrss,
170 procppid, procpcpu, procstat, procprog, procargs);
171
172 /* Ignore self */
173 if (strcmp (procprog, progname) == 0)
174 continue;
175
176 found++; 186 found++;
177 187
178 /* Next line if filters not matched */ 188 /* Next line if filters not matched */
@@ -192,12 +202,11 @@ main (int argc, char **argv)
192 if (metric != METRIC_PROCS) { 202 if (metric != METRIC_PROCS) {
193 if (i == STATE_WARNING) { 203 if (i == STATE_WARNING) {
194 warn++; 204 warn++;
195 asprintf (&fails, "%s%s%s", fails, (fails == "" ? "" : ", "), procprog);
196 } 205 }
197 if (i == STATE_CRITICAL) { 206 if (i == STATE_CRITICAL) {
198 crit++; 207 crit++;
199 asprintf (&fails, "%s%s%s", fails, (fails == "" ? "" : ", "), procprog);
200 } 208 }
209 asprintf (&fails, "%s%s%s", fails, (strcmp(fails,"") ? ", " : ""), procprog);
201 result = max_state (result, i); 210 result = max_state (result, i);
202 } 211 }
203 } 212 }
@@ -237,33 +246,25 @@ main (int argc, char **argv)
237 } 246 }
238 247
239 if ( result == STATE_OK ) { 248 if ( result == STATE_OK ) {
240 printf (_("%s OK: %d process%s"), 249 printf ("%s %s: ", metric_name, _("OK"));
241 metric_name, procs, ( procs != 1 ? "es" : "") );
242 } else if (result == STATE_WARNING) { 250 } else if (result == STATE_WARNING) {
243 if ( metric == METRIC_PROCS ) { 251 printf ("%s %s: ", metric_name, _("WARNING"));
244 printf (_("PROCS WARNING: %d process%s"), procs, 252 if ( metric != METRIC_PROCS ) {
245 ( procs != 1 ? "es" : "")); 253 printf (_("%d warn out of "), warn);
246 } else {
247 printf (_("%s WARNING: %d warn out of %d process%s"),
248 metric_name, warn, procs,
249 ( procs != 1 ? "es" : ""));
250 } 254 }
251 } else if (result == STATE_CRITICAL) { 255 } else if (result == STATE_CRITICAL) {
252 if (metric == METRIC_PROCS) { 256 printf ("%s %s: ", metric_name, _("CRITICAL"));
253 printf (_("PROCS CRITICAL: %d process%s"), procs, 257 if (metric != METRIC_PROCS) {
254 ( procs != 1 ? "es" : "")); 258 printf (_("%d crit, %d warn out of "), crit, warn);
255 } else {
256 printf (_("%s CRITICAL: %d crit, %d warn out of %d process%s"),
257 metric_name, crit, warn, procs,
258 ( procs != 1 ? "es" : ""));
259 } 259 }
260 } 260 }
261 printf (ngettext ("%d process", "%d processes", procs), procs);
261 262
262 if (strcmp(fmt,"") != 0) { 263 if (strcmp(fmt,"") != 0) {
263 printf (_(" with %s"), fmt); 264 printf (_(" with %s"), fmt);
264 } 265 }
265 266
266 if ( verbose >= 1 && fails != "" ) 267 if ( verbose >= 1 && strcmp(fails,"") )
267 printf (" [%s]", fails); 268 printf (" [%s]", fails);
268 269
269 printf ("\n"); 270 printf ("\n");
@@ -631,7 +632,7 @@ Optional Filters:\n\
631 -a, --argument-array=STRING\n\ 632 -a, --argument-array=STRING\n\
632 Only scan for processes with args that contain STRING.\n\ 633 Only scan for processes with args that contain STRING.\n\
633 -C, --command=COMMAND\n\ 634 -C, --command=COMMAND\n\
634 Only scan for exact matches to the named COMMAND.\n")); 635 Only scan for exact matches of COMMAND (without path).\n"));
635 636
636 printf(_("\n\ 637 printf(_("\n\
637RANGEs are specified 'min:max' or 'min:' or ':max' (or 'max'). If\n\ 638RANGEs are specified 'min:max' or 'min:' or ':max' (or 'max'). If\n\