summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5d7f78d)
raw | patch | inline | side by side (parent: 5d7f78d)
author | Sebastian Harl <sh@teamix.net> | |
Thu, 7 Apr 2011 09:50:10 +0000 (11:50 +0200) | ||
committer | Sebastian Harl <sh@teamix.net> | |
Thu, 7 Apr 2011 09:56:35 +0000 (11:56 +0200) |
This option may be used to specify further connection parameters to be passed
to PQconnectdb(). For example, this may be used to specify a service name in
pg_service.conf to be used for additional connection parameters: -o
'service=<name>' or to specify the SSL mode: -o 'sslmode=require'.
See the chapter "libpq - C Library" in the PostgreSQL manual for details.
to PQconnectdb(). For example, this may be used to specify a service name in
pg_service.conf to be used for additional connection parameters: -o
'service=<name>' or to specify the SSL mode: -o 'sslmode=require'.
See the chapter "libpq - C Library" in the PostgreSQL manual for details.
plugins/check_pgsql.c | patch | blob | history |
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index 85e26fe099cf58a0cab6650ff631f61a60ec4dd2..aa65fb2f10fdb47c153f1f264ef0224ab96f3ca2 100644 (file)
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
char dbName[NAMEDATALEN] = DEFAULT_DB;
char *pguser = NULL;
char *pgpasswd = NULL;
+char *pgparams = NULL;
double twarn = (double)DEFAULT_WARN;
double tcrit = (double)DEFAULT_CRIT;
char *pgquery = NULL;
<sect2>
<title>Future Enhancements</title>
<para>ToDo List</para>
-<itemizedlist>
-<listitem>Add option to get password from a secured file rather than the command line</listitem>
-</itemizedlist>
</sect2>
}
alarm (timeout_interval);
- asprintf (&conninfo, "dbname = '%s'", dbName);
+ if (pgparams)
+ asprintf (&conninfo, "%s ", pgparams);
+
+ asprintf (&conninfo, "%sdbname = '%s'", conninfo ? conninfo : "", dbName);
if (pghost)
asprintf (&conninfo, "%s host = '%s'", conninfo, pghost);
if (pgport)
{"authorization", required_argument, 0, 'a'},
{"port", required_argument, 0, 'P'},
{"database", required_argument, 0, 'd'},
+ {"option", required_argument, 0, 'o'},
{"query", required_argument, 0, 'q'},
{"query_critical", required_argument, 0, 'C'},
{"query_warning", required_argument, 0, 'W'},
};
while (1) {
- c = getopt_long (argc, argv, "hVt:c:w:H:P:d:l:p:a:q:C:W:v",
+ c = getopt_long (argc, argv, "hVt:c:w:H:P:d:l:p:a:o:q:C:W:v",
longopts, &option);
if (c == EOF)
case 'a':
pgpasswd = optarg;
break;
+ case 'o':
+ if (pgparams)
+ asprintf (&pgparams, "%s %s", pgparams, optarg);
+ else
+ asprintf (&pgparams, "%s", optarg);
+ break;
case 'q':
pgquery = optarg;
break;
printf (" %s\n", _("Login name of user"));
printf (" %s\n", "-p, --password = STRING");
printf (" %s\n", _("Password (BIG SECURITY ISSUE)"));
+ printf (" %s\n", "-o, --option = STRING");
+ printf (" %s\n", _("Connection parameters (keyword = value), see below"));
printf (UT_WARN_CRIT);
printf (" %s\n", _("See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual"));
printf (" %s\n\n", _("for details about how to access internal statistics of the database server."));
+ printf (" %s\n", _("For a list of available connection parameters which may be used with the -o"));
+ printf (" %s\n", _("command line option, see the documentation for PQconnectdb() in the chapter"));
+ printf (" %s\n", _("\"libpq - C Library\" of the PostgreSQL manual. For example, this may be"));
+ printf (" %s\n", _("used to specify a service name in pg_service.conf to be used for additional"));
+ printf (" %s\n", _("connection parameters: -o 'service=<name>' or to specify the SSL mode:"));
+ printf (" %s\n\n", _("-o 'sslmode=require'."));
+
printf (" %s\n", _("The plugin will connect to a local postmaster if no host is specified. To"));
printf (" %s\n", _("connect to a remote host, be sure that the remote postmaster accepts TCP/IP"));
printf (" %s\n\n", _("connections (start the postmaster with the -i option)."));