summaryrefslogtreecommitdiffstats
path: root/plugins/check_mysql_query.c
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-11-26 13:50:58 +0100
committerLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-11-26 13:57:12 +0100
commit317ee266a88bd8752113df39f12e2d133edd6802 (patch)
treea676bd3f036767d598dbe7a8b3ecc9328e4bb360 /plugins/check_mysql_query.c
parent3657197cf77ca78f6e2d003a71d48dc5d4dc45ae (diff)
downloadmonitoring-plugins-317ee266a88bd8752113df39f12e2d133edd6802.tar.gz
Add output formatting option where they were forgotten
Diffstat (limited to 'plugins/check_mysql_query.c')
-rw-r--r--plugins/check_mysql_query.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/plugins/check_mysql_query.c b/plugins/check_mysql_query.c
index 8af378d5..ae6cc15d 100644
--- a/plugins/check_mysql_query.c
+++ b/plugins/check_mysql_query.c
@@ -73,6 +73,10 @@ int main(int argc, char **argv) {
73 73
74 const check_mysql_query_config config = tmp_config.config; 74 const check_mysql_query_config config = tmp_config.config;
75 75
76 if (config.output_format_is_set) {
77 mp_set_format(config.output_format);
78 }
79
76 MYSQL mysql; 80 MYSQL mysql;
77 /* initialize mysql */ 81 /* initialize mysql */
78 mysql_init(&mysql); 82 mysql_init(&mysql);
@@ -185,6 +189,10 @@ int main(int argc, char **argv) {
185 189
186/* process command-line arguments */ 190/* process command-line arguments */
187check_mysql_query_config_wrapper process_arguments(int argc, char **argv) { 191check_mysql_query_config_wrapper process_arguments(int argc, char **argv) {
192 enum {
193 output_format_index = CHAR_MAX + 1,
194 };
195
188 static struct option longopts[] = {{"hostname", required_argument, 0, 'H'}, 196 static struct option longopts[] = {{"hostname", required_argument, 0, 'H'},
189 {"socket", required_argument, 0, 's'}, 197 {"socket", required_argument, 0, 's'},
190 {"database", required_argument, 0, 'd'}, 198 {"database", required_argument, 0, 'd'},
@@ -199,6 +207,7 @@ check_mysql_query_config_wrapper process_arguments(int argc, char **argv) {
199 {"query", required_argument, 0, 'q'}, 207 {"query", required_argument, 0, 'q'},
200 {"warning", required_argument, 0, 'w'}, 208 {"warning", required_argument, 0, 'w'},
201 {"critical", required_argument, 0, 'c'}, 209 {"critical", required_argument, 0, 'c'},
210 {"output-format", required_argument, 0, output_format_index},
202 {0, 0, 0, 0}}; 211 {0, 0, 0, 0}};
203 212
204 check_mysql_query_config_wrapper result = { 213 check_mysql_query_config_wrapper result = {
@@ -282,6 +291,17 @@ check_mysql_query_config_wrapper process_arguments(int argc, char **argv) {
282 } break; 291 } break;
283 case '?': /* help */ 292 case '?': /* help */
284 usage5(); 293 usage5();
294 case output_format_index: {
295 parsed_output_format parser = mp_parse_output_format(optarg);
296 if (!parser.parsing_success) {
297 printf("Invalid output format: %s\n", optarg);
298 exit(STATE_UNKNOWN);
299 }
300
301 result.config.output_format_is_set = true;
302 result.config.output_format = parser.output_format;
303 break;
304 }
285 } 305 }
286 } 306 }
287 307
@@ -344,6 +364,8 @@ void print_help(void) {
344 printf(" ==> %s <==\n", _("IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!!")); 364 printf(" ==> %s <==\n", _("IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!!"));
345 printf(" %s\n", _("Your clear-text password could be visible as a process table entry")); 365 printf(" %s\n", _("Your clear-text password could be visible as a process table entry"));
346 366
367 printf(UT_OUTPUT_FORMAT);
368
347 printf("\n"); 369 printf("\n");
348 printf(" %s\n", _("A query is required. The result from the query should be numeric.")); 370 printf(" %s\n", _("A query is required. The result from the query should be numeric."));
349 printf(" %s\n", _("For extra security, create a user with minimal access.")); 371 printf(" %s\n", _("For extra security, create a user with minimal access."));