Code

- Cleanup minor compile errors on Irix
[nagiosplug.git] / plugins / check_procs.c
index 671190ca092571b3fdedd4699bc22c58121b4235..3f40e087c51ed6f4c92131deb62498a1d9d896f0 100644 (file)
@@ -94,9 +94,11 @@ main (int argc, char **argv)
        int procseconds = 0;
        float procpcpu = 0;
        char procstat[8];
-       char procetime[MAX_INPUT_BUFFER];
+       char procetime[MAX_INPUT_BUFFER] = { '\0' };
        char *procargs;
+#ifdef HAVE_BASENAME
        char *temp_string;
+#endif
 
        const char *zombie = "Z";
 
@@ -108,12 +110,10 @@ 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);
 
@@ -178,11 +178,10 @@ main (int argc, char **argv)
                        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, "/");
-                       }
+#ifdef HAVE_BASENAME
+                       temp_string = strdup(procprog);
+                       procprog = basename(temp_string);
+#endif /* HAVE_BASENAME */
 
                        /* we need to convert the elapsed time to seconds */
                        procseconds = convert_to_seconds(procetime);
@@ -643,6 +642,9 @@ convert_to_seconds(char *etime) {
                (minutes * 60) +
                seconds;
 
+       if (verbose >= 3 && metric == METRIC_ELAPSED) {
+                       printf("seconds: %d\n", total);
+       }
        return total;
 }