diff options
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/check_swap.c | 35 | ||||
| -rw-r--r-- | plugins/check_swap.d/check_swap.h | 3 | ||||
| -rw-r--r-- | plugins/check_swap.d/swap.c | 4 |
3 files changed, 24 insertions, 18 deletions
diff --git a/plugins/check_swap.c b/plugins/check_swap.c index e0c246db..bc90a90b 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c | |||
| @@ -114,24 +114,29 @@ int main(int argc, char **argv) { | |||
| 114 | crit_print = config.crit.value * (data.metrics.total / HUNDRED_PERCENT); | 114 | crit_print = config.crit.value * (data.metrics.total / HUNDRED_PERCENT); |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | char *perfdata = perfdata_uint64("swap", data.metrics.free, "B", true, warn_print, true, crit_print, true, 0, true, data.metrics.total); | 117 | char *perfdata = perfdata_uint64("swap", data.metrics.free, "B", config.warn_is_set, warn_print, config.crit_is_set, crit_print, true, |
| 118 | 0, true, data.metrics.total); | ||
| 118 | 119 | ||
| 119 | if (verbose > 1) { | 120 | if (config.warn_is_set) { |
| 120 | printf("Warn threshold value: %" PRIu64 "\n", config.warn.value); | 121 | if (verbose > 1) { |
| 121 | } | 122 | printf("Warn threshold value: %" PRIu64 "\n", config.warn.value); |
| 123 | } | ||
| 122 | 124 | ||
| 123 | if ((config.warn.is_percentage && (percent_used >= (double)(HUNDRED_PERCENT - config.warn.value))) || | 125 | if ((config.warn.is_percentage && (percent_used >= (double)(HUNDRED_PERCENT - config.warn.value))) || |
| 124 | config.warn.value >= data.metrics.free) { | 126 | config.warn.value >= data.metrics.free) { |
| 125 | data.statusCode = max_state(data.statusCode, STATE_WARNING); | 127 | data.statusCode = max_state(data.statusCode, STATE_WARNING); |
| 128 | } | ||
| 126 | } | 129 | } |
| 127 | 130 | ||
| 128 | if (verbose > 1) { | 131 | if (config.crit_is_set) { |
| 129 | printf("Crit threshold value: %" PRIu64 "\n", config.crit.value); | 132 | if (verbose > 1) { |
| 130 | } | 133 | printf("Crit threshold value: %" PRIu64 "\n", config.crit.value); |
| 134 | } | ||
| 131 | 135 | ||
| 132 | if ((config.crit.is_percentage && (percent_used >= (double)(HUNDRED_PERCENT - config.crit.value))) || | 136 | if ((config.crit.is_percentage && (percent_used >= (double)(HUNDRED_PERCENT - config.crit.value))) || |
| 133 | config.crit.value >= data.metrics.free) { | 137 | config.crit.value >= data.metrics.free) { |
| 134 | data.statusCode = max_state(data.statusCode, STATE_CRITICAL); | 138 | data.statusCode = max_state(data.statusCode, STATE_CRITICAL); |
| 139 | } | ||
| 135 | } | 140 | } |
| 136 | 141 | ||
| 137 | printf(_("SWAP %s - %g%% free (%lluMiB out of %lluMiB) %s|%s\n"), state_text(data.statusCode), (HUNDRED_PERCENT - percent_used), | 142 | printf(_("SWAP %s - %g%% free (%lluMiB out of %lluMiB) %s|%s\n"), state_text(data.statusCode), (HUNDRED_PERCENT - percent_used), |
| @@ -196,7 +201,7 @@ swap_config_wrapper process_arguments(int argc, char **argv) { | |||
| 196 | */ | 201 | */ |
| 197 | size_t length; | 202 | size_t length; |
| 198 | length = strlen(optarg); | 203 | length = strlen(optarg); |
| 199 | conf_wrapper.config.warn.is_set = true; | 204 | conf_wrapper.config.warn_is_set = true; |
| 200 | 205 | ||
| 201 | if (optarg[length - 1] == '%') { | 206 | if (optarg[length - 1] == '%') { |
| 202 | /* It's percentage */ | 207 | /* It's percentage */ |
| @@ -226,7 +231,7 @@ swap_config_wrapper process_arguments(int argc, char **argv) { | |||
| 226 | */ | 231 | */ |
| 227 | size_t length; | 232 | size_t length; |
| 228 | length = strlen(optarg); | 233 | length = strlen(optarg); |
| 229 | conf_wrapper.config.crit.is_set = true; | 234 | conf_wrapper.config.crit_is_set = true; |
| 230 | 235 | ||
| 231 | if (optarg[length - 1] == '%') { | 236 | if (optarg[length - 1] == '%') { |
| 232 | /* It's percentage */ | 237 | /* It's percentage */ |
diff --git a/plugins/check_swap.d/check_swap.h b/plugins/check_swap.d/check_swap.h index e3e350c5..5d878989 100644 --- a/plugins/check_swap.d/check_swap.h +++ b/plugins/check_swap.d/check_swap.h | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | #endif | 8 | #endif |
| 9 | 9 | ||
| 10 | typedef struct { | 10 | typedef struct { |
| 11 | bool is_set; | ||
| 12 | bool is_percentage; | 11 | bool is_percentage; |
| 13 | uint64_t value; | 12 | uint64_t value; |
| 14 | } check_swap_threshold; | 13 | } check_swap_threshold; |
| @@ -28,7 +27,9 @@ typedef struct { | |||
| 28 | typedef struct { | 27 | typedef struct { |
| 29 | bool allswaps; | 28 | bool allswaps; |
| 30 | int no_swap_state; | 29 | int no_swap_state; |
| 30 | bool warn_is_set; | ||
| 31 | check_swap_threshold warn; | 31 | check_swap_threshold warn; |
| 32 | bool crit_is_set; | ||
| 32 | check_swap_threshold crit; | 33 | check_swap_threshold crit; |
| 33 | bool on_aix; | 34 | bool on_aix; |
| 34 | int conversion_factor; | 35 | int conversion_factor; |
diff --git a/plugins/check_swap.d/swap.c b/plugins/check_swap.d/swap.c index 6c94b33a..354efdbf 100644 --- a/plugins/check_swap.d/swap.c +++ b/plugins/check_swap.d/swap.c | |||
| @@ -11,8 +11,8 @@ swap_config swap_config_init(void) { | |||
| 11 | tmp.no_swap_state = STATE_CRITICAL; | 11 | tmp.no_swap_state = STATE_CRITICAL; |
| 12 | tmp.conversion_factor = SWAP_CONVERSION; | 12 | tmp.conversion_factor = SWAP_CONVERSION; |
| 13 | 13 | ||
| 14 | tmp.warn.is_set = false; | 14 | tmp.warn_is_set = false; |
| 15 | tmp.crit.is_set = false; | 15 | tmp.crit_is_set = false; |
| 16 | 16 | ||
| 17 | #ifdef _AIX | 17 | #ifdef _AIX |
| 18 | tmp.on_aix = true; | 18 | tmp.on_aix = true; |
