Code

Fixed reading too many argv parameters and changed to asprintf
[nagiosplug.git] / plugins / check_pgsql.c
index 2d80fad1bb04560c89fafc1dcd1c639ad942bcc0..e1484566328961e69b89652e19f6e9ff53c7f6ef 100644 (file)
@@ -30,8 +30,7 @@ const char *progname = "check_pgsql";
 #define EMAIL "kdebisschop@users.sourceforge.net"
 #define SUMMARY "Tests to see if a PostgreSQL DBMS is accepting connections.\n"
 
-#define OPTIONS "\
-\[-c critical_time] [-w warning_time] [-t timeout] [-H host]\n\
+#define OPTIONS "[-c critical_time] [-w warning_time] [-t timeout] [-H host]\n\
              [-P port] [-d database] [-l logname] [-p password]"
 
 #define LONGOPTIONS "\
@@ -80,7 +79,6 @@ enum {
 #include "config.h"
 #include "common.h"
 #include "utils.h"
-#include <netdb.h>
 #include <libpq-fe.h>
 
 int process_arguments (int, char **);
@@ -248,7 +246,6 @@ process_arguments (int argc, char **argv)
 {
        int c;
 
-#ifdef HAVE_GETOPT_H
        int option_index = 0;
        static struct option long_options[] = {
                {"help", no_argument, 0, 'h'},
@@ -264,15 +261,11 @@ process_arguments (int argc, char **argv)
                {"database", required_argument, 0, 'd'},
                {0, 0, 0, 0}
        };
-#endif
 
        while (1) {
-#ifdef HAVE_GETOPT_H
                c = getopt_long (argc, argv, "hVt:c:w:H:P:d:l:p:a:",
                                 long_options, &option_index);
-#else
-               c = getopt (argc, argv, "hVt:c:w:H:P:d:l:p:a:");
-#endif
+
                if (c == EOF)
                        break;