summaryrefslogtreecommitdiffstats
path: root/plugins/check_disk.c
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2024-03-26 23:36:41 (GMT)
committerGitHub <noreply@github.com>2024-03-26 23:36:41 (GMT)
commitd3faf13961c61b3ad69b47960124d3269c5f335e (patch)
treed626f2d7d234b194af8fe536dd5b2cf318a7adf6 /plugins/check_disk.c
parent66f62dd336832702a1e4f60cbfc4258de2c931cf (diff)
downloadmonitoring-plugins-d3faf13961c61b3ad69b47960124d3269c5f335e.tar.gz
check_disk: Fail on missing arguments for --warning and --critical and fix a test case (#1935)
* check_disk: Fail on missing arguments for --warning and --critical * Add new test function for percentage expressions and use it in check_disk * Add error abort in tests if they fail to parse output * Fix typo in test which probably broke the test since forever :-(
Diffstat (limited to 'plugins/check_disk.c')
-rw-r--r--plugins/check_disk.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 0d84ecd..24de2d4 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -550,6 +550,10 @@ process_arguments (int argc, char **argv)
550 550
551 /* See comments for 'c' */ 551 /* See comments for 'c' */
552 case 'w': /* warning threshold */ 552 case 'w': /* warning threshold */
553 if (!is_percentage_expression(optarg) && !is_numeric(optarg)) {
554 die(STATE_UNKNOWN, "Argument for --warning invalid or missing: %s\n", optarg);
555 }
556
553 if (strstr(optarg, "%")) { 557 if (strstr(optarg, "%")) {
554 if (*optarg == '@') { 558 if (*optarg == '@') {
555 warn_freespace_percent = optarg; 559 warn_freespace_percent = optarg;
@@ -571,6 +575,10 @@ process_arguments (int argc, char **argv)
571 force @ at the beginning of the range, so that it is backwards compatible 575 force @ at the beginning of the range, so that it is backwards compatible
572 */ 576 */
573 case 'c': /* critical threshold */ 577 case 'c': /* critical threshold */
578 if (!is_percentage_expression(optarg) && !is_numeric(optarg)) {
579 die(STATE_UNKNOWN, "Argument for --critical invalid or missing: %s\n", optarg);
580 }
581
574 if (strstr(optarg, "%")) { 582 if (strstr(optarg, "%")) {
575 if (*optarg == '@') { 583 if (*optarg == '@') {
576 crit_freespace_percent = optarg; 584 crit_freespace_percent = optarg;