summaryrefslogtreecommitdiffstats
path: root/plugins/check_swap.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_swap.c')
-rw-r--r--plugins/check_swap.c35
1 files changed, 20 insertions, 15 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 */