summaryrefslogtreecommitdiffstats
path: root/plugins/check_swap.d/check_swap.h
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-12-19 11:18:51 +0100
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-12-20 10:02:47 +0100
commit2dec5182c508bd3cc286b4649836ead51aec50ef (patch)
tree682dbf85ed7452f3101a200d925991c281b7d465 /plugins/check_swap.d/check_swap.h
parent2289d094ae00a52f96a038cb7ca8bb350aec483a (diff)
downloadmonitoring-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.h45
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
10typedef struct {
11 bool is_percentage;
12 uint64_t value;
13} threshold;
14
15typedef 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
21typedef struct {
22 int errorcode;
23 int statusCode;
24 swap_metrics metrics;
25} swap_result;
26
27typedef 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
37swap_config swap_config_init();
38
39swap_result get_swap_data(swap_config config);
40swap_result getSwapFromProcMeminfo(swap_config config, char path_to_proc_meminfo[]);
41swap_result getSwapFromSwapCommand(swap_config config, const char swap_command[], const char swap_format[]);
42swap_result getSwapFromSwapctl_BSD(swap_config config);
43swap_result getSwapFromSwap_SRV4(swap_config config);
44
45#endif