X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fcheck_pgsql.c;h=e1484566328961e69b89652e19f6e9ff53c7f6ef;hb=8b2381c97634804bad7aa0b48345a9e1216b5512;hp=4c8662bab7029d4bfa5335beea63a074dfbcd351;hpb=0c3386274ef5002dffc20337ef02407f24d7400c;p=nagiosplug.git diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c index 4c8662b..e148456 100644 --- a/plugins/check_pgsql.c +++ b/plugins/check_pgsql.c @@ -23,15 +23,14 @@ * *****************************************************************************/ -const char *progname = "check_pgsql" +const char *progname = "check_pgsql"; #define REVISION "$Revision$" #define COPYRIGHT "1999-2001" #define AUTHOR "Karl DeBisschop" #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 "\ @@ -44,7 +43,7 @@ const char *progname = "check_pgsql" -H, --hostname=STRING\n\ Name or numeric IP address of machine running backend\n\ -P, --port=INTEGER\n\ - Port running backend (default: %s)\n\ + Port running backend (default: %d)\n\ -d, --database=STRING\n\ Database to check (default: %s)\n\ -l, --logname = STRING\n\ @@ -70,15 +69,16 @@ a password, but no effort is made to obsure or encrypt the password.\n" #define DEFAULT_DB "template1" #define DEFAULT_HOST "127.0.0.1" -#define DEFAULT_PORT "5432" -#define DEFAULT_WARN 2 -#define DEFAULT_CRIT 8 -#define DEFAULT_TIMEOUT 30 +enum { + DEFAULT_PORT = 5432, + DEFAULT_WARN = 2, + DEFAULT_CRIT = 8, + DEFAULT_TIMEOUT = 30 +}; #include "config.h" #include "common.h" #include "utils.h" -#include #include int process_arguments (int, char **); @@ -90,7 +90,7 @@ int is_pg_logname (char *); char *pghost = NULL; /* host name of the backend server */ char *pgport = NULL; /* port of the backend server */ -char default_port[4] = DEFAULT_PORT; +int default_port = DEFAULT_PORT; char *pgoptions = NULL; char *pgtty = NULL; char dbName[NAMEDATALEN] = DEFAULT_DB; @@ -246,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'}, @@ -262,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;