diff options
Diffstat (limited to 'plugins/check_mysql_query.c')
| -rw-r--r-- | plugins/check_mysql_query.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/plugins/check_mysql_query.c b/plugins/check_mysql_query.c index ff86e219..8d46eaae 100644 --- a/plugins/check_mysql_query.c +++ b/plugins/check_mysql_query.c | |||
| @@ -183,7 +183,11 @@ int main(int argc, char **argv) { | |||
| 183 | mp_add_perfdata_to_subcheck(&sc_value, pd_query_result); | 183 | mp_add_perfdata_to_subcheck(&sc_value, pd_query_result); |
| 184 | 184 | ||
| 185 | sc_value = mp_set_subcheck_state(sc_value, mp_get_pd_status(pd_query_result)); | 185 | sc_value = mp_set_subcheck_state(sc_value, mp_get_pd_status(pd_query_result)); |
| 186 | xasprintf(&sc_value.output, "'%s' returned '%f'", config.sql_query, value); | 186 | if (config.queryname != NULL) { |
| 187 | xasprintf(&sc_value.output, "query '%s' returned '%f'", config.queryname, value); | ||
| 188 | } else { | ||
| 189 | xasprintf(&sc_value.output, "query '%s' returned '%f'", config.sql_query, value); | ||
| 190 | } | ||
| 187 | 191 | ||
| 188 | mp_add_subcheck_to_check(&overall, sc_value); | 192 | mp_add_subcheck_to_check(&overall, sc_value); |
| 189 | 193 | ||
| @@ -194,6 +198,7 @@ int main(int argc, char **argv) { | |||
| 194 | check_mysql_query_config_wrapper process_arguments(int argc, char **argv) { | 198 | check_mysql_query_config_wrapper process_arguments(int argc, char **argv) { |
| 195 | enum { | 199 | enum { |
| 196 | output_format_index = CHAR_MAX + 1, | 200 | output_format_index = CHAR_MAX + 1, |
| 201 | queryname_index, | ||
| 197 | }; | 202 | }; |
| 198 | 203 | ||
| 199 | static struct option longopts[] = {{"hostname", required_argument, 0, 'H'}, | 204 | static struct option longopts[] = {{"hostname", required_argument, 0, 'H'}, |
| @@ -211,6 +216,7 @@ check_mysql_query_config_wrapper process_arguments(int argc, char **argv) { | |||
| 211 | {"warning", required_argument, 0, 'w'}, | 216 | {"warning", required_argument, 0, 'w'}, |
| 212 | {"critical", required_argument, 0, 'c'}, | 217 | {"critical", required_argument, 0, 'c'}, |
| 213 | {"output-format", required_argument, 0, output_format_index}, | 218 | {"output-format", required_argument, 0, output_format_index}, |
| 219 | {"queryname", required_argument, 0, queryname_index}, | ||
| 214 | {0, 0, 0, 0}}; | 220 | {0, 0, 0, 0}}; |
| 215 | 221 | ||
| 216 | check_mysql_query_config_wrapper result = { | 222 | check_mysql_query_config_wrapper result = { |
| @@ -305,6 +311,9 @@ check_mysql_query_config_wrapper process_arguments(int argc, char **argv) { | |||
| 305 | result.config.output_format = parser.output_format; | 311 | result.config.output_format = parser.output_format; |
| 306 | break; | 312 | break; |
| 307 | } | 313 | } |
| 314 | case queryname_index: { | ||
| 315 | result.config.queryname = optarg; | ||
| 316 | } | ||
| 308 | } | 317 | } |
| 309 | } | 318 | } |
| 310 | 319 | ||
| @@ -350,6 +359,9 @@ void print_help(void) { | |||
| 350 | printf(UT_EXTRA_OPTS); | 359 | printf(UT_EXTRA_OPTS); |
| 351 | printf(" -q, --query=STRING\n"); | 360 | printf(" -q, --query=STRING\n"); |
| 352 | printf(" %s\n", _("SQL query to run. Only first column in first row will be read")); | 361 | printf(" %s\n", _("SQL query to run. Only first column in first row will be read")); |
| 362 | printf(" --queryname\n"); | ||
| 363 | printf(" %s\n", _("A name for the query, this string is used instead of the query")); | ||
| 364 | |||
| 353 | printf(UT_WARN_CRIT_RANGE); | 365 | printf(UT_WARN_CRIT_RANGE); |
| 354 | printf(UT_HOST_PORT, 'P', myport); | 366 | printf(UT_HOST_PORT, 'P', myport); |
| 355 | printf(" %s\n", "-s, --socket=STRING"); | 367 | printf(" %s\n", "-s, --socket=STRING"); |
