summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index abe721b..925751b 100644
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
@@ -67,6 +67,7 @@ char *pguser = NULL;
67char *pgpasswd = NULL; 67char *pgpasswd = NULL;
68double twarn = (double)DEFAULT_WARN; 68double twarn = (double)DEFAULT_WARN;
69double tcrit = (double)DEFAULT_CRIT; 69double tcrit = (double)DEFAULT_CRIT;
70int verbose = 0;
70 71
71PGconn *conn; 72PGconn *conn;
72/*PGresult *res;*/ 73/*PGresult *res;*/
@@ -151,6 +152,8 @@ main (int argc, char **argv)
151 152
152 if (process_arguments (argc, argv) == ERROR) 153 if (process_arguments (argc, argv) == ERROR)
153 usage4 (_("Could not parse arguments")); 154 usage4 (_("Could not parse arguments"));
155 if (verbose > 2)
156 printf("Arguments initialized\n");
154 157
155 /* Set signal handling and alarm */ 158 /* Set signal handling and alarm */
156 if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) { 159 if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) {
@@ -158,14 +161,24 @@ main (int argc, char **argv)
158 } 161 }
159 alarm (timeout_interval); 162 alarm (timeout_interval);
160 163
164 if (verbose)
165 printf("Connecting to database:\n DB: %s\n User: %s\n Host: %s\n Port: %d\n", dbName,
166 (pguser != NULL) ? pguser : "unspecified",
167 (pghost != NULL) ? pghost : "unspecified",
168 (pgport != NULL) ? atoi(pgport) : DEFAULT_PORT);
169
161 /* make a connection to the database */ 170 /* make a connection to the database */
162 time (&start_time); 171 time (&start_time);
163 conn = 172 conn =
164 PQsetdbLogin (pghost, pgport, pgoptions, pgtty, dbName, pguser, pgpasswd); 173 PQsetdbLogin (pghost, pgport, pgoptions, pgtty, dbName, pguser, pgpasswd);
165 time (&end_time); 174 time (&end_time);
166 elapsed_time = (int) (end_time - start_time); 175 elapsed_time = (int) (end_time - start_time);
176 if (verbose)
177 printf("Time elapsed: %d\n", elapsed_time);
167 178
168 /* check to see that the backend connection was successfully made */ 179 /* check to see that the backend connection was successfully made */
180 if (verbose)
181 printf("Verifying connection\n");
169 if (PQstatus (conn) == CONNECTION_BAD) { 182 if (PQstatus (conn) == CONNECTION_BAD) {
170 printf (_("CRITICAL - no connection to '%s' (%s).\n"), 183 printf (_("CRITICAL - no connection to '%s' (%s).\n"),
171 dbName, PQerrorMessage (conn)); 184 dbName, PQerrorMessage (conn));
@@ -181,6 +194,8 @@ main (int argc, char **argv)
181 else { 194 else {
182 status = STATE_OK; 195 status = STATE_OK;
183 } 196 }
197 if (verbose)
198 printf("Closing connection\n");
184 PQfinish (conn); 199 PQfinish (conn);
185 printf (_(" %s - database %s (%d sec.)|%s\n"), 200 printf (_(" %s - database %s (%d sec.)|%s\n"),
186 state_text(status), dbName, elapsed_time, 201 state_text(status), dbName, elapsed_time,
@@ -210,11 +225,12 @@ process_arguments (int argc, char **argv)
210 {"authorization", required_argument, 0, 'a'}, 225 {"authorization", required_argument, 0, 'a'},
211 {"port", required_argument, 0, 'P'}, 226 {"port", required_argument, 0, 'P'},
212 {"database", required_argument, 0, 'd'}, 227 {"database", required_argument, 0, 'd'},
228 {"verbose", no_argument, 0, 'v'},
213 {0, 0, 0, 0} 229 {0, 0, 0, 0}
214 }; 230 };
215 231
216 while (1) { 232 while (1) {
217 c = getopt_long (argc, argv, "hVt:c:w:H:P:d:l:p:a:", 233 c = getopt_long (argc, argv, "hVt:c:w:H:P:d:l:p:a:v",
218 longopts, &option); 234 longopts, &option);
219 235
220 if (c == EOF) 236 if (c == EOF)
@@ -275,6 +291,9 @@ process_arguments (int argc, char **argv)
275 case 'a': 291 case 'a':
276 pgpasswd = optarg; 292 pgpasswd = optarg;
277 break; 293 break;
294 case 'v':
295 verbose++;
296 break;
278 } 297 }
279 } 298 }
280 299