diff options
author | awiddersheim <awiddersheim@hotmail.com> | 2013-10-05 11:28:19 -0400 |
---|---|---|
committer | awiddersheim <awiddersheim@hotmail.com> | 2013-10-05 11:28:19 -0400 |
commit | dccf53cf3833641d9865cbf946c6c1705a428fc5 (patch) | |
tree | 7d4e4ac28d70b884c0466a7062b4aad4cbd12519 /plugins/check_mysql_query.c | |
parent | f6576c6db4eeb655f16a71286757e4a93792887d (diff) | |
download | monitoring-plugins-dccf53cf3833641d9865cbf946c6c1705a428fc5.tar.gz |
Add ability to read from options file to check_mysql_query.c
This is the same code that was added to check_mysql.c in 5ed7194.
Diffstat (limited to 'plugins/check_mysql_query.c')
-rw-r--r-- | plugins/check_mysql_query.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/plugins/check_mysql_query.c b/plugins/check_mysql_query.c index 0bb83c3e..2e961a7d 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)) { @@ -174,6 +182,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'}, @@ -188,7 +198,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; @@ -220,6 +230,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; @@ -299,6 +315,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"); |