aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_mysql_query.c
diff options
context:
space:
mode:
authorGravatar Thomas Guyot-Sionnest <dermoth@aei.ca> 2014-01-27 22:50:27 -0800
committerGravatar Thomas Guyot-Sionnest <dermoth@aei.ca> 2014-01-27 22:50:27 -0800
commitf34f51a005408a95cd2b20d739f761106857ef7b (patch)
tree35db9ac6490563c8818d2f71e38c0f2995596de6 /plugins/check_mysql_query.c
parent58e57b32bf733bf952794c056047fb810684a468 (diff)
parentbe2324d7ab10615ae96b0f0a2daf2ad85cb1f613 (diff)
downloadmonitoring-plugins-f34f51a005408a95cd2b20d739f761106857ef7b.tar.gz
Merge pull request #1200 from awiddersheim/add_file_options_mysql_query
Add ability to read from options file to check_mysql_query.c
Diffstat (limited to 'plugins/check_mysql_query.c')
-rw-r--r--plugins/check_mysql_query.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/plugins/check_mysql_query.c b/plugins/check_mysql_query.c
index 9d2f4932..71ab7768 100644
--- a/plugins/check_mysql_query.c
+++ b/plugins/check_mysql_query.c
@@ -46,6 +46,8 @@ char *db_host = NULL;
char *db_socket = NULL;
char *db_pass = NULL;
char *db = NULL;
+char *opt_file = NULL;
+char *opt_group = NULL;
unsigned int db_port = MYSQL_PORT;
int process_arguments (int, char **);
@@ -83,7 +85,13 @@ main (int argc, char **argv)
/* initialize mysql */
mysql_init (&mysql);
- mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"client");
+ if (opt_file != NULL)
+ mysql_options(&mysql,MYSQL_READ_DEFAULT_FILE,opt_file);
+
+ if (opt_group != NULL)
+ mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,opt_group);
+ else
+ mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"client");
/* establish a connection to the server and error checking */
if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) {
@@ -180,6 +188,8 @@ process_arguments (int argc, char **argv)
{"database", required_argument, 0, 'd'},
{"username", required_argument, 0, 'u'},
{"password", required_argument, 0, 'p'},
+ {"file", required_argument, 0, 'f'},
+ {"group", required_argument, 0, 'g'},
{"port", required_argument, 0, 'P'},
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
@@ -194,7 +204,7 @@ process_arguments (int argc, char **argv)
return ERROR;
while (1) {
- c = getopt_long (argc, argv, "hvVP:p:u:d:H:s:q:w:c:", longopts, &option);
+ c = getopt_long (argc, argv, "hvVP:p:u:d:H:s:q:w:c:f:g:", longopts, &option);
if (c == -1 || c == EOF)
break;
@@ -226,6 +236,12 @@ process_arguments (int argc, char **argv)
optarg++;
}
break;
+ case 'f': /* client options file */
+ opt_file = optarg;
+ break;
+ case 'g': /* client options group */
+ opt_group = optarg;
+ break;
case 'P': /* critical time threshold */
db_port = atoi (optarg);
break;
@@ -305,6 +321,10 @@ print_help (void)
printf (" %s\n", _("Use the specified socket (has no effect if -H is used)"));
printf (" -d, --database=STRING\n");
printf (" %s\n", _("Database to check"));
+ printf (" %s\n", "-f, --file=STRING");
+ printf (" %s\n", _("Read from the specified client options file"));
+ printf (" %s\n", "-g, --group=STRING");
+ printf (" %s\n", _("Use a client options group"));
printf (" -u, --username=STRING\n");
printf (" %s\n", _("Username to login with"));
printf (" -p, --password=STRING\n");
@@ -330,5 +350,5 @@ print_usage (void)
{
printf ("%s\n", _("Usage:"));
printf (" %s -q SQL_query [-w warn] [-c crit] [-H host] [-P port] [-s socket]\n",progname);
- printf (" [-d database] [-u user] [-p password]\n");
+ printf (" [-d database] [-u user] [-p password] [-f optfile] [-g group]\n");
}