[Nagiosplug-checkins] CVS: nagiosplug/plugins Makefile.am,1.32,1.33 check_procs.c,1.21,1.22
Ton Voon
tonvoon at users.sourceforge.net
Tue Sep 16 07:15:08 CEST 2003
Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv4084/plugins
Modified Files:
Makefile.am check_procs.c
Log Message:
Support for AIX ps command and cleanup of configure's ps checks
Index: Makefile.am
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/Makefile.am,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -r1.32 -r1.33
*** Makefile.am 3 Aug 2003 06:03:31 -0000 1.32
--- Makefile.am 16 Sep 2003 14:14:53 -0000 1.33
***************
*** 13,17 ****
libexec_PROGRAMS = check_disk check_dummy check_http check_load \
check_mrtg check_mrtgtraf check_nwstat check_overcr check_ping \
! check_procs check_real check_smtp check_ssh check_tcp check_time \
check_udp check_ups check_users negate urlize \
@EXTRAS@
--- 13,17 ----
libexec_PROGRAMS = check_disk check_dummy check_http check_load \
check_mrtg check_mrtgtraf check_nwstat check_overcr check_ping \
! check_real check_smtp check_ssh check_tcp check_time \
check_udp check_ups check_users negate urlize \
@EXTRAS@
***************
*** 22,26 ****
EXTRA_PROGRAMS = check_mysql check_radius check_pgsql check_snmp check_hpjd \
check_swap check_fping check_ldap check_game check_dig \
! check_nagios check_by_ssh check_dns check_nt check_ide-smart
EXTRA_DIST = t utils.c netutils.c popen.c utils.h netutils.h popen.h common.h \
--- 22,26 ----
EXTRA_PROGRAMS = check_mysql check_radius check_pgsql check_snmp check_hpjd \
check_swap check_fping check_ldap check_game check_dig \
! check_nagios check_by_ssh check_dns check_nt check_ide-smart check_procs
EXTRA_DIST = t utils.c netutils.c popen.c utils.h netutils.h popen.h common.h \
Index: check_procs.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_procs.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -r1.21 -r1.22
*** check_procs.c 2 Sep 2003 15:04:02 -0000 1.21
--- check_procs.c 16 Sep 2003 14:14:53 -0000 1.22
***************
*** 90,93 ****
--- 90,94 ----
char procprog[MAX_INPUT_BUFFER];
char *procargs;
+ char *temp_string;
const char *zombie = "Z";
***************
*** 98,101 ****
--- 99,103 ----
int pos; /* number of spaces before 'args' in `ps` output */
int cols; /* number of columns in ps output */
+ int expected_cols = PS_COLS - 1;
int warn = 0; /* number of processes in warn state */
int crit = 0; /* number of processes in crit state */
***************
*** 136,141 ****
/* Zombie processes do not give a procprog command */
! if ( cols == 6 && strstr(procstat, zombie) ) {
! cols = 7;
/* Set some value for procargs for the strip command further below
Seen to be a problem on some Solaris 7 and 8 systems */
--- 138,143 ----
/* Zombie processes do not give a procprog command */
! if ( cols == (expected_cols - 1) && strstr(procstat, zombie) ) {
! cols = expected_cols;
/* Set some value for procargs for the strip command further below
Seen to be a problem on some Solaris 7 and 8 systems */
***************
*** 143,151 ****
input_buffer[pos+1] = 0x0;
}
! if ( cols >= 7 ) {
resultsum = 0;
asprintf (&procargs, "%s", input_buffer + pos);
strip (procargs);
if ((options & STAT) && (strstr (statopts, procstat)))
resultsum |= STAT;
--- 145,170 ----
input_buffer[pos+1] = 0x0;
}
! if ( cols >= expected_cols ) {
resultsum = 0;
asprintf (&procargs, "%s", input_buffer + pos);
strip (procargs);
+ /* 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, "/");
+ }
+
+ if (verbose >= 3)
+ printf ("%d %d %d %d %d %.2f %s %s %s\n",
+ procs, procuid, procvsz, procrss,
+ procppid, procpcpu, procstat, procprog, procargs);
+
+ /* Ignore self */
+ if (strcmp (procprog, progname) == 0) {
+ continue;
+ }
+
if ((options & STAT) && (strstr (statopts, procstat)))
resultsum |= STAT;
***************
*** 165,177 ****
resultsum |= PCPU;
- if (verbose >= 3)
- printf ("%d %d %d %d %d %.2f %s %s %s\n",
- procs, procuid, procvsz, procrss,
- procppid, procpcpu, procstat, procprog, procargs);
-
- /* Ignore self */
- if (strcmp (procprog, progname) == 0)
- continue;
-
found++;
--- 184,187 ----
***************
*** 193,202 ****
if (i == STATE_WARNING) {
warn++;
- asprintf (&fails, "%s%s%s", fails, (fails == "" ? "" : ", "), procprog);
}
if (i == STATE_CRITICAL) {
crit++;
- asprintf (&fails, "%s%s%s", fails, (fails == "" ? "" : ", "), procprog);
}
result = max_state (result, i);
}
--- 203,211 ----
if (i == STATE_WARNING) {
warn++;
}
if (i == STATE_CRITICAL) {
crit++;
}
+ asprintf (&fails, "%s%s%s", fails, (strcmp(fails,"") ? ", " : ""), procprog);
result = max_state (result, i);
}
***************
*** 238,262 ****
if ( result == STATE_OK ) {
! printf (_("%s OK: %d process%s"),
! metric_name, procs, ( procs != 1 ? "es" : "") );
} else if (result == STATE_WARNING) {
! if ( metric == METRIC_PROCS ) {
! printf (_("PROCS WARNING: %d process%s"), procs,
! ( procs != 1 ? "es" : ""));
! } else {
! printf (_("%s WARNING: %d warn out of %d process%s"),
! metric_name, warn, procs,
! ( procs != 1 ? "es" : ""));
}
} else if (result == STATE_CRITICAL) {
! if (metric == METRIC_PROCS) {
! printf (_("PROCS CRITICAL: %d process%s"), procs,
! ( procs != 1 ? "es" : ""));
! } else {
! printf (_("%s CRITICAL: %d crit, %d warn out of %d process%s"),
! metric_name, crit, warn, procs,
! ( procs != 1 ? "es" : ""));
}
}
if (strcmp(fmt,"") != 0) {
--- 247,263 ----
if ( result == STATE_OK ) {
! printf ("%s %s: ", metric_name, _("OK"));
} else if (result == STATE_WARNING) {
! printf ("%s %s: ", metric_name, _("WARNING"));
! if ( metric != METRIC_PROCS ) {
! printf (_("%d warn out of "), warn);
}
} else if (result == STATE_CRITICAL) {
! printf ("%s %s: ", metric_name, _("CRITICAL"));
! if (metric != METRIC_PROCS) {
! printf (_("%d crit, %d warn out of "), crit, warn);
}
}
+ printf (ngettext ("%d process", "%d processes", procs), procs);
if (strcmp(fmt,"") != 0) {
***************
*** 264,268 ****
}
! if ( verbose >= 1 && fails != "" )
printf (" [%s]", fails);
--- 265,269 ----
}
! if ( verbose >= 1 && strcmp(fails,"") )
printf (" [%s]", fails);
***************
*** 632,636 ****
Only scan for processes with args that contain STRING.\n\
-C, --command=COMMAND\n\
! Only scan for exact matches to the named COMMAND.\n"));
printf(_("\n\
--- 633,637 ----
Only scan for processes with args that contain STRING.\n\
-C, --command=COMMAND\n\
! Only scan for exact matches of COMMAND (without path).\n"));
printf(_("\n\
More information about the Commits
mailing list