summaryrefslogtreecommitdiffstats
path: root/plugins/check_swap.d/check_swap.h
blob: 99039b21815c08102b9ad9a4e01684e75a3f55d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once

#include "../common.h"

#ifndef SWAP_CONVERSION
#	define SWAP_CONVERSION 1
#endif

typedef struct {
	bool is_percentage;
	uint64_t value;
} check_swap_threshold;

typedef struct {
	unsigned long long free;  // Free swap in Bytes!
	unsigned long long used;  // Used swap in Bytes!
	unsigned long long total; // Total swap size, you guessed it, in Bytes!
} swap_metrics;

typedef struct {
	int errorcode;
	int statusCode;
	swap_metrics metrics;
} swap_result;

typedef struct {
	bool allswaps;
	int no_swap_state;
	bool warn_is_set;
	check_swap_threshold warn;
	bool crit_is_set;
	check_swap_threshold crit;
	bool on_aix;
	int conversion_factor;
} swap_config;

swap_config swap_config_init(void);

swap_result get_swap_data(swap_config config);
swap_result getSwapFromProcMeminfo(char path_to_proc_meminfo[]);
swap_result getSwapFromSwapCommand(swap_config config, const char swap_command[], const char swap_format[]);
swap_result getSwapFromSwapctl_BSD(swap_config config);
swap_result getSwapFromSwap_SRV4(swap_config config);