diff options
Diffstat (limited to 'plugins/check_mysql_query.c')
-rw-r--r-- | plugins/check_mysql_query.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/plugins/check_mysql_query.c b/plugins/check_mysql_query.c index 9d2f493..71ab776 100644 --- a/plugins/check_mysql_query.c +++ b/plugins/check_mysql_query.c | |||
@@ -46,6 +46,8 @@ char *db_host = NULL; | |||
46 | char *db_socket = NULL; | 46 | char *db_socket = NULL; |
47 | char *db_pass = NULL; | 47 | char *db_pass = NULL; |
48 | char *db = NULL; | 48 | char *db = NULL; |
49 | char *opt_file = NULL; | ||
50 | char *opt_group = NULL; | ||
49 | unsigned int db_port = MYSQL_PORT; | 51 | unsigned int db_port = MYSQL_PORT; |
50 | 52 | ||
51 | int process_arguments (int, char **); | 53 | int 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)) { |
@@ -180,6 +188,8 @@ process_arguments (int argc, char **argv) | |||
180 | {"database", required_argument, 0, 'd'}, | 188 | {"database", required_argument, 0, 'd'}, |
181 | {"username", required_argument, 0, 'u'}, | 189 | {"username", required_argument, 0, 'u'}, |
182 | {"password", required_argument, 0, 'p'}, | 190 | {"password", required_argument, 0, 'p'}, |
191 | {"file", required_argument, 0, 'f'}, | ||
192 | {"group", required_argument, 0, 'g'}, | ||
183 | {"port", required_argument, 0, 'P'}, | 193 | {"port", required_argument, 0, 'P'}, |
184 | {"verbose", no_argument, 0, 'v'}, | 194 | {"verbose", no_argument, 0, 'v'}, |
185 | {"version", no_argument, 0, 'V'}, | 195 | {"version", no_argument, 0, 'V'}, |
@@ -194,7 +204,7 @@ process_arguments (int argc, char **argv) | |||
194 | return ERROR; | 204 | return ERROR; |
195 | 205 | ||
196 | while (1) { | 206 | while (1) { |
197 | c = getopt_long (argc, argv, "hvVP:p:u:d:H:s:q:w:c:", longopts, &option); | 207 | c = getopt_long (argc, argv, "hvVP:p:u:d:H:s:q:w:c:f:g:", longopts, &option); |
198 | 208 | ||
199 | if (c == -1 || c == EOF) | 209 | if (c == -1 || c == EOF) |
200 | break; | 210 | break; |
@@ -226,6 +236,12 @@ process_arguments (int argc, char **argv) | |||
226 | optarg++; | 236 | optarg++; |
227 | } | 237 | } |
228 | break; | 238 | break; |
239 | case 'f': /* client options file */ | ||
240 | opt_file = optarg; | ||
241 | break; | ||
242 | case 'g': /* client options group */ | ||
243 | opt_group = optarg; | ||
244 | break; | ||
229 | case 'P': /* critical time threshold */ | 245 | case 'P': /* critical time threshold */ |
230 | db_port = atoi (optarg); | 246 | db_port = atoi (optarg); |
231 | break; | 247 | break; |
@@ -305,6 +321,10 @@ print_help (void) | |||
305 | printf (" %s\n", _("Use the specified socket (has no effect if -H is used)")); | 321 | printf (" %s\n", _("Use the specified socket (has no effect if -H is used)")); |
306 | printf (" -d, --database=STRING\n"); | 322 | printf (" -d, --database=STRING\n"); |
307 | printf (" %s\n", _("Database to check")); | 323 | printf (" %s\n", _("Database to check")); |
324 | printf (" %s\n", "-f, --file=STRING"); | ||
325 | printf (" %s\n", _("Read from the specified client options file")); | ||
326 | printf (" %s\n", "-g, --group=STRING"); | ||
327 | printf (" %s\n", _("Use a client options group")); | ||
308 | printf (" -u, --username=STRING\n"); | 328 | printf (" -u, --username=STRING\n"); |
309 | printf (" %s\n", _("Username to login with")); | 329 | printf (" %s\n", _("Username to login with")); |
310 | printf (" -p, --password=STRING\n"); | 330 | printf (" -p, --password=STRING\n"); |
@@ -330,5 +350,5 @@ print_usage (void) | |||
330 | { | 350 | { |
331 | printf ("%s\n", _("Usage:")); | 351 | printf ("%s\n", _("Usage:")); |
332 | printf (" %s -q SQL_query [-w warn] [-c crit] [-H host] [-P port] [-s socket]\n",progname); | 352 | printf (" %s -q SQL_query [-w warn] [-c crit] [-H host] [-P port] [-s socket]\n",progname); |
333 | printf (" [-d database] [-u user] [-p password]\n"); | 353 | printf (" [-d database] [-u user] [-p password] [-f optfile] [-g group]\n"); |
334 | } | 354 | } |