diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-12-19 11:18:51 +0100 |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-12-20 10:02:47 +0100 |
commit | 2dec5182c508bd3cc286b4649836ead51aec50ef (patch) | |
tree | 682dbf85ed7452f3101a200d925991c281b7d465 /plugins/check_swap.d/check_swap.h | |
parent | 2289d094ae00a52f96a038cb7ca8bb350aec483a (diff) | |
download | monitoring-plugins-2dec5182c508bd3cc286b4649836ead51aec50ef.tar.gz |
check_swap: refactor to improve readability
Diffstat (limited to 'plugins/check_swap.d/check_swap.h')
-rw-r--r-- | plugins/check_swap.d/check_swap.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/plugins/check_swap.d/check_swap.h b/plugins/check_swap.d/check_swap.h new file mode 100644 index 00000000..bad52917 --- /dev/null +++ b/plugins/check_swap.d/check_swap.h | |||
@@ -0,0 +1,45 @@ | |||
1 | #ifndef CHECK_SWAP_H | ||
2 | #define CHECK_SWAP_H | ||
3 | |||
4 | #include "../common.h" | ||
5 | |||
6 | #ifndef SWAP_CONVERSION | ||
7 | #define SWAP_CONVERSION 1 | ||
8 | #endif | ||
9 | |||
10 | typedef struct { | ||
11 | bool is_percentage; | ||
12 | uint64_t value; | ||
13 | } threshold; | ||
14 | |||
15 | typedef struct { | ||
16 | unsigned long long free; // Free swap in Bytes! | ||
17 | unsigned long long used; // Used swap in Bytes! | ||
18 | unsigned long long total; // Total swap size, you guessed it, in Bytes! | ||
19 | } swap_metrics; | ||
20 | |||
21 | typedef struct { | ||
22 | int errorcode; | ||
23 | int statusCode; | ||
24 | swap_metrics metrics; | ||
25 | } swap_result; | ||
26 | |||
27 | typedef struct { | ||
28 | int verbose; | ||
29 | bool allswaps; | ||
30 | int no_swap_state; | ||
31 | threshold warn; | ||
32 | threshold crit; | ||
33 | bool on_aix; | ||
34 | int conversion_factor; | ||
35 | } swap_config; | ||
36 | |||
37 | swap_config swap_config_init(); | ||
38 | |||
39 | swap_result get_swap_data(swap_config config); | ||
40 | swap_result getSwapFromProcMeminfo(swap_config config, char path_to_proc_meminfo[]); | ||
41 | swap_result getSwapFromSwapCommand(swap_config config, const char swap_command[], const char swap_format[]); | ||
42 | swap_result getSwapFromSwapctl_BSD(swap_config config); | ||
43 | swap_result getSwapFromSwap_SRV4(swap_config config); | ||
44 | |||
45 | #endif | ||