diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2024-11-10 10:37:19 +0100 |
---|---|---|
committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2024-11-10 10:37:19 +0100 |
commit | 9679551b20acdc8306a11e6c7d9dbc4f15e90967 (patch) | |
tree | 2d8a340dd0df04284bc4d3dcb6e27cb4a7461de7 /plugins/check_swap.c | |
parent | 77c0913f7577d20fbb8a8ead522199cd079ea122 (diff) | |
download | monitoring-plugins-9679551b20acdc8306a11e6c7d9dbc4f15e90967.tar.gz |
check_swap: stricter error handling
Diffstat (limited to 'plugins/check_swap.c')
-rw-r--r-- | plugins/check_swap.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/plugins/check_swap.c b/plugins/check_swap.c index 94f41a55..e0c246db 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c | |||
@@ -27,6 +27,7 @@ | |||
27 | * | 27 | * |
28 | *****************************************************************************/ | 28 | *****************************************************************************/ |
29 | 29 | ||
30 | #include "common.h" | ||
30 | #ifdef HAVE_DECL_SWAPCTL | 31 | #ifdef HAVE_DECL_SWAPCTL |
31 | # ifdef HAVE_SYS_PARAM_H | 32 | # ifdef HAVE_SYS_PARAM_H |
32 | # include <sys/param.h> | 33 | # include <sys/param.h> |
@@ -83,6 +84,11 @@ int main(int argc, char **argv) { | |||
83 | 84 | ||
84 | swap_result data = get_swap_data(config); | 85 | swap_result data = get_swap_data(config); |
85 | 86 | ||
87 | if (data.errorcode != STATE_OK) { | ||
88 | puts("SWAP UNKNOWN - Failed to retrieve Swap usage"); | ||
89 | exit(STATE_UNKNOWN); | ||
90 | } | ||
91 | |||
86 | double percent_used; | 92 | double percent_used; |
87 | /* if total_swap_mb == 0, let's not divide by 0 */ | 93 | /* if total_swap_mb == 0, let's not divide by 0 */ |
88 | if (data.metrics.total != 0) { | 94 | if (data.metrics.total != 0) { |