summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_mysql_query.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/plugins/check_mysql_query.c b/plugins/check_mysql_query.c
index 0bb83c3..2e961a7 100644
--- a/plugins/check_mysql_query.c
+++ b/plugins/check_mysql_query.c
@@ -46,6 +46,8 @@ char *db_host = NULL;
46char *db_socket = NULL; 46char *db_socket = NULL;
47char *db_pass = NULL; 47char *db_pass = NULL;
48char *db = NULL; 48char *db = NULL;
49char *opt_file = NULL;
50char *opt_group = NULL;
49unsigned int db_port = MYSQL_PORT; 51unsigned int db_port = MYSQL_PORT;
50 52
51int process_arguments (int, char **); 53int process_arguments (int, char **);
@@ -83,7 +85,13 @@ main (int argc, char **argv)
83 /* initialize mysql */ 85 /* initialize mysql */
84 mysql_init (&mysql); 86 mysql_init (&mysql);
85 87
86 mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"client"); 88 if (opt_file != NULL)
89 mysql_options(&mysql,MYSQL_READ_DEFAULT_FILE,opt_file);
90
91 if (opt_group != NULL)
92 mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,opt_group);
93 else
94 mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"client");
87 95
88 /* establish a connection to the server and error checking */ 96 /* establish a connection to the server and error checking */
89 if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) { 97 if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) {
@@ -174,6 +182,8 @@ process_arguments (int argc, char **argv)
174 {"database", required_argument, 0, 'd'}, 182 {"database", required_argument, 0, 'd'},
175 {"username", required_argument, 0, 'u'}, 183 {"username", required_argument, 0, 'u'},
176 {"password", required_argument, 0, 'p'}, 184 {"password", required_argument, 0, 'p'},
185 {"file", required_argument, 0, 'f'},
186 {"group", required_argument, 0, 'g'},
177 {"port", required_argument, 0, 'P'}, 187 {"port", required_argument, 0, 'P'},
178 {"verbose", no_argument, 0, 'v'}, 188 {"verbose", no_argument, 0, 'v'},
179 {"version", no_argument, 0, 'V'}, 189 {"version", no_argument, 0, 'V'},
@@ -188,7 +198,7 @@ process_arguments (int argc, char **argv)
188 return ERROR; 198 return ERROR;
189 199
190 while (1) { 200 while (1) {
191 c = getopt_long (argc, argv, "hvVP:p:u:d:H:s:q:w:c:", longopts, &option); 201 c = getopt_long (argc, argv, "hvVP:p:u:d:H:s:q:w:c:f:g:", longopts, &option);
192 202
193 if (c == -1 || c == EOF) 203 if (c == -1 || c == EOF)
194 break; 204 break;
@@ -220,6 +230,12 @@ process_arguments (int argc, char **argv)
220 optarg++; 230 optarg++;
221 } 231 }
222 break; 232 break;
233 case 'f': /* client options file */
234 opt_file = optarg;
235 break;
236 case 'g': /* client options group */
237 opt_group = optarg;
238 break;
223 case 'P': /* critical time threshold */ 239 case 'P': /* critical time threshold */
224 db_port = atoi (optarg); 240 db_port = atoi (optarg);
225 break; 241 break;
@@ -299,6 +315,10 @@ print_help (void)
299 printf (" %s\n", _("Use the specified socket (has no effect if -H is used)")); 315 printf (" %s\n", _("Use the specified socket (has no effect if -H is used)"));
300 printf (" -d, --database=STRING\n"); 316 printf (" -d, --database=STRING\n");
301 printf (" %s\n", _("Database to check")); 317 printf (" %s\n", _("Database to check"));
318 printf (" %s\n", "-f, --file=STRING");
319 printf (" %s\n", _("Read from the specified client options file"));
320 printf (" %s\n", "-g, --group=STRING");
321 printf (" %s\n", _("Use a client options group"));
302 printf (" -u, --username=STRING\n"); 322 printf (" -u, --username=STRING\n");
303 printf (" %s\n", _("Username to login with")); 323 printf (" %s\n", _("Username to login with"));
304 printf (" -p, --password=STRING\n"); 324 printf (" -p, --password=STRING\n");