diff options
Diffstat (limited to 'plugins-root/check_icmp.d/config.h')
-rw-r--r-- | plugins-root/check_icmp.d/config.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/plugins-root/check_icmp.d/config.h b/plugins-root/check_icmp.d/config.h new file mode 100644 index 00000000..fc9dd5a6 --- /dev/null +++ b/plugins-root/check_icmp.d/config.h | |||
@@ -0,0 +1,111 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include "../../config.h" | ||
4 | #include "../../lib/states.h" | ||
5 | #include <stddef.h> | ||
6 | #include <netinet/in_systm.h> | ||
7 | #include <netinet/in.h> | ||
8 | #include <netinet/ip.h> | ||
9 | #include <netinet/ip6.h> | ||
10 | #include <netinet/ip_icmp.h> | ||
11 | #include <netinet/icmp6.h> | ||
12 | #include <arpa/inet.h> | ||
13 | #include <stdint.h> | ||
14 | #include "./check_icmp_helpers.h" | ||
15 | |||
16 | /* threshold structure. all values are maximum allowed, exclusive */ | ||
17 | typedef struct { | ||
18 | unsigned char pl; /* max allowed packet loss in percent */ | ||
19 | time_t rta; /* roundtrip time average, microseconds */ | ||
20 | double jitter; /* jitter time average, microseconds */ | ||
21 | double mos; /* MOS */ | ||
22 | double score; /* Score */ | ||
23 | } check_icmp_threshold; | ||
24 | |||
25 | /* the different modes of this program are as follows: | ||
26 | * MODE_RTA: send all packets no matter what (mimic check_icmp and check_ping) | ||
27 | * MODE_HOSTCHECK: Return immediately upon any sign of life | ||
28 | * In addition, sends packets to ALL addresses assigned | ||
29 | * to this host (as returned by gethostbyname() or | ||
30 | * gethostbyaddr() and expects one host only to be checked at | ||
31 | * a time. Therefore, any packet response what so ever will | ||
32 | * count as a sign of life, even when received outside | ||
33 | * crit.rta limit. Do not misspell any additional IP's. | ||
34 | * MODE_ALL: Requires packets from ALL requested IP to return OK (default). | ||
35 | * MODE_ICMP: Default Mode | ||
36 | */ | ||
37 | typedef enum { | ||
38 | MODE_RTA, | ||
39 | MODE_HOSTCHECK, | ||
40 | MODE_ALL, | ||
41 | MODE_ICMP, | ||
42 | } check_icmp_execution_mode; | ||
43 | |||
44 | typedef struct { | ||
45 | bool order_mode; | ||
46 | bool mos_mode; | ||
47 | bool rta_mode; | ||
48 | bool pl_mode; | ||
49 | bool jitter_mode; | ||
50 | bool score_mode; | ||
51 | } check_icmp_mode_switches; | ||
52 | |||
53 | typedef struct { | ||
54 | check_icmp_mode_switches modes; | ||
55 | |||
56 | int min_hosts_alive; | ||
57 | check_icmp_threshold crit; | ||
58 | check_icmp_threshold warn; | ||
59 | |||
60 | unsigned long ttl; | ||
61 | unsigned short icmp_data_size; | ||
62 | unsigned short icmp_pkt_size; | ||
63 | time_t pkt_interval; | ||
64 | time_t target_interval; | ||
65 | unsigned short number_of_packets; | ||
66 | |||
67 | char *source_ip; | ||
68 | bool need_v4; | ||
69 | bool need_v6; | ||
70 | |||
71 | uint16_t sender_id; // PID of the main process, which is used as an ID in packets | ||
72 | |||
73 | check_icmp_execution_mode mode; | ||
74 | |||
75 | unsigned short number_of_targets; | ||
76 | ping_target *targets; | ||
77 | |||
78 | unsigned short number_of_hosts; | ||
79 | check_icmp_target_container *hosts; | ||
80 | } check_icmp_config; | ||
81 | |||
82 | check_icmp_config check_icmp_config_init(); | ||
83 | |||
84 | /* the data structure */ | ||
85 | typedef struct icmp_ping_data { | ||
86 | struct timeval stime; /* timestamp (saved in protocol struct as well) */ | ||
87 | unsigned short ping_id; | ||
88 | } icmp_ping_data; | ||
89 | |||
90 | #define MAX_IP_PKT_SIZE 65536 /* (theoretical) max IP packet size */ | ||
91 | #define IP_HDR_SIZE 20 | ||
92 | #define MAX_PING_DATA (MAX_IP_PKT_SIZE - IP_HDR_SIZE - ICMP_MINLEN) | ||
93 | #define MIN_PING_DATA_SIZE sizeof(struct icmp_ping_data) | ||
94 | #define DEFAULT_PING_DATA_SIZE (MIN_PING_DATA_SIZE + 44) | ||
95 | |||
96 | /* 80 msec packet interval by default */ | ||
97 | #define DEFAULT_PKT_INTERVAL 80000 | ||
98 | #define DEFAULT_TARGET_INTERVAL 0 | ||
99 | |||
100 | #define DEFAULT_WARN_RTA 200000 | ||
101 | #define DEFAULT_CRIT_RTA 500000 | ||
102 | #define DEFAULT_WARN_PL 40 | ||
103 | #define DEFAULT_CRIT_PL 80 | ||
104 | |||
105 | #define DEFAULT_TIMEOUT 10 | ||
106 | #define DEFAULT_TTL 64 | ||
107 | |||
108 | #define DEFAULT_NUMBER_OF_PACKETS 5 | ||
109 | |||
110 | #define PACKET_BACKOFF_FACTOR 1.5 | ||
111 | #define TARGET_BACKOFF_FACTOR 1.5 | ||