summaryrefslogtreecommitdiffstats
path: root/plugins/check_pgsql.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_pgsql.c')
-rw-r--r--plugins/check_pgsql.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index 8c45731..d94914f 100644
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
@@ -80,6 +80,7 @@ char *pgtty = NULL;
80char dbName[NAMEDATALEN] = DEFAULT_DB; 80char dbName[NAMEDATALEN] = DEFAULT_DB;
81char *pguser = NULL; 81char *pguser = NULL;
82char *pgpasswd = NULL; 82char *pgpasswd = NULL;
83char *pgparams = NULL;
83double twarn = (double)DEFAULT_WARN; 84double twarn = (double)DEFAULT_WARN;
84double tcrit = (double)DEFAULT_CRIT; 85double tcrit = (double)DEFAULT_CRIT;
85char *pgquery = NULL; 86char *pgquery = NULL;
@@ -130,9 +131,6 @@ Please note that all tags must be lowercase to use the DocBook XML DTD.
130<sect2> 131<sect2>
131<title>Future Enhancements</title> 132<title>Future Enhancements</title>
132<para>ToDo List</para> 133<para>ToDo List</para>
133<itemizedlist>
134<listitem>Add option to get password from a secured file rather than the command line</listitem>
135</itemizedlist>
136</sect2> 134</sect2>
137 135
138 136
@@ -179,7 +177,10 @@ main (int argc, char **argv)
179 } 177 }
180 alarm (timeout_interval); 178 alarm (timeout_interval);
181 179
182 asprintf (&conninfo, "dbname = '%s'", dbName); 180 if (pgparams)
181 asprintf (&conninfo, "%s ", pgparams);
182
183 asprintf (&conninfo, "%sdbname = '%s'", conninfo ? conninfo : "", dbName);
183 if (pghost) 184 if (pghost)
184 asprintf (&conninfo, "%s host = '%s'", conninfo, pghost); 185 asprintf (&conninfo, "%s host = '%s'", conninfo, pghost);
185 if (pgport) 186 if (pgport)
@@ -273,6 +274,7 @@ process_arguments (int argc, char **argv)
273 {"authorization", required_argument, 0, 'a'}, 274 {"authorization", required_argument, 0, 'a'},
274 {"port", required_argument, 0, 'P'}, 275 {"port", required_argument, 0, 'P'},
275 {"database", required_argument, 0, 'd'}, 276 {"database", required_argument, 0, 'd'},
277 {"option", required_argument, 0, 'o'},
276 {"query", required_argument, 0, 'q'}, 278 {"query", required_argument, 0, 'q'},
277 {"query_critical", required_argument, 0, 'C'}, 279 {"query_critical", required_argument, 0, 'C'},
278 {"query_warning", required_argument, 0, 'W'}, 280 {"query_warning", required_argument, 0, 'W'},
@@ -281,7 +283,7 @@ process_arguments (int argc, char **argv)
281 }; 283 };
282 284
283 while (1) { 285 while (1) {
284 c = getopt_long (argc, argv, "hVt:c:w:H:P:d:l:p:a:q:C:W:v", 286 c = getopt_long (argc, argv, "hVt:c:w:H:P:d:l:p:a:o:q:C:W:v",
285 longopts, &option); 287 longopts, &option);
286 288
287 if (c == EOF) 289 if (c == EOF)
@@ -348,6 +350,12 @@ process_arguments (int argc, char **argv)
348 case 'a': 350 case 'a':
349 pgpasswd = optarg; 351 pgpasswd = optarg;
350 break; 352 break;
353 case 'o':
354 if (pgparams)
355 asprintf (&pgparams, "%s %s", pgparams, optarg);
356 else
357 asprintf (&pgparams, "%s", optarg);
358 break;
351 case 'q': 359 case 'q':
352 pgquery = optarg; 360 pgquery = optarg;
353 break; 361 break;
@@ -503,6 +511,8 @@ print_help (void)
503 printf (" %s\n", _("Login name of user")); 511 printf (" %s\n", _("Login name of user"));
504 printf (" %s\n", "-p, --password = STRING"); 512 printf (" %s\n", "-p, --password = STRING");
505 printf (" %s\n", _("Password (BIG SECURITY ISSUE)")); 513 printf (" %s\n", _("Password (BIG SECURITY ISSUE)"));
514 printf (" %s\n", "-o, --option = STRING");
515 printf (" %s\n", _("Connection parameters (keyword = value), see below"));
506 516
507 printf (UT_WARN_CRIT); 517 printf (UT_WARN_CRIT);
508 518
@@ -534,6 +544,13 @@ print_help (void)
534 printf (" %s\n", _("See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual")); 544 printf (" %s\n", _("See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual"));
535 printf (" %s\n\n", _("for details about how to access internal statistics of the database server.")); 545 printf (" %s\n\n", _("for details about how to access internal statistics of the database server."));
536 546
547 printf (" %s\n", _("For a list of available connection parameters which may be used with the -o"));
548 printf (" %s\n", _("command line option, see the documentation for PQconnectdb() in the chapter"));
549 printf (" %s\n", _("\"libpq - C Library\" of the PostgreSQL manual. For example, this may be"));
550 printf (" %s\n", _("used to specify a service name in pg_service.conf to be used for additional"));
551 printf (" %s\n", _("connection parameters: -o 'service=<name>' or to specify the SSL mode:"));
552 printf (" %s\n\n", _("-o 'sslmode=require'."));
553
537 printf (" %s\n", _("The plugin will connect to a local postmaster if no host is specified. To")); 554 printf (" %s\n", _("The plugin will connect to a local postmaster if no host is specified. To"));
538 printf (" %s\n", _("connect to a remote host, be sure that the remote postmaster accepts TCP/IP")); 555 printf (" %s\n", _("connect to a remote host, be sure that the remote postmaster accepts TCP/IP"));
539 printf (" %s\n\n", _("connections (start the postmaster with the -i option).")); 556 printf (" %s\n\n", _("connections (start the postmaster with the -i option)."));