From 9679551b20acdc8306a11e6c7d9dbc4f15e90967 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 10 Nov 2024 10:37:19 +0100 Subject: check_swap: stricter error handling --- plugins/check_swap.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'plugins/check_swap.c') 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 @@ * *****************************************************************************/ +#include "common.h" #ifdef HAVE_DECL_SWAPCTL # ifdef HAVE_SYS_PARAM_H # include @@ -83,6 +84,11 @@ int main(int argc, char **argv) { swap_result data = get_swap_data(config); + if (data.errorcode != STATE_OK) { + puts("SWAP UNKNOWN - Failed to retrieve Swap usage"); + exit(STATE_UNKNOWN); + } + double percent_used; /* if total_swap_mb == 0, let's not divide by 0 */ if (data.metrics.total != 0) { -- cgit v1.2.3-74-g34f1