summaryrefslogtreecommitdiffstats
path: root/plugins-root/check_icmp.d/config.h
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-05-04 01:42:52 +0200
committerLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-05-04 01:42:52 +0200
commit5a6adcb7db497fba7b89471a6d58dba80330ff4a (patch)
tree8db791660766ac2532105e894b1c73eee56a15aa /plugins-root/check_icmp.d/config.h
parenteafee9c3f91879afa82749fa1d8cd2b0b53a5d5c (diff)
downloadmonitoring-plugins-5a6adcb7db497fba7b89471a6d58dba80330ff4a.tar.gz
WIP - check_icmp refactor 2
Diffstat (limited to 'plugins-root/check_icmp.d/config.h')
-rw-r--r--plugins-root/check_icmp.d/config.h102
1 files changed, 102 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..deae9bec
--- /dev/null
+++ b/plugins-root/check_icmp.d/config.h
@@ -0,0 +1,102 @@
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 "./check_icmp_helpers.h"
14
15/* threshold structure. all values are maximum allowed, exclusive */
16typedef struct threshold {
17 unsigned char pl; /* max allowed packet loss in percent */
18 unsigned int rta; /* roundtrip time average, microseconds */
19 double jitter; /* jitter time average, microseconds */
20 double mos; /* MOS */
21 double score; /* Score */
22} threshold;
23
24typedef struct {
25 char *source_ip;
26
27 bool order_mode;
28 bool mos_mode;
29 bool rta_mode;
30 bool pl_mode;
31 bool jitter_mode;
32 bool score_mode;
33
34 int min_hosts_alive;
35 unsigned short icmp_data_size;
36 unsigned short icmp_pkt_size;
37 unsigned int pkt_interval;
38 unsigned int target_interval;
39 threshold crit;
40 threshold warn;
41 pid_t pid;
42
43 int mode;
44 unsigned long ttl;
45
46 unsigned short packets;
47
48 unsigned short number_of_targets;
49 ping_target *targets;
50
51 unsigned short number_of_hosts;
52 check_icmp_target_container *hosts;
53} check_icmp_config;
54
55check_icmp_config check_icmp_config_init();
56
57/* the data structure */
58typedef struct icmp_ping_data {
59 struct timeval stime; /* timestamp (saved in protocol struct as well) */
60 unsigned short ping_id;
61} icmp_ping_data;
62
63#define MAX_IP_PKT_SIZE 65536 /* (theoretical) max IP packet size */
64#define IP_HDR_SIZE 20
65#define MAX_PING_DATA (MAX_IP_PKT_SIZE - IP_HDR_SIZE - ICMP_MINLEN)
66#define MIN_PING_DATA_SIZE sizeof(struct icmp_ping_data)
67#define DEFAULT_PING_DATA_SIZE (MIN_PING_DATA_SIZE + 44)
68
69/* 80 msec packet interval by default */
70#define DEFAULT_PKT_INTERVAL 80000
71#define DEFAULT_TARGET_INTERVAL 0
72
73#define DEFAULT_WARN_RTA 200000
74#define DEFAULT_CRIT_RTA 500000
75#define DEFAULT_WARN_PL 40
76#define DEFAULT_CRIT_PL 80
77
78#define DEFAULT_TIMEOUT 10
79#define DEFAULT_TTL 64
80
81/* the different modes of this program are as follows:
82 * MODE_RTA: send all packets no matter what (mimic check_icmp and check_ping)
83 * MODE_HOSTCHECK: Return immediately upon any sign of life
84 * In addition, sends packets to ALL addresses assigned
85 * to this host (as returned by gethostbyname() or
86 * gethostbyaddr() and expects one host only to be checked at
87 * a time. Therefore, any packet response what so ever will
88 * count as a sign of life, even when received outside
89 * crit.rta limit. Do not misspell any additional IP's.
90 * MODE_ALL: Requires packets from ALL requested IP to return OK (default).
91 * MODE_ICMP: implement something similar to check_icmp (MODE_RTA without
92 * tcp and udp args does this)
93 */
94#define MODE_RTA 0
95#define MODE_HOSTCHECK 1
96#define MODE_ALL 2
97#define MODE_ICMP 3
98
99#define DEFAULT_NUMBER_OF_PACKETS 5
100
101#define PACKET_BACKOFF_FACTOR 1.5
102#define TARGET_BACKOFF_FACTOR 1.5