[monitoring-plugins] Remove STATE_DEPENDENT (#2291)
GitHub
git at monitoring-plugins.org
Wed Jul 29 16:10:13 CEST 2026
Module: monitoring-plugins
Branch: master
Commit: aaca8dcf80a19546ee037164e30495abbeb043a4
Author: Lorenz Kästle <12514511+RincewindsHat at users.noreply.github.com>
Committer: GitHub <noreply at github.com>
Date: Wed Jul 29 16:06:29 2026 +0200
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=aaca8dcf
Remove STATE_DEPENDENT (#2291)
Additionaly to the "normal" exit states OK, WARNING, CRITICAL and
UNKNOWN, the state DEPENDENT was definend, but only used internally
in check_http.
This patch removes every mention of it and adapts the logic in
check_http accordingly.
The result is a cleaner interface and should cause less confusion in the
future.
---
lib/output.c | 19 +++++++++++++++----
lib/states.h | 9 +--------
lib/utils_base.c | 2 --
plugins-scripts/utils.pm.in | 2 +-
plugins-scripts/utils.sh.in | 1 -
plugins/check_http.c | 13 +++++++++----
6 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/lib/output.c b/lib/output.c
index 43a5d078..b73460eb 100644
--- a/lib/output.c
+++ b/lib/output.c
@@ -736,7 +736,7 @@ mp_state_enum mp_eval_unknown(mp_check overall) {
static int mp_compare_state(mp_state_enum first, mp_state_enum second) {
switch (first) {
- case STATE_OK:
+ case STATE_OK: {
switch (second) {
case STATE_OK:
return 0;
@@ -745,7 +745,9 @@ static int mp_compare_state(mp_state_enum first, mp_state_enum second) {
case STATE_CRITICAL:
return 1;
}
- case STATE_WARNING:
+ break;
+ }
+ case STATE_WARNING: {
switch (second) {
case STATE_OK:
return -1;
@@ -755,7 +757,9 @@ static int mp_compare_state(mp_state_enum first, mp_state_enum second) {
case STATE_CRITICAL:
return 1;
}
- case STATE_UNKNOWN:
+ break;
+ }
+ case STATE_UNKNOWN: {
switch (second) {
case STATE_OK:
case STATE_WARNING:
@@ -765,7 +769,9 @@ static int mp_compare_state(mp_state_enum first, mp_state_enum second) {
case STATE_CRITICAL:
return 1;
}
- case STATE_CRITICAL:
+ break;
+ }
+ case STATE_CRITICAL: {
switch (second) {
case STATE_OK:
case STATE_WARNING:
@@ -774,5 +780,10 @@ static int mp_compare_state(mp_state_enum first, mp_state_enum second) {
case STATE_CRITICAL:
return 0;
}
+ break;
+ }
}
+
+ // should not be reachable, but silences a compiler warning
+ return 0;
}
diff --git a/lib/states.h b/lib/states.h
index 43926f0c..3b50fedb 100644
--- a/lib/states.h
+++ b/lib/states.h
@@ -9,7 +9,6 @@ typedef enum state_enum {
STATE_WARNING,
STATE_CRITICAL,
STATE_UNKNOWN,
- STATE_DEPENDENT
} mp_state_enum;
/* **************************************************************************
@@ -33,16 +32,13 @@ static inline mp_state_enum max_state(mp_state_enum a, mp_state_enum b) {
if (a == STATE_UNKNOWN || b == STATE_UNKNOWN) {
return STATE_UNKNOWN;
}
- if (a == STATE_DEPENDENT || b == STATE_DEPENDENT) {
- return STATE_DEPENDENT;
- }
return MAX(a, b);
}
/* **************************************************************************
* max_state_alt(STATE_x, STATE_y)
* compares STATE_x to STATE_y and returns result based on the following
- * STATE_OK < STATE_DEPENDENT < STATE_UNKNOWN < STATE_WARNING < STATE_CRITICAL
+ * STATE_OK < STATE_UNKNOWN < STATE_WARNING < STATE_CRITICAL
*
* The main difference between max_state_alt and max_state it that it doesn't
* allow setting a default to UNKNOWN. It will instead prioritize any valid
@@ -59,9 +55,6 @@ static inline mp_state_enum max_state_alt(mp_state_enum a, mp_state_enum b) {
if (a == STATE_UNKNOWN || b == STATE_UNKNOWN) {
return STATE_UNKNOWN;
}
- if (a == STATE_DEPENDENT || b == STATE_DEPENDENT) {
- return STATE_DEPENDENT;
- }
if (a == STATE_OK || b == STATE_OK) {
return STATE_OK;
}
diff --git a/lib/utils_base.c b/lib/utils_base.c
index 28e6dc47..7450bd30 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -402,8 +402,6 @@ const char *state_text(mp_state_enum result) {
return "WARNING";
case STATE_CRITICAL:
return "CRITICAL";
- case STATE_DEPENDENT:
- return "DEPENDENT";
default:
return "UNKNOWN";
}
diff --git a/plugins-scripts/utils.pm.in b/plugins-scripts/utils.pm.in
index c84769fb..d5140ca7 100644
--- a/plugins-scripts/utils.pm.in
+++ b/plugins-scripts/utils.pm.in
@@ -27,7 +27,7 @@ $PATH_TO_SNMPGET = "@PATH_TO_SNMPGET@";
## common variables
$TIMEOUT = 15;
-%ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
+%ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3);
## utility subroutines
sub print_revision ($$) {
diff --git a/plugins-scripts/utils.sh.in b/plugins-scripts/utils.sh.in
index 031c0357..90643f00 100644
--- a/plugins-scripts/utils.sh.in
+++ b/plugins-scripts/utils.sh.in
@@ -4,7 +4,6 @@ STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
-STATE_DEPENDENT=4
print_revision() {
echo "$1 v$2 (@PACKAGE@ @VERSION@)"
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 73e4f3b6..f402aa1b 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -42,6 +42,7 @@ const char *email = "devel at monitoring-plugins.org";
#include "netutils.h"
#include "utils.h"
#include <ctype.h>
+#include "states.h"
#define STICKY_NONE 0
#define STICKY_HOST 1
@@ -113,6 +114,7 @@ static bool display_html = false;
static char **http_opt_headers;
static int http_opt_headers_count = 0;
static int onredirect = STATE_OK;
+static bool onredirect_dependent = false;
static int followsticky = STICKY_NONE;
static bool use_ssl = false;
static bool use_sni = false;
@@ -425,11 +427,14 @@ bool process_arguments(int argc, char **argv) {
break;
case 'f': /* onredirect */
if (!strcmp(optarg, "stickyport")) {
- onredirect = STATE_DEPENDENT, followsticky = STICKY_HOST | STICKY_PORT;
+ followsticky = STICKY_HOST | STICKY_PORT;
+ onredirect_dependent = true;
} else if (!strcmp(optarg, "sticky")) {
- onredirect = STATE_DEPENDENT, followsticky = STICKY_HOST;
+ followsticky = STICKY_HOST;
+ onredirect_dependent = true;
} else if (!strcmp(optarg, "follow")) {
- onredirect = STATE_DEPENDENT, followsticky = STICKY_NONE;
+ followsticky = STICKY_NONE;
+ onredirect_dependent = true;
} else if (!strcmp(optarg, "unknown")) {
onredirect = STATE_UNKNOWN;
} else if (!strcmp(optarg, "ok")) {
@@ -1298,7 +1303,7 @@ int check_http(void) {
/* check redirected page if specified */
else if (http_status >= 300) {
- if (onredirect == STATE_DEPENDENT) {
+ if (onredirect_dependent) {
redir(header, status_line);
} else {
result = max_state_alt(onredirect, result);
More information about the Commits
mailing list