Revision: 2205
http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=2205&view=rev
Author: dermoth
Date: 2009-06-01 20:12:16 +0000 (Mon, 01 Jun 2009)
Log Message:
-----------
Added verbose output to check_pgsql (#2799281 - Jun Kuriyama)
check_pgsql displayed the -v flag in help output, but didn't
accept the verbosity argument. Added -v and basic verbose output.
From: Matthias Eble <[email protected]>
Modified Paths:
--------------
nagiosplug/trunk/plugins/check_pgsql.c
Modified: nagiosplug/trunk/plugins/check_pgsql.c
===================================================================
--- nagiosplug/trunk/plugins/check_pgsql.c 2009-06-01 14:49:15 UTC (rev 2204)
+++ nagiosplug/trunk/plugins/check_pgsql.c 2009-06-01 20:12:16 UTC (rev 2205)
@@ -67,6 +67,7 @@
char *pgpasswd = NULL;
double twarn = (double)DEFAULT_WARN;
double tcrit = (double)DEFAULT_CRIT;
+int verbose = 0;
PGconn *conn;
/*PGresult *res;*/
@@ -151,6 +152,8 @@
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) {
@@ -158,14 +161,24 @@
}
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));
@@ -181,6 +194,8 @@
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,
@@ -210,11 +225,12 @@
{"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)
@@ -275,6 +291,9 @@
case 'a':
pgpasswd = optarg;
break;
+ case 'v':
+ verbose++;
+ break;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.