summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 843c652)
raw | patch | inline | side by side (parent: 843c652)
author | Matthias Eble <psychotrahe@gmx.de> | |
Mon, 1 Jun 2009 20:08:07 +0000 (22:08 +0200) | ||
committer | Matthias Eble <psychotrahe@gmx.de> | |
Mon, 1 Jun 2009 20:08:07 +0000 (22:08 +0200) |
check_pgsql displayed the -v flag in help output, but didn't
accept the verbosity argument. Added -v and basic verbose output.
accept the verbosity argument. Added -v and basic verbose output.
plugins/check_pgsql.c | patch | blob | history |
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index abe721bf696a5802d60e4922c7e7fd6896733f4c..925751b17e0fbb20af4871bb50f50dabd0939377 100644 (file)
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
char *pgpasswd = NULL;
double twarn = (double)DEFAULT_WARN;
double tcrit = (double)DEFAULT_CRIT;
+int verbose = 0;
PGconn *conn;
/*PGresult *res;*/
if (process_arguments (argc, argv) == ERROR)
usage4 (_("Could not parse arguments"));
+ if (verbose > 2)
+ printf("Arguments initialized\n");
/* Set signal handling and alarm */
if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) {
}
alarm (timeout_interval);
+ if (verbose)
+ printf("Connecting to database:\n DB: %s\n User: %s\n Host: %s\n Port: %d\n", dbName,
+ (pguser != NULL) ? pguser : "unspecified",
+ (pghost != NULL) ? pghost : "unspecified",
+ (pgport != NULL) ? atoi(pgport) : DEFAULT_PORT);
+
/* make a connection to the database */
time (&start_time);
conn =
PQsetdbLogin (pghost, pgport, pgoptions, pgtty, dbName, pguser, pgpasswd);
time (&end_time);
elapsed_time = (int) (end_time - start_time);
+ if (verbose)
+ printf("Time elapsed: %d\n", elapsed_time);
/* check to see that the backend connection was successfully made */
+ if (verbose)
+ printf("Verifying connection\n");
if (PQstatus (conn) == CONNECTION_BAD) {
printf (_("CRITICAL - no connection to '%s' (%s).\n"),
dbName, PQerrorMessage (conn));
else {
status = STATE_OK;
}
+ if (verbose)
+ printf("Closing connection\n");
PQfinish (conn);
printf (_(" %s - database %s (%d sec.)|%s\n"),
state_text(status), dbName, elapsed_time,
{"authorization", required_argument, 0, 'a'},
{"port", required_argument, 0, 'P'},
{"database", required_argument, 0, 'd'},
+ {"verbose", no_argument, 0, 'v'},
{0, 0, 0, 0}
};
while (1) {
- c = getopt_long (argc, argv, "hVt:c:w:H:P:d:l:p:a:",
+ c = getopt_long (argc, argv, "hVt:c:w:H:P:d:l:p:a:v",
longopts, &option);
if (c == EOF)
case 'a':
pgpasswd = optarg;
break;
+ case 'v':
+ verbose++;
+ break;
}
}