Code

Updated help file to remove swap -s reference (Sivakumar Nellurandi)
[nagiosplug.git] / plugins / popen.c
index 98ba085b79bb9e989643849b1297cee2cf02f361..062cf274a476fe8a775c2c562c777747a046f9f3 100644 (file)
@@ -16,10 +16,11 @@ int spclose(FILE *);
  * path passed to the exec'd program are esstially empty. (popen create a shell
  * and passes the environment to it).
  *
+ * $Id$
+ *
  ******************************************************************************/
 
-#include <config.h>
-#include <common.h>
+#include "common.h"
 
 /* extern so plugin has pid to kill exec'd process on timeouts */
 extern int timeout_interval;
@@ -111,8 +112,9 @@ spopen (const char *cmdstring)
        /* there cannot be more args than characters */
        argc = strlen (cmdstring) + 1;  /* add 1 for NULL termination */
        argv = malloc (sizeof(char*)*argc);
+       
        if (argv == NULL) {
-               printf ("Could not malloc argv array in popen()\n");
+               printf (_("Could not malloc argv array in popen()\n"));
                return NULL;
        }
 
@@ -122,7 +124,7 @@ spopen (const char *cmdstring)
                str += strspn (str, " \t\r\n"); /* trim any leading whitespace */
 
                if (i >= argc - 2) {
-                       printf ("You've got a big problem buddy! You need more args!!!\n");
+                       printf (_("CRITICAL - You need more args!!!\n"));
                        return (NULL);
                }
 
@@ -237,17 +239,23 @@ static int openmax = 0;
 #define        OPEN_MAX_GUESS  256                     /* if OPEN_MAX is indeterminate */
                                /* no guarantee this is adequate */
 
+
 void
 popen_timeout_alarm_handler (int signo)
 {
+       int fh;
        if (signo == SIGALRM) {
-               kill (childpid[fileno (child_process)], SIGKILL);
-               printf ("CRITICAL - Plugin timed out after %d seconds\n",
+               fh=fileno (child_process);
+               if(fh >= 0){
+                       kill (childpid[fh], SIGKILL);
+               }
+               printf (_("CRITICAL - Plugin timed out after %d seconds\n"),
                                                timeout_interval);
                exit (STATE_CRITICAL);
        }
 }
 
+
 int
 open_max (void)
 {
@@ -257,14 +265,13 @@ open_max (void)
                        if (errno == 0)
                                openmax = OPEN_MAX_GUESS;       /* it's indeterminate */
                        else
-                               err_sys ("sysconf error for _SC_OPEN_MAX");
+                               err_sys (_("sysconf error for _SC_OPEN_MAX"));
                }
        }
        return (openmax);
 }
 
 
-
 /* Fatal error related to a system call.
  * Print a message and die. */
 
@@ -307,4 +314,3 @@ rtrim (char *str, const char *tok)
        }
        return str;
 }
-