From 487d64a4e4122ca7b389b5e26b6cdf156c877c04 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= <glen@delfi.ee>
Date: Thu, 3 Mar 2016 21:23:49 +0200
Subject: allow checking 0-sized resource (ex. IPC$)

patch by Marek Marczykowski <marmarek@staszic.waw.pl>

diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl
index 9899226..4e46397 100755
--- a/plugins-scripts/check_disk_smb.pl
+++ b/plugins-scripts/check_disk_smb.pl
@@ -212,7 +212,8 @@ if (/\s*(\d*) blocks of size (\d*)\. (\d*) blocks available/) {
 	my ($total_bytes) = $1 * $2;
 	my ($occupied_bytes) = $1 * $2 - $avail_bytes;
 	my ($avail) = $avail_bytes/1024;
-	my ($capper) = int(($3/$1)*100);
+	my ($capper);
+	if ($1!=0) { $capper = int(($3/$1)*100) } else { $capper=100 };
 	my ($mountpt) = "\\\\$host\\$share";
 
 	# TODO : why is the kB the standard unit for args ?
-- 
cgit v0.10-9-g596f


From ab7d056ee36c064ae0a75fb0029cb8cf20df5b66 Mon Sep 17 00:00:00 2001
From: root <dirty.ren@gmail.com>
Date: Fri, 18 Aug 2017 16:13:30 -0300
Subject: Add support to Jitter, MOS and Score


diff --git a/lib/utils_base.c b/lib/utils_base.c
index 3822bcf..8a03d09 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -300,6 +300,19 @@ char *np_escaped_string (const char *string) {
 
 int np_check_if_root(void) { return (geteuid() == 0); }
 
+int np_warn_if_not_root(void) {
+        int status = np_check_if_root();
+        if(!status) {
+                printf(_("Warning: "));
+                printf(_("This plugin must be either run as root or setuid root.\n"));
+                printf(_("To run as root, you can use a tool like sudo.\n"));
+                printf(_("To set the setuid permissions, use the command:\n"));
+                /* XXX could we use something like progname? */
+                printf("\tchmod u+s yourpluginfile\n");
+        }
+        return status;
+}
+
 /*
  * Extract the value from key/value pairs, or return NULL. The value returned
  * can be free()ed.
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 4098874..d68c4e0 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -42,6 +42,10 @@ char *progname;
 const char *copyright = "2005-2008";
 const char *email = "devel@monitoring-plugins.org";
 
+#ifdef __sun
+#define _XPG4_2
+#endif
+
 /** Monitoring Plugins basic includes */
 #include "common.h"
 #include "netutils.h"
@@ -120,18 +124,35 @@ typedef struct rta_host {
 	unsigned char icmp_type, icmp_code; /* type and code from errors */
 	unsigned short flags;        /* control/status flags */
 	double rta;                  /* measured RTA */
+	int			rta_status;
 	double rtmax;                /* max rtt */
 	double rtmin;                /* min rtt */
+	double jitter;                  /* measured jitter */
+	int			jitter_status;
+	double jitter_max;                /* jitter rtt */
+	double jitter_min;                /* jitter rtt */
+	double EffectiveLatency;
+	double mos;									/* Mean opnion score */
+	int			mos_status;
+	double	score;							/* score */
+	int			score_status;
+	u_int last_tdiff;
+	u_int	last_icmp_seq;        /* Last ICMP_SEQ to check out of order pkts */
 	unsigned char pl;            /* measured packet loss */
+	int			pl_status;
 	struct rta_host *next;       /* linked list */
+	int	order_status;
 } rta_host;
 
 #define FLAG_LOST_CAUSE 0x01  /* decidedly dead target. */
 
 /* threshold structure. all values are maximum allowed, exclusive */
 typedef struct threshold {
-	unsigned char pl;    /* max allowed packet loss in percent */
-	unsigned int rta;  /* roundtrip time average, microseconds */
+	unsigned char pl;			/* max allowed packet loss in percent */
+	unsigned int rta;			/* roundtrip time average, microseconds */
+	double jitter;	/* jitter time average, microseconds */
+	double mos;			/* MOS */
+	double score;		/* Score */
 } threshold;
 
 /* the data structure */
@@ -187,6 +208,7 @@ static int wait_for_reply(int, u_int);
 static int recvfrom_wto(int, void *, unsigned int, struct sockaddr *, u_int *, struct timeval*);
 static int send_icmp_ping(int, struct rta_host *);
 static int get_threshold(char *str, threshold *th);
+static int get_threshold2(char *str, threshold *, threshold *, int type);
 static void run_checks(void);
 static void set_source_ip(char *);
 static int add_target(char *);
@@ -223,6 +245,12 @@ static unsigned int warn_down = 1, crit_down = 1; /* host down threshold values
 static int min_hosts_alive = -1;
 float pkt_backoff_factor = 1.5;
 float target_backoff_factor = 1.5;
+int	rta_mode=0;
+int	pl_mode=0;
+int	jitter_mode=0;
+int	score_mode=0;
+int	mos_mode=0;
+int	order_mode=0;
 
 /** code start **/
 static void
@@ -378,6 +406,9 @@ main(int argc, char **argv)
 	int icmp_sockerrno, udp_sockerrno, tcp_sockerrno;
 	int result;
 	struct rta_host *host;
+#ifdef HAVE_SIGACTION
+	struct sigaction sig_action;
+#endif
 #ifdef SO_TIMESTAMP
 	int on = 1;
 #endif
@@ -386,6 +417,9 @@ main(int argc, char **argv)
 	bindtextdomain (PACKAGE, LOCALEDIR);
 	textdomain (PACKAGE);
 
+	/* print a helpful error message if geteuid != 0 */
+	np_warn_if_not_root();
+
 	/* we only need to be setsuid when we get the sockets, so do
 	 * that before pointer magic (esp. on network data) */
 	icmp_sockerrno = udp_sockerrno = tcp_sockerrno = sockets = 0;
@@ -430,10 +464,19 @@ main(int argc, char **argv)
 	table = NULL;
 
 	mode = MODE_RTA;
+	/* Default critical thresholds */
 	crit.rta = 500000;
 	crit.pl = 80;
+	crit.jitter = 50;
+	crit.mos= 3;
+	crit.score=70;
+	/* Default warning thresholds */
 	warn.rta = 200000;
 	warn.pl = 40;
+	warn.jitter = 40;
+	warn.mos= 3.5;
+	warn.score=80;
+	
 	protocols = HAVE_ICMP | HAVE_UDP | HAVE_TCP;
 	pkt_interval = 80000;  /* 80 msec packet interval by default */
 	packets = 5;
@@ -469,14 +512,14 @@ main(int argc, char **argv)
 
 	/* parse the arguments */
 	for(i = 1; i < argc; i++) {
-		while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:s:i:b:I:l:m:")) != EOF) {
-			unsigned short size;
+		while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:s:i:b:I:l:m:P:R:J:S:M:O")) != EOF) {
+			long size;
 			switch(arg) {
 			case 'v':
 				debug++;
 				break;
 			case 'b':
-				size = (unsigned short)strtol(optarg,NULL,0);
+				size = strtol(optarg,NULL,0);
 				if (size >= (sizeof(struct icmp) + sizeof(struct icmp_ping_data)) &&
 				    size < MAX_PING_DATA) {
 					icmp_data_size = size;
@@ -526,11 +569,34 @@ main(int argc, char **argv)
 				break;
 			case 'V': /* version */
 				print_revision (progname, NP_VERSION);
-				exit (STATE_UNKNOWN);
+				exit (STATE_OK);
 			case 'h': /* help */
 				print_help ();
-				exit (STATE_UNKNOWN);
-			}
+				exit (STATE_OK);
+			case 'R': /* RTA mode */
+				get_threshold2(optarg, &warn, &crit,1);
+        rta_mode=1;
+        break;
+			case 'P': /* packet loss mode */
+				get_threshold2(optarg, &warn, &crit,2);
+        pl_mode=1;
+        break;
+			case 'J': /* packet loss mode */
+				get_threshold2(optarg, &warn, &crit,3);
+      	jitter_mode=1;
+      	break;
+			case 'M': /* MOS mode */
+				get_threshold2(optarg, &warn, &crit,4);
+        mos_mode=1;
+        break;
+			case 'S': /* score mode */
+				get_threshold2(optarg, &warn, &crit,5);
+        score_mode=1;
+        break;
+			case 'O': /* out of order mode */
+        order_mode=1;
+        break;
+      }
 		}
 	}
 
@@ -579,11 +645,25 @@ main(int argc, char **argv)
 	if(warn.pl > crit.pl) warn.pl = crit.pl;
 	if(warn.rta > crit.rta) warn.rta = crit.rta;
 	if(warn_down > crit_down) crit_down = warn_down;
-
+	if(warn.jitter > crit.jitter) crit.jitter = warn.jitter;
+	if(warn.mos < crit.mos) warn.mos = crit.mos;
+	if(warn.score < crit.score) warn.score = crit.score;
+
+#ifdef HAVE_SIGACTION
+	sig_action.sa_sigaction = NULL;
+	sig_action.sa_handler = finish;
+	sigfillset(&sig_action.sa_mask);
+	sig_action.sa_flags = SA_NODEFER|SA_RESTART;
+	sigaction(SIGINT, &sig_action, NULL);
+	sigaction(SIGHUP, &sig_action, NULL);
+	sigaction(SIGTERM, &sig_action, NULL);
+	sigaction(SIGALRM, &sig_action, NULL);
+#else /* HAVE_SIGACTION */
 	signal(SIGINT, finish);
 	signal(SIGHUP, finish);
 	signal(SIGTERM, finish);
 	signal(SIGALRM, finish);
+#endif /* HAVE_SIGACTION */
 	if(debug) printf("Setting alarm timeout to %u seconds\n", timeout);
 	alarm(timeout);
 
@@ -608,7 +688,7 @@ main(int argc, char **argv)
 		if(max_completion_time > (u_int)timeout * 1000000) {
 			printf("max_completion_time: %llu  timeout: %u\n",
 				   max_completion_time, timeout);
-			printf("Timeout must be at least %llu\n",
+			printf("Timout must be at lest %llu\n",
 				   max_completion_time / 1000000 + 1);
 		}
 	}
@@ -633,7 +713,7 @@ main(int argc, char **argv)
 	}
 
 	host = list;
-	table = malloc(sizeof(struct rta_host **) * targets);
+	table = malloc(sizeof(struct rta_host *) * targets);
 	i = 0;
 	while(host) {
 		host->id = i*packets;
@@ -671,9 +751,9 @@ run_checks()
 
 			/* we're still in the game, so send next packet */
 			(void)send_icmp_ping(icmp_sock, table[t]);
-			result = wait_for_reply(icmp_sock, target_interval);
+			(void)wait_for_reply(icmp_sock, target_interval);
 		}
-		result = wait_for_reply(icmp_sock, pkt_interval * targets);
+		(void)wait_for_reply(icmp_sock, pkt_interval * targets);
 	}
 
 	if(icmp_pkts_en_route && targets_alive) {
@@ -693,7 +773,7 @@ run_checks()
 		 * haven't yet */
 		if(debug) printf("Waiting for %u micro-seconds (%0.3f msecs)\n",
 						 final_wait, (float)final_wait / 1000);
-		result = wait_for_reply(icmp_sock, final_wait);
+		(void)wait_for_reply(icmp_sock, final_wait);
 	}
 }
 
@@ -714,6 +794,7 @@ wait_for_reply(int sock, u_int t)
 	struct icmp_ping_data data;
 	struct timeval wait_start, now;
 	u_int tdiff, i, per_pkt_wait;
+	double jitter_tmp;
 
 	/* if we can't listen or don't have anything to listen to, just return */
 	if(!t || !icmp_pkts_en_route) return 0;
@@ -792,12 +873,43 @@ wait_for_reply(int sock, u_int t)
 		host = table[ntohs(icp.icmp_seq)/packets];
 		tdiff = get_timevaldiff(&data.stime, &now);
 
+		if (host->last_tdiff>0) {
+			/* Calculate jitter */
+			if (host->last_tdiff > tdiff) {
+				jitter_tmp = host->last_tdiff - tdiff;
+			}
+			else {
+				jitter_tmp = tdiff - host->last_tdiff;
+			}
+			if (host->jitter==0) {
+				host->jitter=jitter_tmp;
+				host->jitter_max=jitter_tmp;
+				host->jitter_min=jitter_tmp;
+			}
+			else {
+				host->jitter+=jitter_tmp;
+				if (jitter_tmp < host->jitter_min)
+					host->jitter_min=jitter_tmp;
+				if (jitter_tmp > host->jitter_max)
+					host->jitter_max=jitter_tmp;
+			}
+			
+			/* Check if packets in order */
+			if (host->last_icmp_seq >= icp.icmp_seq)
+				host->order_status=STATE_CRITICAL;
+		}
+		host->last_tdiff=tdiff;
+		
+		host->last_icmp_seq=icp.icmp_seq;
+		
+		//printf("%d tdiff %d host->jitter %u  host->last_tdiff %u\n", icp.icmp_seq, tdiff, host->jitter, host->last_tdiff);
+		
 		host->time_waited += tdiff;
 		host->icmp_recv++;
 		icmp_recv++;
-		if (tdiff > host->rtmax)
+		if (tdiff > (int)host->rtmax)
 			host->rtmax = tdiff;
-		if (tdiff < host->rtmin)
+		if (tdiff < (int)host->rtmin)
 			host->rtmin = tdiff;
 
 		if(debug) {
@@ -945,8 +1057,10 @@ recvfrom_wto(int sock, void *buf, unsigned int len, struct sockaddr *saddr,
 	hdr.msg_namelen = slen;
 	hdr.msg_iov = &iov;
 	hdr.msg_iovlen = 1;
+#ifdef HAVE_MSGHDR_MSG_CONTROL
 	hdr.msg_control = ans_data;
 	hdr.msg_controllen = sizeof(ans_data);
+#endif
 
 	ret = recvmsg(sock, &hdr, 0);
 #ifdef SO_TIMESTAMP
@@ -975,6 +1089,8 @@ finish(int sig)
 	{"OK", "WARNING", "CRITICAL", "UNKNOWN", "DEPENDENT"};
 	int hosts_ok = 0;
 	int hosts_warn = 0;
+	double R;
+	int	shown=0;
 
 	alarm(0);
 	if(debug > 1) printf("finish(%d) called\n", sig);
@@ -990,6 +1106,7 @@ finish(int sig)
 	}
 
 	/* iterate thrice to calculate values, give output, and print perfparse */
+	status=STATE_OK;
 	host = list;
 	while(host) {
 		if(!host->icmp_recv) {
@@ -1005,19 +1122,104 @@ finish(int sig)
 			pl = ((host->icmp_sent - host->icmp_recv) * 100) / host->icmp_sent;
 			rta = (double)host->time_waited / host->icmp_recv;
 		}
+		if (host->icmp_recv>1) {
+			host->jitter=(host->jitter / (host->icmp_recv - 1)/1000);
+			host->EffectiveLatency = (rta/1000) + host->jitter * 2 + 10;
+			if (host->EffectiveLatency < 160)
+			   R = 93.2 - (host->EffectiveLatency / 40);
+			else
+			   R = 93.2 - ((host->EffectiveLatency - 120) / 10);
+			R = R - (pl * 2.5);
+			if (R<0) R=0;
+			host->score = R;
+			host->mos= 1 + ((0.035) * R) + ((.000007) * R * (R-60) * (100-R));
+		}
+		else {
+			host->jitter=0;
+			host->jitter_min=0;
+			host->jitter_max=0;
+			host->mos=0;
+		}
 		host->pl = pl;
 		host->rta = rta;
-		if(pl >= crit.pl || rta >= crit.rta) {
-			status = STATE_CRITICAL;
+
+		/* if no new mode selected, use old schema */
+		if (!rta_mode && !pl_mode && !jitter_mode && !score_mode && !mos_mode && !order_mode) {
+			rta_mode=1;
+			pl_mode=1;
 		}
-		else if(!status && (pl >= warn.pl || rta >= warn.rta)) {
-			status = STATE_WARNING;
-			hosts_warn++;
+
+		/* Check which mode is on and do the warn / Crit stuff */
+		if (rta_mode) {
+			if(rta >= crit.rta) {
+				status = STATE_CRITICAL;
+				host->rta_status=STATE_CRITICAL;
+			}
+			else if(status!=STATE_CRITICAL && (rta >= warn.rta)) {
+				status = STATE_WARNING;
+				hosts_warn++;
+				host->rta_status=STATE_WARNING;
+			}
+			else {
+				hosts_ok++;
+			}
 		}
-		else {
-			hosts_ok++;
+		if (pl_mode) {
+			if(pl >= crit.pl) {
+				status = STATE_CRITICAL;
+				host->pl_status=STATE_CRITICAL;
+			}
+			else if(status!=STATE_CRITICAL && (pl >= warn.pl)) {
+				status = STATE_WARNING;
+				hosts_warn++;
+				host->pl_status=STATE_WARNING;
+			}
+			else {
+				hosts_ok++;
+			}
+		}
+		if (jitter_mode) {
+			if(host->jitter >= crit.jitter) {
+				status = STATE_CRITICAL;
+				host->jitter_status=STATE_CRITICAL;
+			}
+			else if(status!=STATE_CRITICAL && (host->jitter >= warn.jitter)) {
+				status = STATE_WARNING;
+				hosts_warn++;
+				host->jitter_status=STATE_WARNING;
+			}
+			else {
+				hosts_ok++;
+			}
+		}
+		if (mos_mode) {
+			if(host->mos <= crit.mos) {
+				status = STATE_CRITICAL;
+				host->mos_status=STATE_CRITICAL;
+			}
+			else if(status!=STATE_CRITICAL && (host->mos <= warn.mos)) {
+				status = STATE_WARNING;
+				hosts_warn++;
+				host->mos_status=STATE_WARNING;
+			}
+			else {
+				hosts_ok++;
+			}
+		}
+		if (score_mode) {
+			if(host->score <= crit.score) {
+				status = STATE_CRITICAL;
+				host->score_status=STATE_CRITICAL;
+			}
+			else if(status!=STATE_CRITICAL && (host->score <= warn.score)) {
+				status = STATE_WARNING;
+				score_mode++;
+				host->score_status=STATE_WARNING;
+			}
+			else {
+				hosts_ok++;
+			}
 		}
-
 		host = host->next;
 	}
 	/* this is inevitable */
@@ -1027,9 +1229,10 @@ finish(int sig)
 		else if((hosts_ok + hosts_warn) >= min_hosts_alive) status = STATE_WARNING;
 	}
 	printf("%s - ", status_string[status]);
-
+	
 	host = list;
 	while(host) {
+		
 		if(debug) puts("");
 		if(i) {
 			if(i < targets) printf(" :: ");
@@ -1038,6 +1241,8 @@ finish(int sig)
 		i++;
 		if(!host->icmp_recv) {
 			status = STATE_CRITICAL;
+			host->rtmin=0;
+			host->jitter_min=0;
 			if(host->flags & FLAG_LOST_CAUSE) {
 				printf("%s: %s @ %s. rta nan, lost %d%%",
 					   host->name,
@@ -1050,26 +1255,92 @@ finish(int sig)
 			}
 		}
 		else {	/* !icmp_recv */
-			printf("%s: rta %0.3fms, lost %u%%",
-				   host->name, host->rta / 1000, host->pl);
+			printf("%s: ", host->name);
+			/* rta text output */
+			if (rta_mode) {
+				shown=1;
+				if (status == STATE_OK)
+					printf("%s rta %0.3fms",(shown==1)?",":"", host->rta / 1000);
+				else if (status==STATE_WARNING && host->rta_status==status)
+					printf("%s rta %0.3fms > %0.3fms",(shown==1)?",":"", (float)host->rta / 1000, (float)warn.rta/1000);
+				else if (status==STATE_CRITICAL && host->rta_status==status)
+					printf("%s rta %0.3fms > %0.3fms",(shown==1)?",":"", (float)host->rta / 1000, (float)crit.rta/1000);
+			}
+			/* pl text output */
+			if (pl_mode) {
+				shown=1;
+				if (status == STATE_OK)
+					printf("%s lost %u%%",(shown==1)?",":"", host->pl);
+				else if (status==STATE_WARNING && host->pl_status==status)
+					printf("%s lost %u%% > %u%%",(shown==1)?",":"", host->pl, warn.pl);
+				else if (status==STATE_CRITICAL && host->pl_status==status)
+					printf("%s lost %u%% > %u%%",(shown==1)?",":"", host->pl, crit.pl);
+			}
+			/* jitter text output */
+			if (jitter_mode) {
+				shown=1;
+				if (status == STATE_OK)
+					printf("%s jitter %0.3fms",(shown==1)?",":"", (float)host->jitter);
+				else if (status==STATE_WARNING && host->jitter_status==status)
+					printf("%s jitter %0.3fms > %0.3fms",(shown==1)?",":"", (float)host->jitter, warn.jitter);
+				else if (status==STATE_CRITICAL && host->jitter_status==status)
+					printf("%s jitter %0.3fms > %0.3fms",(shown==1)?",":"", (float)host->jitter, crit.jitter);
+			}
+			/* mos text output */
+			if (mos_mode) {
+				shown=1;
+				if (status == STATE_OK)
+					printf("%s MOS %0.1f",(shown==1)?",":"", (float)host->mos);
+				else if (status==STATE_WARNING && host->mos_status==status)
+					printf("%s MOS %0.1f < %0.1f",(shown==1)?",":"", (float)host->mos, (float)warn.mos);
+				else if (status==STATE_CRITICAL && host->mos_status==status)
+					printf("%s MOS %0.1f < %0.1f",(shown==1)?",":"", (float)host->mos, (float)crit.mos);
+			}
+			/* score text output */
+			if (score_mode) {
+				shown=1;
+				if (status == STATE_OK)
+					printf("%s Score %u",(shown==1)?",":"", (int)host->score);
+				else if (status==STATE_WARNING && host->score_status==status )
+					printf("%s Score %u < %u",(shown==1)?",":"", (int)host->score, (int)warn.score);
+				else if (status==STATE_CRITICAL && host->score_status==status )
+					printf("%s Score %u < %u",(shown==1)?",":"", (int)host->score, (int)crit.score);
+			}
+			/* order statis text output */
+			if (order_mode) {
+				shown=1;
+				if (status == STATE_OK)
+					printf("%s Packets in order",(shown==1)?",":"");
+				else if (status==STATE_CRITICAL && host->order_status==status)
+					printf("%s Packets out of order",(shown==1)?",":"");
+			}
 		}
-
 		host = host->next;
 	}
 
 	/* iterate once more for pretty perfparse output */
-	printf("|");
+	if (!(!rta_mode && !pl_mode && !jitter_mode && !score_mode && !mos_mode && order_mode)) {
+			printf("|");
+	}
 	i = 0;
 	host = list;
 	while(host) {
 		if(debug) puts("");
-		printf("%srta=%0.3fms;%0.3f;%0.3f;0; %spl=%u%%;%u;%u;; %srtmax=%0.3fms;;;; %srtmin=%0.3fms;;;; ",
-			   (targets > 1) ? host->name : "",
-			   host->rta / 1000, (float)warn.rta / 1000, (float)crit.rta / 1000,
-			   (targets > 1) ? host->name : "", host->pl, warn.pl, crit.pl,
-			   (targets > 1) ? host->name : "", (float)host->rtmax / 1000,
-			   (targets > 1) ? host->name : "", (host->rtmin < DBL_MAX) ? (float)host->rtmin / 1000 : (float)0);
-
+		if (rta_mode && host->pl<100) {
+			printf("%srta=%0.3fms;%0.3f;%0.3f;0; %srtmax=%0.3fms;;;; %srtmin=%0.3fms;;;; ",(targets > 1) ? host->name : "", (float)host->rta / 1000, (float)warn.rta / 1000, (float)crit.rta / 1000, (targets > 1) ? host->name : "", (float)host->rtmax / 1000, (targets > 1) ? host->name : "", (float)host->rtmin / 1000);
+		}
+		if (pl_mode) {
+			printf("%spl=%u%%;%u;%u;0;100 ", (targets > 1) ? host->name : "", host->pl, warn.pl, crit.pl);
+		}
+		if (jitter_mode && host->pl<100) {
+			printf("%sjitter_avg=%0.3fms;%0.3f;%0.3f;0; %sjitter_max=%0.3fms;;;; %sjitter_min=%0.3fms;;;; ", (targets > 1) ? host->name : "", (float)host->jitter, (float)warn.jitter, (float)crit.jitter, (targets > 1) ? host->name : "", (float)host->jitter_max / 1000, (targets > 1) ? host->name : "",(float)host->jitter_min / 1000);
+		}
+		if (mos_mode && host->pl<100) {
+			printf("%smos=%0.1f;%0.1f;%0.1f;0;5 ", (targets > 1) ? host->name : "", (float)host->mos, (float)warn.mos, (float)crit.mos);
+		}
+		if (score_mode && host->pl<100) {
+			printf("%sscore=%u;%u;%u;0;100 ", (targets > 1) ? host->name : "", (int)host->score, (int)warn.score, (int)crit.score);
+		}
 		host = host->next;
 	}
 
@@ -1144,8 +1415,20 @@ add_target_ip(char *arg, struct in_addr *in)
 	/* fill out the sockaddr_in struct */
 	host->saddr_in.sin_family = AF_INET;
 	host->saddr_in.sin_addr.s_addr = in->s_addr;
-
 	host->rtmin = DBL_MAX;
+	host->rtmax = 0;
+	host->jitter=0;
+	host->jitter_max=0;
+	host->jitter_min=DBL_MAX;
+	host->last_tdiff=0;
+	host->order_status=STATE_OK;
+	host->last_icmp_seq=0;
+	host->rta_status=0;
+	host->pl_status=0;
+	host->jitter_status=0;
+	host->mos_status=0;
+	host->score_status=0;
+	host->pl_status=0;
 
 	if(!list) list = cursor = host;
 	else cursor->next = host;
@@ -1250,7 +1533,7 @@ get_timevar(const char *str)
 
 	/* unit might be given as ms|m (millisec),
 	 * us|u (microsec) or just plain s, for seconds */
-	u = p = '\0';
+	p = '\0';
 	u = str[len - 1];
 	if(len >= 2 && !isdigit((int)str[len - 2])) p = str[len - 2];
 	if(p && u == 's') u = p;
@@ -1262,7 +1545,7 @@ get_timevar(const char *str)
 	else if(u == 's') factor = 1000000;	/* seconds */
 	if(debug > 2) printf("factor is %u\n", factor);
 
-	i = strtoul(str, &ptr, 0);
+	i =  strtoul(str, &ptr, 0);
 	if(!ptr || *ptr != '.' || strlen(ptr) < 2 || factor == 1)
 		return i * factor;
 
@@ -1308,6 +1591,46 @@ get_threshold(char *str, threshold *th)
 	return 0;
 }
 
+/* not too good at checking errors, but it'll do (main() should barfe on -1) */
+static int
+get_threshold2(char *str, threshold *warn, threshold *crit, int type)
+{
+	char *p = NULL, i = 0;
+
+	if(!str || !strlen(str) || !warn || !crit) return -1;
+	/* pointer magic slims code by 10 lines. i is bof-stop on stupid libc's */
+	p = &str[strlen(str) - 1];
+	while(p != &str[0]) {
+		if( (*p == 'm') || (*p == '%') ) *p = '\0';
+		else if(*p == ',' && i) {
+			*p = '\0';	/* reset it so get_timevar(str) works nicely later */
+			if (type==1)
+				crit->rta = atof(p+1)*1000;
+			else if  (type==2)
+				crit->pl = (unsigned char)strtoul(p+1, NULL, 0);
+			else if  (type==3)
+				crit->jitter = atof(p+1);
+			else if (type==4)
+				crit->mos = atof(p+1);
+			else if (type==5)
+				crit->score = atof(p+1);
+		}
+		i = 1;
+		p--;
+	}
+	if (type==1)
+		warn->rta = atof(p)*1000;
+	else if (type==2)
+		warn->pl = (unsigned char)strtoul(p, NULL, 0);
+	if (type==3)
+		warn->jitter = atof(p);
+	else if (type==4)
+		warn->mos = atof(p);
+	else if (type==5)
+		warn->score = atof(p);
+	return 0;
+}
+
 unsigned short
 icmp_checksum(unsigned short *p, int n)
 {
@@ -1332,10 +1655,9 @@ icmp_checksum(unsigned short *p, int n)
 void
 print_help(void)
 {
-
   /*print_revision (progname);*/ /* FIXME: Why? */
-
   printf ("Copyright (c) 2005 Andreas Ericsson <ae@op5.se>\n");
+  
   printf (COPYRIGHT, copyright, email);
 
   printf ("\n\n");
@@ -1344,20 +1666,35 @@ print_help(void)
 
   printf (UT_HELP_VRSN);
   printf (UT_EXTRA_OPTS);
-
-  printf (" %s\n", "-H");
-  printf ("    %s\n", _("specify a target"));
-  printf (" %s\n", "-w");
+	printf (" %s\n", "-w");
   printf ("    %s", _("warning threshold (currently "));
   printf ("%0.3fms,%u%%)\n", (float)warn.rta / 1000, warn.pl);
   printf (" %s\n", "-c");
   printf ("    %s", _("critical threshold (currently "));
   printf ("%0.3fms,%u%%)\n", (float)crit.rta / 1000, crit.pl);
+
+  printf (" %s\n", "-R");
+  printf ("    %s\n", _("RTA, round trip average,  mode  warning,critical, ex. 100ms,200ms unit in ms"));
+  printf (" %s\n", "-P");
+  printf ("    %s\n", _("packet loss mode, ex. 40%,50% , unit in %"));
+  printf (" %s\n", "-J");
+  printf ("    %s\n", _("jitter mode  warning,critical, ex. 40.000ms,50.000ms , unit in ms "));
+  printf (" %s\n", "-M");
+  printf ("    %s\n", _("MOS mode, between 0 and 4.4  warning,critical, ex. 3.5,3.0"));
+  printf (" %s\n", "-S");
+  printf ("    %s\n", _("score  mode, max value 100  warning,critical, ex. 80,70 "));
+  printf (" %s\n", "-O");
+  printf ("    %s\n", _("detect out of order ICMP packts "));
+  printf (" %s\n", "-H");
+  printf ("    %s\n", _("specify a target"));
   printf (" %s\n", "-s");
   printf ("    %s\n", _("specify a source IP address or device name"));
   printf (" %s\n", "-n");
   printf ("    %s", _("number of packets to send (currently "));
   printf ("%u)\n",packets);
+  printf (" %s\n", "-p");
+  printf ("    %s", _("number of packets to send (currently "));
+  printf ("%u)\n",packets);
   printf (" %s\n", "-i");
   printf ("    %s", _("max packet interval (currently "));
   printf ("%0.3fms)\n",(float)pkt_interval / 1000);
@@ -1378,9 +1715,9 @@ print_help(void)
   printf ("    %s %u + %d)\n", _("Packet size will be data bytes + icmp header (currently"),icmp_data_size, ICMP_MINLEN);
   printf (" %s\n", "-v");
   printf ("    %s\n", _("verbose"));
-
   printf ("\n");
   printf ("%s\n", _("Notes:"));
+  printf ("%s\n", _("If not mode R,P,J,M,S or O is informed, default icmp behavior, RTA and packet loss"));
   printf (" %s\n", _("The -H switch is optional. Naming a host (or several) to check is not."));
   printf ("\n");
   printf (" %s\n", _("Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%"));
-- 
cgit v0.10-9-g596f


From f5c5a7438fa34f2ee2c0b9914806f9a26b56ba59 Mon Sep 17 00:00:00 2001
From: root <dirty.ren@gmail.com>
Date: Mon, 21 Aug 2017 09:42:10 -0300
Subject: Clean up plugin exit


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index d68c4e0..2ad644e 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1090,7 +1090,6 @@ finish(int sig)
 	int hosts_ok = 0;
 	int hosts_warn = 0;
 	double R;
-	int	shown=0;
 
 	alarm(0);
 	if(debug > 1) printf("finish(%d) called\n", sig);
@@ -1255,64 +1254,58 @@ finish(int sig)
 			}
 		}
 		else {	/* !icmp_recv */
-			printf("%s: ", host->name);
+			printf("%s ", host->name);
 			/* rta text output */
 			if (rta_mode) {
-				shown=1;
 				if (status == STATE_OK)
-					printf("%s rta %0.3fms",(shown==1)?",":"", host->rta / 1000);
+					printf("rta %0.3fms", host->rta / 1000);
 				else if (status==STATE_WARNING && host->rta_status==status)
-					printf("%s rta %0.3fms > %0.3fms",(shown==1)?",":"", (float)host->rta / 1000, (float)warn.rta/1000);
+					printf("rta %0.3fms > %0.3fms", (float)host->rta / 1000, (float)warn.rta/1000);
 				else if (status==STATE_CRITICAL && host->rta_status==status)
-					printf("%s rta %0.3fms > %0.3fms",(shown==1)?",":"", (float)host->rta / 1000, (float)crit.rta/1000);
+					printf("rta %0.3fms > %0.3fms", (float)host->rta / 1000, (float)crit.rta/1000);
 			}
 			/* pl text output */
 			if (pl_mode) {
-				shown=1;
 				if (status == STATE_OK)
-					printf("%s lost %u%%",(shown==1)?",":"", host->pl);
+					printf("lost %u%%", host->pl);
 				else if (status==STATE_WARNING && host->pl_status==status)
-					printf("%s lost %u%% > %u%%",(shown==1)?",":"", host->pl, warn.pl);
+					printf("lost %u%% > %u%%", host->pl, warn.pl);
 				else if (status==STATE_CRITICAL && host->pl_status==status)
-					printf("%s lost %u%% > %u%%",(shown==1)?",":"", host->pl, crit.pl);
+					printf("lost %u%% > %u%%", host->pl, crit.pl);
 			}
 			/* jitter text output */
 			if (jitter_mode) {
-				shown=1;
 				if (status == STATE_OK)
-					printf("%s jitter %0.3fms",(shown==1)?",":"", (float)host->jitter);
+					printf("jitter %0.3fms", (float)host->jitter);
 				else if (status==STATE_WARNING && host->jitter_status==status)
-					printf("%s jitter %0.3fms > %0.3fms",(shown==1)?",":"", (float)host->jitter, warn.jitter);
+					printf("jitter %0.3fms > %0.3fms", (float)host->jitter, warn.jitter);
 				else if (status==STATE_CRITICAL && host->jitter_status==status)
-					printf("%s jitter %0.3fms > %0.3fms",(shown==1)?",":"", (float)host->jitter, crit.jitter);
+					printf("jitter %0.3fms > %0.3fms", (float)host->jitter, crit.jitter);
 			}
 			/* mos text output */
 			if (mos_mode) {
-				shown=1;
 				if (status == STATE_OK)
-					printf("%s MOS %0.1f",(shown==1)?",":"", (float)host->mos);
+					printf("MOS %0.1f", (float)host->mos);
 				else if (status==STATE_WARNING && host->mos_status==status)
-					printf("%s MOS %0.1f < %0.1f",(shown==1)?",":"", (float)host->mos, (float)warn.mos);
+					printf("MOS %0.1f < %0.1f", (float)host->mos, (float)warn.mos);
 				else if (status==STATE_CRITICAL && host->mos_status==status)
-					printf("%s MOS %0.1f < %0.1f",(shown==1)?",":"", (float)host->mos, (float)crit.mos);
+					printf("MOS %0.1f < %0.1f", (float)host->mos, (float)crit.mos);
 			}
 			/* score text output */
 			if (score_mode) {
-				shown=1;
 				if (status == STATE_OK)
-					printf("%s Score %u",(shown==1)?",":"", (int)host->score);
+					printf("Score %u", (int)host->score);
 				else if (status==STATE_WARNING && host->score_status==status )
-					printf("%s Score %u < %u",(shown==1)?",":"", (int)host->score, (int)warn.score);
+					printf("Score %u < %u", (int)host->score, (int)warn.score);
 				else if (status==STATE_CRITICAL && host->score_status==status )
-					printf("%s Score %u < %u",(shown==1)?",":"", (int)host->score, (int)crit.score);
+					printf("Score %u < %u", (int)host->score, (int)crit.score);
 			}
 			/* order statis text output */
 			if (order_mode) {
-				shown=1;
 				if (status == STATE_OK)
-					printf("%s Packets in order",(shown==1)?",":"");
+					printf("Packets in order");
 				else if (status==STATE_CRITICAL && host->order_status==status)
-					printf("%s Packets out of order",(shown==1)?",":"");
+					printf("Packets out of order");
 			}
 		}
 		host = host->next;
-- 
cgit v0.10-9-g596f


From 3929c5ac37a5b6c6ae0430c40438da087da07e1a Mon Sep 17 00:00:00 2001
From: Gerardo Malazdrewicz <36243997+GerMalaz@users.noreply.github.com>
Date: Sun, 31 Oct 2021 09:37:55 -0300
Subject: check_mysql.c: Detect running mysqldump

When checking a slave, if the IO Thread or the SQL Thread are stopped, check for running mysqldump threads, return STATE_OK if there is any.
Requires PROCESS privilege to work (else the mysqldump thread(s) would not be detected).

Enlarged SLAVERESULTSIZE to fit "Mysqldump: in progress" at the end of the string.
Got a NULL pointer in row[seconds_behind_field] instead of the "NULL" string when a mysqldump is running [mysql 5.7.34 + libmariadb3 10.3.31], so added a check for that.

diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index 0cba50e..5b9a4fe 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -34,7 +34,7 @@ const char *progname = "check_mysql";
 const char *copyright = "1999-2011";
 const char *email = "devel@monitoring-plugins.org";
 
-#define SLAVERESULTSIZE 70
+#define SLAVERESULTSIZE 96
 
 #include "common.h"
 #include "utils.h"
@@ -89,6 +89,8 @@ static const char *metric_counter[LENGTH_METRIC_COUNTER] = {
 	"Uptime"
 };
 
+#define MYSQLDUMP_THREADS_QUERY "SELECT COUNT(1) mysqldumpThreads FROM information_schema.processlist WHERE info LIKE 'SELECT /*!40001 SQL_NO_CACHE */%'"
+
 thresholds *my_threshold = NULL;
 
 int process_arguments (int, char **);
@@ -275,11 +277,29 @@ main (int argc, char **argv)
 			/* Save slave status in slaveresult */
 			snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s Seconds Behind Master: %s", row[slave_io_field], row[slave_sql_field], seconds_behind_field!=-1?row[seconds_behind_field]:"Unknown");
 
-			/* Raise critical error if SQL THREAD or IO THREAD are stopped */
+			/* Raise critical error if SQL THREAD or IO THREAD are stopped, but only if there are no mysqldump threads running */
 			if (strcmp (row[slave_io_field], "Yes") != 0 || strcmp (row[slave_sql_field], "Yes") != 0) {
-				mysql_free_result (res);
-				mysql_close (&mysql);
-				die (STATE_CRITICAL, "%s\n", slaveresult);
+				MYSQL_RES *res_mysqldump;
+				MYSQL_ROW row_mysqldump;
+				unsigned int mysqldump_threads = 0;
+
+				if (mysql_query (&mysql, MYSQLDUMP_THREADS_QUERY) == 0) {
+					/* store the result */
+					if ( (res_mysqldump = mysql_store_result (&mysql)) != NULL) {
+						if (mysql_num_rows(res_mysqldump) == 1) {
+							if ( (row_mysqldump = mysql_fetch_row (res_mysqldump)) != NULL) {
+								mysqldump_threads = atoi(row_mysqldump[0]);
+							}
+						}
+						/* free the result */
+						mysql_free_result (res_mysqldump);
+					}
+				}
+				if (mysqldump_threads == 0) {
+					die (STATE_CRITICAL, "%s\n", slaveresult);
+				} else {
+					strlcat (slaveresult, " Mysqldump: in progress", SLAVERESULTSIZE);
+				}
 			}
 
 			if (verbose >=3) {
@@ -291,7 +311,7 @@ main (int argc, char **argv)
 			}
 
 			/* Check Seconds Behind against threshold */
-			if ((seconds_behind_field != -1) && (strcmp (row[seconds_behind_field], "NULL") != 0)) {
+			if ((seconds_behind_field != -1) && (row[seconds_behind_field] != NULL && strcmp (row[seconds_behind_field], "NULL") != 0)) {
 				double value = atof(row[seconds_behind_field]);
 				int status;
 
-- 
cgit v0.10-9-g596f


From 8700f497160cfc2cce8918c8cd8922b7320c510a Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 12 Mar 2023 20:44:42 +0100
Subject: Replace deprecated TLS client functions


diff --git a/plugins/sslutils.c b/plugins/sslutils.c
index 666a012..6bc0ba8 100644
--- a/plugins/sslutils.c
+++ b/plugins/sslutils.c
@@ -31,9 +31,8 @@
 #include "netutils.h"
 
 #ifdef HAVE_SSL
-static SSL_CTX *c=NULL;
+static SSL_CTX *ctx=NULL;
 static SSL *s=NULL;
-static int initialized=0;
 
 int np_net_ssl_init(int sd) {
 	return np_net_ssl_init_with_hostname(sd, NULL);
@@ -48,24 +47,24 @@ int np_net_ssl_init_with_hostname_and_version(int sd, char *host_name, int versi
 }
 
 int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int version, char *cert, char *privkey) {
-	const SSL_METHOD *method = NULL;
 	long options = 0;
 
+	if ((ctx = SSL_CTX_new(TLS_client_method())) == NULL) {
+		printf("%s\n", _("CRITICAL - Cannot create SSL context."));
+		return STATE_CRITICAL;
+	}
+
 	switch (version) {
 	case MP_SSLv2: /* SSLv2 protocol */
-#if defined(USE_GNUTLS) || defined(OPENSSL_NO_SSL2)
 		printf("%s\n", _("UNKNOWN - SSL protocol version 2 is not supported by your SSL library."));
 		return STATE_UNKNOWN;
-#else
-		method = SSLv2_client_method();
-		break;
-#endif
 	case MP_SSLv3: /* SSLv3 protocol */
 #if defined(OPENSSL_NO_SSL3)
 		printf("%s\n", _("UNKNOWN - SSL protocol version 3 is not supported by your SSL library."));
 		return STATE_UNKNOWN;
 #else
-		method = SSLv3_client_method();
+		SSL_CTX_set_min_proto_version(ctx, SSL3_VERSION);
+		SSL_CTX_set_max_proto_version(ctx, SSL3_VERSION);
 		break;
 #endif
 	case MP_TLSv1: /* TLSv1 protocol */
@@ -73,7 +72,8 @@ int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int
 		printf("%s\n", _("UNKNOWN - TLS protocol version 1 is not supported by your SSL library."));
 		return STATE_UNKNOWN;
 #else
-		method = TLSv1_client_method();
+		SSL_CTX_set_min_proto_version(ctx, TLS1_VERSION);
+		SSL_CTX_set_max_proto_version(ctx, TLS1_VERSION);
 		break;
 #endif
 	case MP_TLSv1_1: /* TLSv1.1 protocol */
@@ -81,7 +81,8 @@ int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int
 		printf("%s\n", _("UNKNOWN - TLS protocol version 1.1 is not supported by your SSL library."));
 		return STATE_UNKNOWN;
 #else
-		method = TLSv1_1_client_method();
+		SSL_CTX_set_min_proto_version(ctx, TLS1_1_VERSION);
+		SSL_CTX_set_max_proto_version(ctx, TLS1_1_VERSION);
 		break;
 #endif
 	case MP_TLSv1_2: /* TLSv1.2 protocol */
@@ -89,7 +90,8 @@ int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int
 		printf("%s\n", _("UNKNOWN - TLS protocol version 1.2 is not supported by your SSL library."));
 		return STATE_UNKNOWN;
 #else
-		method = TLSv1_2_client_method();
+		SSL_CTX_set_min_proto_version(ctx, TLS1_2_VERSION);
+		SSL_CTX_set_max_proto_version(ctx, TLS1_2_VERSION);
 		break;
 #endif
 	case MP_TLSv1_2_OR_NEWER:
@@ -97,56 +99,43 @@ int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int
 		printf("%s\n", _("UNKNOWN - Disabling TLSv1.1 is not supported by your SSL library."));
 		return STATE_UNKNOWN;
 #else
-		options |= SSL_OP_NO_TLSv1_1;
+		SSL_CTX_set_min_proto_version(ctx, TLS1_2_VERSION);
+		break;
 #endif
-		/* FALLTHROUGH */
 	case MP_TLSv1_1_OR_NEWER:
 #if !defined(SSL_OP_NO_TLSv1)
 		printf("%s\n", _("UNKNOWN - Disabling TLSv1 is not supported by your SSL library."));
 		return STATE_UNKNOWN;
 #else
-		options |= SSL_OP_NO_TLSv1;
+		SSL_CTX_set_min_proto_version(ctx, TLS1_1_VERSION);
+		break;
 #endif
-		/* FALLTHROUGH */
 	case MP_TLSv1_OR_NEWER:
 #if defined(SSL_OP_NO_SSLv3)
-		options |= SSL_OP_NO_SSLv3;
+		SSL_CTX_set_min_proto_version(ctx, TLS1_VERSION);
+		break;
 #endif
-		/* FALLTHROUGH */
 	case MP_SSLv3_OR_NEWER:
 #if defined(SSL_OP_NO_SSLv2)
-		options |= SSL_OP_NO_SSLv2;
+		SSL_CTX_set_min_proto_version(ctx, SSL3_VERSION);
+		break;
 #endif
-	case MP_SSLv2_OR_NEWER:
-		/* FALLTHROUGH */
-	default: /* Default to auto negotiation */
-		method = SSLv23_client_method();
-	}
-	if (!initialized) {
-		/* Initialize SSL context */
-		SSLeay_add_ssl_algorithms();
-		SSL_load_error_strings();
-		OpenSSL_add_all_algorithms();
-		initialized = 1;
-	}
-	if ((c = SSL_CTX_new(method)) == NULL) {
-		printf("%s\n", _("CRITICAL - Cannot create SSL context."));
-		return STATE_CRITICAL;
 	}
+
 	if (cert && privkey) {
 #ifdef USE_OPENSSL
-		if (!SSL_CTX_use_certificate_chain_file(c, cert)) {
+		if (!SSL_CTX_use_certificate_chain_file(ctx, cert)) {
 #elif  USE_GNUTLS
-		if (!SSL_CTX_use_certificate_file(c, cert, SSL_FILETYPE_PEM)) {
+		if (!SSL_CTX_use_certificate_file(ctx, cert, SSL_FILETYPE_PEM)) {
 #else
 #error Unported for unknown SSL library
 #endif
 			printf ("%s\n", _("CRITICAL - Unable to open certificate chain file!\n"));
 			return STATE_CRITICAL;
 		}
-		SSL_CTX_use_PrivateKey_file(c, privkey, SSL_FILETYPE_PEM);
+		SSL_CTX_use_PrivateKey_file(ctx, privkey, SSL_FILETYPE_PEM);
 #ifdef USE_OPENSSL
-		if (!SSL_CTX_check_private_key(c)) {
+		if (!SSL_CTX_check_private_key(ctx)) {
 			printf ("%s\n", _("CRITICAL - Private key does not seem to match certificate!\n"));
 			return STATE_CRITICAL;
 		}
@@ -155,9 +144,9 @@ int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int
 #ifdef SSL_OP_NO_TICKET
 	options |= SSL_OP_NO_TICKET;
 #endif
-	SSL_CTX_set_options(c, options);
-	SSL_CTX_set_mode(c, SSL_MODE_AUTO_RETRY);
-	if ((s = SSL_new(c)) != NULL) {
+	SSL_CTX_set_options(ctx, options);
+	SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);
+	if ((s = SSL_new(ctx)) != NULL) {
 #ifdef SSL_set_tlsext_host_name
 		if (host_name != NULL)
 			SSL_set_tlsext_host_name(s, host_name);
@@ -184,9 +173,9 @@ void np_net_ssl_cleanup() {
 #endif
 		SSL_shutdown(s);
 		SSL_free(s);
-		if (c) {
-			SSL_CTX_free(c);
-			c=NULL;
+		if (ctx) {
+			SSL_CTX_free(ctx);
+			ctx=NULL;
 		}
 		s=NULL;
 	}
-- 
cgit v0.10-9-g596f


From 7c98e2b345b91d8ef3fb1f7a1bcf74194d54c966 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 12 Mar 2023 12:14:41 +0100
Subject: Use default OPENSSL sha functions if available


diff --git a/lib/utils_base.c b/lib/utils_base.c
index eb1823b..39032cb 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -402,26 +402,37 @@ int mp_translate_state (char *state_text) {
  * parse of argv, so that uniqueness in parameters are reflected there.
  */
 char *_np_state_generate_key() {
-	struct sha256_ctx ctx;
 	int i;
 	char **argv = this_monitoring_plugin->argv;
 	unsigned char result[20];
 	char keyname[41];
 	char *p=NULL;
+#ifdef USE_OPENSSL
+	/*
+	 * This code path is chosen if openssl is available (which should be the most common
+	 * scenario). Alternatively, the gnulib implementation/
+	 *
+	 */
+	EVP_MD_CTX *ctx = EVP_MD_CTX_new();
+
+	EVP_DigestInit(ctx, EVP_sha256());
+
+	for(i=0; i<this_monitoring_plugin->argc; i++) {
+		EVP_DigestUpdate(ctx, argv[i], strlen(argv[i]));
+	}
+
+	EVP_DigestFinalXOF(ctx, &result, 20);
+#else
+	struct sha256_ctx ctx;
 
-	sha256_init_ctx(&ctx);
-	
 	for(i=0; i<this_monitoring_plugin->argc; i++) {
 		sha256_process_bytes(argv[i], strlen(argv[i]), &ctx);
 	}
 
 	sha256_finish_ctx(&ctx, &result);
-	
-	for (i=0; i<20; ++i) {
-		sprintf(&keyname[2*i], "%02x", result[i]);
-	}
+#endif // FOUNDOPENSSL
 	keyname[40]='\0';
-	
+
 	p = strdup(keyname);
 	if(p==NULL) {
 		die(STATE_UNKNOWN, _("Cannot execute strdup: %s"), strerror(errno));
diff --git a/lib/utils_base.h b/lib/utils_base.h
index 5906550..9cb4276 100644
--- a/lib/utils_base.h
+++ b/lib/utils_base.h
@@ -2,7 +2,9 @@
 #define _UTILS_BASE_
 /* Header file for Monitoring Plugins utils_base.c */
 
-#include "sha256.h"
+#ifndef USE_OPENSSL
+# include "sha256.h"
+#endif
 
 /* This file holds header information for thresholds - use this in preference to 
    individual plugin logic */
-- 
cgit v0.10-9-g596f


From f6f2ba34c713b5bc65936af836be24ebc74faf46 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 12 Mar 2023 13:58:25 +0100
Subject: Fix hash creation


diff --git a/lib/utils_base.c b/lib/utils_base.c
index 39032cb..105ff44 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -404,9 +404,15 @@ int mp_translate_state (char *state_text) {
 char *_np_state_generate_key() {
 	int i;
 	char **argv = this_monitoring_plugin->argv;
-	unsigned char result[20];
 	char keyname[41];
 	char *p=NULL;
+
+	unsigned char *result = malloc(256 * sizeof(unsigned char));
+
+	if (result == NULL) {
+		die(STATE_UNKNOWN, _("Failed to allocate memory for hashes: %s"), strerror(errno));
+	}
+
 #ifdef USE_OPENSSL
 	/*
 	 * This code path is chosen if openssl is available (which should be the most common
@@ -421,16 +427,22 @@ char *_np_state_generate_key() {
 		EVP_DigestUpdate(ctx, argv[i], strlen(argv[i]));
 	}
 
-	EVP_DigestFinalXOF(ctx, &result, 20);
+	EVP_DigestFinal(ctx, result, NULL);
 #else
+
 	struct sha256_ctx ctx;
 
 	for(i=0; i<this_monitoring_plugin->argc; i++) {
 		sha256_process_bytes(argv[i], strlen(argv[i]), &ctx);
 	}
 
-	sha256_finish_ctx(&ctx, &result);
+	sha256_finish_ctx(&ctx, result);
 #endif // FOUNDOPENSSL
+
+	for (i=0; i<20; ++i) {
+		sprintf(&keyname[2*i], "%02x", result[i]);
+	}
+
 	keyname[40]='\0';
 
 	p = strdup(keyname);
-- 
cgit v0.10-9-g596f


From a00c412e7ba1474b32f478daf039d2bdf71f072a Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 12 Mar 2023 14:59:23 +0100
Subject: Fixes for -Wnonnull-compare


diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c
index 8b8e570..34fb390 100644
--- a/lib/utils_cmd.c
+++ b/lib/utils_cmd.c
@@ -118,10 +118,6 @@ _cmd_open (char *const *argv, int *pfd, int *pfderr)
 
 	int i = 0;
 
-	/* if no command was passed, return with no error */
-	if (argv == NULL)
-		return -1;
-
 	if (!_cmd_pids)
 		CMD_INIT;
 
diff --git a/plugins/runcmd.c b/plugins/runcmd.c
index 1bd2ca1..ff1987f 100644
--- a/plugins/runcmd.c
+++ b/plugins/runcmd.c
@@ -114,10 +114,6 @@ np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr)
 	env[0] = strdup("LC_ALL=C");
 	env[1] = '\0';
 
-	/* if no command was passed, return with no error */
-	if (cmdstring == NULL)
-		return -1;
-
 	/* make copy of command string so strtok() doesn't silently modify it */
 	/* (the calling program may want to access it later) */
 	cmdlen = strlen(cmdstring);
-- 
cgit v0.10-9-g596f


From 6d341c40ab4d84d5eabfd672de1ffa3c7ecd07be Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 12 Mar 2023 14:04:25 +0100
Subject: Fixes for Waddress

* check_snmp: Fix string comparison

diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index c425df3..425bb7b 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -422,7 +422,8 @@ main (int argc, char **argv)
 		}
 		else if (strstr (response, "INTEGER: ")) {
 			show = multiply (strstr (response, "INTEGER: ") + 9);
-			if (fmtstr != "") {
+
+			if (strcmp(fmtstr, "") != 0) {
 				conv = fmtstr;
 			}
 		}
@@ -596,8 +597,9 @@ main (int argc, char **argv)
 			len = sizeof(perfstr)-strlen(perfstr)-1;
 			strncat(perfstr, show, len>ptr-show ? ptr-show : len);
 
-			if (type)
+			if (strcmp(type, "") != 0) {
 				strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);
+			}
 
 			if (warning_thresholds) {
 				strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
@@ -1185,7 +1187,7 @@ multiply (char *str)
 	if(verbose>2)
 		printf("    multiply extracted double: %f\n", val);
 	val *= multiplier;
-	if (fmtstr != "") {
+	if (strcmp(fmtstr, "") != 0) {
 		conv = fmtstr;
 	}
 	if (val == (int)val) {
-- 
cgit v0.10-9-g596f


From 068c124f361d4c615aed79f6fe607f39040b2e31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?= <lorenz.kaestle@netways.de>
Date: Tue, 11 Jul 2023 16:39:29 +0200
Subject: Detect if fmtstr was set in edge cases


diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 425bb7b..135bbc7 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -158,6 +158,7 @@ int perf_labels = 1;
 char* ip_version = "";
 double multiplier = 1.0;
 char *fmtstr = "";
+bool fmtstr_set = false;
 char buffer[DEFAULT_BUFFER_SIZE];
 
 static char *fix_snmp_range(char *th)
@@ -423,7 +424,7 @@ main (int argc, char **argv)
 		else if (strstr (response, "INTEGER: ")) {
 			show = multiply (strstr (response, "INTEGER: ") + 9);
 
-			if (strcmp(fmtstr, "") != 0) {
+			if (fmtstr_set) {
 				conv = fmtstr;
 			}
 		}
@@ -973,6 +974,7 @@ process_arguments (int argc, char **argv)
 		case 'f':
 			if (multiplier != 1.0) {
 				fmtstr=optarg;
+				fmtstr_set = true;
 			}
 			break;
 		}
@@ -1187,7 +1189,7 @@ multiply (char *str)
 	if(verbose>2)
 		printf("    multiply extracted double: %f\n", val);
 	val *= multiplier;
-	if (strcmp(fmtstr, "") != 0) {
+	if (fmtstr_set) {
 		conv = fmtstr;
 	}
 	if (val == (int)val) {
-- 
cgit v0.10-9-g596f


From c5e90822d7db1db504e19007a7078d1fa09267f2 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 23 Jul 2023 22:07:33 +0200
Subject: Use memory on stack instead of heap for temporary variables


diff --git a/lib/utils_base.c b/lib/utils_base.c
index 176fa85..0f52126 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -407,11 +407,7 @@ char *_np_state_generate_key() {
 	char keyname[41];
 	char *p=NULL;
 
-	unsigned char *result = malloc(256 * sizeof(unsigned char));
-
-	if (result == NULL) {
-		die(STATE_UNKNOWN, _("Failed to allocate memory for hashes: %s"), strerror(errno));
-	}
+	unsigned char result[256];
 
 #ifdef USE_OPENSSL
 	/*
-- 
cgit v0.10-9-g596f


From c405dbafccd27259bd860ea408b32f2594e1a384 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Mon, 18 Sep 2023 19:18:35 +0200
Subject: Add mysql_close to avoid spamming the server logs


diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index 5b9a4fe..8dc554f 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -294,6 +294,7 @@ main (int argc, char **argv)
 						/* free the result */
 						mysql_free_result (res_mysqldump);
 					}
+					mysql_close (&mysql);
 				}
 				if (mysqldump_threads == 0) {
 					die (STATE_CRITICAL, "%s\n", slaveresult);
-- 
cgit v0.10-9-g596f


From ce355c80cf6054bfa5e1dcf81f9e2183ef963ee1 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Mon, 18 Sep 2023 22:58:34 +0200
Subject: Initialize slaveresult to 0 and use strncat instead of bsd strlcat


diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index 8dc554f..9b7d13f 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -110,7 +110,7 @@ main (int argc, char **argv)
 
 	char *result = NULL;
 	char *error = NULL;
-	char slaveresult[SLAVERESULTSIZE];
+	char slaveresult[SLAVERESULTSIZE] = { 0 };
 	char* perf;
 
         perf = strdup ("");
@@ -299,7 +299,7 @@ main (int argc, char **argv)
 				if (mysqldump_threads == 0) {
 					die (STATE_CRITICAL, "%s\n", slaveresult);
 				} else {
-					strlcat (slaveresult, " Mysqldump: in progress", SLAVERESULTSIZE);
+					strncat(slaveresult, " Mysqldump: in progress", SLAVERESULTSIZE-1);
 				}
 			}
 
-- 
cgit v0.10-9-g596f


From 3e8fdf9b35ab750e3fe964ce289bbbdaffb3b800 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Wed, 20 Sep 2023 18:22:55 +0200
Subject: check_disk: Fix printf format string


diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 05e5502..6cb4cb2 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -1027,7 +1027,7 @@ void
 print_usage (void)
 {
   printf ("%s\n", _("Usage:"));
-  printf (" %s {-w absolute_limit |-w  percentage_limit% | -W inode_percentage_limit } {-c absolute_limit|-c percentage_limit% | -K inode_percentage_limit } {-p path | -x device}\n", progname);
+  printf (" %s {-w absolute_limit |-w  percentage_limit%% | -W inode_percentage_limit } {-c absolute_limit|-c percentage_limit%% | -K inode_percentage_limit } {-p path | -x device}\n", progname);
   printf ("[-C] [-E] [-e] [-f] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n");
   printf ("[-t timeout] [-u unit] [-v] [-X type] [-N type]\n");
 }
-- 
cgit v0.10-9-g596f


From 2f916675b3b0ecb7cdeac045304607265cc57065 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Wed, 20 Sep 2023 18:23:42 +0200
Subject: check_disk: Mention -A and long options in error message about
 missing thresholds


diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 6cb4cb2..bd64148 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -798,7 +798,7 @@ process_arguments (int argc, char **argv)
              crit_freespace_percent || warn_usedspace_units || crit_usedspace_units ||
              warn_usedspace_percent || crit_usedspace_percent || warn_usedinodes_percent ||
              crit_usedinodes_percent || warn_freeinodes_percent || crit_freeinodes_percent )) {
-        die (STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set a threshold value before using -r/-R\n"));
+        die (STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set a threshold value before using -r/-R/-A (--ereg-path/--eregi-path/--all)\n"));
       }
 
       err = regcomp(&re, optarg, cflags);
-- 
cgit v0.10-9-g596f


From b01aa8c43390a4e32197abedc84af20fd8a8faf6 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Wed, 20 Sep 2023 18:24:08 +0200
Subject: check_disk: More spacing to separate examples


diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index bd64148..35fd481 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -1011,10 +1011,10 @@ print_help (void)
   printf ("\n");
   printf ("%s\n", _("Examples:"));
   printf (" %s\n", "check_disk -w 10% -c 5% -p /tmp -p /var -C -w 100000 -c 50000 -p /");
-  printf ("    %s\n", _("Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB"));
+  printf ("    %s\n\n", _("Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB"));
   printf (" %s\n", "check_disk -w 100 -c 50 -C -w 1000 -c 500 -g sidDATA -r '^/oracle/SID/data.*$'");
   printf ("    %s\n", _("Checks all filesystems not matching -r at 100M and 50M. The fs matching the -r regex"));
-  printf ("    %s\n", _("are grouped which means the freespace thresholds are applied to all disks together"));
+  printf ("    %s\n\n", _("are grouped which means the freespace thresholds are applied to all disks together"));
   printf (" %s\n", "check_disk -w 100 -c 50 -C -w 1000 -c 500 -p /foo -C -w 5% -c 3% -p /bar");
   printf ("    %s\n", _("Checks /foo for 1000M/500M and /bar for 5/3%. All remaining volumes use 100M/50M"));
 
-- 
cgit v0.10-9-g596f


From 8faf7afad389b74d6fe67a2ece10e85b9f614a13 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Thu, 21 Sep 2023 09:00:33 +0200
Subject: check_disk: Add some general usage hints


diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 35fd481..b3edc41 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -1009,6 +1009,14 @@ print_help (void)
   printf ("    %s\n", _("Check only filesystems of indicated type (may be repeated)"));
 
   printf ("\n");
+  printf ("%s\n", _("General usage hints:"));
+  printf (" %s\n", _("- Arguments are positional! \"-w 5 -c 1 -p /foo -w6 -c2 -p /bar\" is not the same as"));
+  printf ("   %s\n", _("\"-w 5 -c 1 -p /bar w6 -c2 -p /foo\"."));
+  printf (" %s\n", _("- The syntax is broadly: \"{thresholds a} {paths a} {thresholds b} {thresholds b} ...\""));
+
+
+
+  printf ("\n");
   printf ("%s\n", _("Examples:"));
   printf (" %s\n", "check_disk -w 10% -c 5% -p /tmp -p /var -C -w 100000 -c 50000 -p /");
   printf ("    %s\n\n", _("Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB"));
-- 
cgit v0.10-9-g596f


From 2ef36843abf3b2ec7142aa2f52b66d5d3c7b543b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?= <lorenz.kaestle@netways.de>
Date: Thu, 21 Sep 2023 09:50:53 +0200
Subject: Add -C to general usage hints


diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index b3edc41..7dc1c4b 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -1012,7 +1012,7 @@ print_help (void)
   printf ("%s\n", _("General usage hints:"));
   printf (" %s\n", _("- Arguments are positional! \"-w 5 -c 1 -p /foo -w6 -c2 -p /bar\" is not the same as"));
   printf ("   %s\n", _("\"-w 5 -c 1 -p /bar w6 -c2 -p /foo\"."));
-  printf (" %s\n", _("- The syntax is broadly: \"{thresholds a} {paths a} {thresholds b} {thresholds b} ...\""));
+  printf (" %s\n", _("- The syntax is broadly: \"{thresholds a} {paths a} -C {thresholds b} {thresholds b} ...\""));
 
 
 
-- 
cgit v0.10-9-g596f


From b6bb2a18c9c772d41e2bf703f02b95e0bfe9b31d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?= <lorenz.kaestle@netways.de>
Date: Thu, 21 Sep 2023 12:14:24 +0200
Subject: Update translations


diff --git a/po/de.po b/po/de.po
index d597203..0dedfc1 100644
--- a/po/de.po
+++ b/po/de.po
@@ -9,10 +9,11 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
-"POT-Creation-Date: 2023-09-05 00:31+0200\n"
+"POT-Creation-Date: 2023-09-21 12:09+0200\n"
 "PO-Revision-Date: 2004-12-23 17:46+0100\n"
 "Last-Translator:  \n"
-"Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins.org>\n"
+"Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins."
+"org>\n"
 "Language: de\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
@@ -321,7 +322,9 @@ msgstr ""
 msgid "Could not compile regular expression"
 msgstr ""
 
-msgid "Must set a threshold value before using -r/-R\n"
+msgid ""
+"Must set a threshold value before using -r/-R/-A (--ereg-path/--eregi-path/--"
+"all)\n"
 msgstr ""
 
 msgid "Regular expression did not match any path or disk"
@@ -449,6 +452,22 @@ msgstr ""
 msgid "Check only filesystems of indicated type (may be repeated)"
 msgstr ""
 
+msgid "General usage hints:"
+msgstr "Allgemeine Nutzungshinweise:"
+
+msgid ""
+"- Arguments are positional! \"-w 5 -c 1 -p /foo -w6 -c2 -p /bar\" is not the "
+"same as"
+msgstr ""
+
+msgid "\"-w 5 -c 1 -p /bar w6 -c2 -p /foo\"."
+msgstr ""
+
+msgid ""
+"- The syntax is broadly: \"{thresholds a} {paths a} -C {thresholds b} "
+"{thresholds b} ...\""
+msgstr ""
+
 msgid "Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB"
 msgstr ""
 
diff --git a/po/fr.po b/po/fr.po
index dfc2c5d..ec5651d 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -10,10 +10,11 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
-"POT-Creation-Date: 2023-09-05 00:31+0200\n"
+"POT-Creation-Date: 2023-09-21 12:09+0200\n"
 "PO-Revision-Date: 2010-04-21 23:38-0400\n"
 "Last-Translator: \n"
-"Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins.org>\n"
+"Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins."
+"org>\n"
 "Language: fr\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
@@ -320,7 +321,9 @@ msgstr ""
 msgid "Could not compile regular expression"
 msgstr "Impossible de compiler l'expression rationnelle"
 
-msgid "Must set a threshold value before using -r/-R\n"
+msgid ""
+"Must set a threshold value before using -r/-R/-A (--ereg-path/--eregi-path/--"
+"all)\n"
 msgstr ""
 
 msgid "Regular expression did not match any path or disk"
@@ -469,6 +472,22 @@ msgstr ""
 "Ignorer tout les systèmes de fichiers qui correspondent au type indiqué "
 "(peut être utilisé plusieurs fois)"
 
+msgid "General usage hints:"
+msgstr ""
+
+msgid ""
+"- Arguments are positional! \"-w 5 -c 1 -p /foo -w6 -c2 -p /bar\" is not the "
+"same as"
+msgstr ""
+
+msgid "\"-w 5 -c 1 -p /bar w6 -c2 -p /foo\"."
+msgstr ""
+
+msgid ""
+"- The syntax is broadly: \"{thresholds a} {paths a} -C {thresholds b} "
+"{thresholds b} ...\""
+msgstr ""
+
 msgid "Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB"
 msgstr "Vérifie /tmp à 10% et /var à 5% et / à 100MB et 50MB"
 
diff --git a/po/monitoring-plugins.pot b/po/monitoring-plugins.pot
index af48f03..2cd94b1 100644
--- a/po/monitoring-plugins.pot
+++ b/po/monitoring-plugins.pot
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
-"POT-Creation-Date: 2023-09-12 01:33+0200\n"
+"POT-Creation-Date: 2023-09-21 12:09+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -305,7 +305,9 @@ msgstr ""
 msgid "Could not compile regular expression"
 msgstr ""
 
-msgid "Must set a threshold value before using -r/-R\n"
+msgid ""
+"Must set a threshold value before using -r/-R/-A (--ereg-path/--eregi-path/--"
+"all)\n"
 msgstr ""
 
 msgid "Regular expression did not match any path or disk"
@@ -427,6 +429,22 @@ msgstr ""
 msgid "Check only filesystems of indicated type (may be repeated)"
 msgstr ""
 
+msgid "General usage hints:"
+msgstr ""
+
+msgid ""
+"- Arguments are positional! \"-w 5 -c 1 -p /foo -w6 -c2 -p /bar\" is not the "
+"same as"
+msgstr ""
+
+msgid "\"-w 5 -c 1 -p /bar w6 -c2 -p /foo\"."
+msgstr ""
+
+msgid ""
+"- The syntax is broadly: \"{thresholds a} {paths a} -C {thresholds b} "
+"{thresholds b} ...\""
+msgstr ""
+
 msgid "Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB"
 msgstr ""
 
-- 
cgit v0.10-9-g596f


From 7fd0e6f36d90a341e0d9b418f1cd64a3a5472a94 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 5 Mar 2023 15:37:47 +0100
Subject: Rework maxfd/open_max to avoid unused variables


diff --git a/lib/Makefile.am b/lib/Makefile.am
index 01d73a6..1a47395 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -7,7 +7,7 @@ noinst_LIBRARIES = libmonitoringplug.a
 AM_CPPFLAGS = -DNP_STATE_DIR_PREFIX=\"$(localstatedir)\" \
 	-I$(srcdir) -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins
 
-libmonitoringplug_a_SOURCES = utils_base.c utils_disk.c utils_tcp.c utils_cmd.c
+libmonitoringplug_a_SOURCES = utils_base.c utils_disk.c utils_tcp.c utils_cmd.c maxfd.c
 EXTRA_DIST = utils_base.h utils_disk.h utils_tcp.h utils_cmd.h parse_ini.h extra_opts.h
 
 if USE_PARSE_INI
diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c
index 34fb390..71da9d2 100644
--- a/lib/utils_cmd.c
+++ b/lib/utils_cmd.c
@@ -43,6 +43,9 @@
 #include "utils.h"
 #include "utils_cmd.h"
 #include "utils_base.h"
+
+#include "./maxfd.h"
+
 #include <fcntl.h>
 
 #ifdef HAVE_SYS_WAIT_H
@@ -86,13 +89,7 @@ extern void die (int, const char *, ...)
 void
 cmd_init (void)
 {
-#ifndef maxfd
-	if (!maxfd && (maxfd = sysconf (_SC_OPEN_MAX)) < 0) {
-		/* possibly log or emit a warning here, since there's no
-		 * guarantee that our guess at maxfd will be adequate */
-		maxfd = DEFAULT_MAXFD;
-	}
-#endif
+	long maxfd = open_max();
 
 	/* if maxfd is unnaturally high, we force it to a lower value
 	 * ( e.g. on SunOS, when ulimit is set to unlimited: 2147483647 this would cause
@@ -148,6 +145,7 @@ _cmd_open (char *const *argv, int *pfd, int *pfderr)
 		/* close all descriptors in _cmd_pids[]
 		 * This is executed in a separate address space (pure child),
 		 * so we don't have to worry about async safety */
+		long maxfd = open_max();
 		for (i = 0; i < maxfd; i++)
 			if (_cmd_pids[i] > 0)
 				close (i);
@@ -174,6 +172,7 @@ _cmd_close (int fd)
 	pid_t pid;
 
 	/* make sure the provided fd was opened */
+	long maxfd = open_max();
 	if (fd < 0 || fd > maxfd || !_cmd_pids || (pid = _cmd_pids[fd]) == 0)
 		return -1;
 
@@ -265,7 +264,6 @@ _cmd_fetch_output (int fd, output * op, int flags)
 int
 cmd_run (const char *cmdstring, output * out, output * err, int flags)
 {
-	int fd, pfd_out[2], pfd_err[2];
 	int i = 0, argc;
 	size_t cmdlen;
 	char **argv = NULL;
@@ -387,6 +385,7 @@ timeout_alarm_handler (int signo)
 		printf (_("%s - Plugin timed out after %d seconds\n"),
 						state_text(timeout_state), timeout_interval);
 
+		long maxfd = open_max();
 		if(_cmd_pids) for(i = 0; i < maxfd; i++) {
 			if(_cmd_pids[i] != 0) kill(_cmd_pids[i], SIGKILL);
 		}
diff --git a/plugins/common.h b/plugins/common.h
index 0f08e2f..6bf4fca 100644
--- a/plugins/common.h
+++ b/plugins/common.h
@@ -225,18 +225,4 @@ enum {
 # define __attribute__(x) /* do nothing */
 #endif
 
-/* Try sysconf(_SC_OPEN_MAX) first, as it can be higher than OPEN_MAX.
- * If that fails and the macro isn't defined, we fall back to an educated
- * guess. There's no guarantee that our guess is adequate and the program
- * will die with SIGSEGV if it isn't and the upper boundary is breached. */
-#define DEFAULT_MAXFD  256   /* fallback value if no max open files value is set */
-#define MAXFD_LIMIT   8192   /* upper limit of open files */
-#ifdef _SC_OPEN_MAX
-static long maxfd = 0;
-#elif defined(OPEN_MAX)
-# define maxfd OPEN_MAX
-#else	/* sysconf macro unavailable, so guess (may be wildly inaccurate) */
-# define maxfd DEFAULT_MAXFD
-#endif
-
 #endif /* _COMMON_H_ */
diff --git a/plugins/popen.c b/plugins/popen.c
index 723817d..7703afc 100644
--- a/plugins/popen.c
+++ b/plugins/popen.c
@@ -38,8 +38,9 @@
 * 
 *****************************************************************************/
 
-#include "common.h"
-#include "utils.h"
+#include "./common.h"
+#include "./utils.h"
+#include "../lib/maxfd.h"
 
 /* extern so plugin has pid to kill exec'd process on timeouts */
 extern pid_t *childpid;
@@ -177,8 +178,7 @@ spopen (const char *cmdstring)
 	}
 	argv[i] = NULL;
 
-	if(maxfd == 0)
-		maxfd = open_max();
+	long maxfd = open_max();
 
 	if (childpid == NULL) {				/* first time through */
 		if ((childpid = calloc ((size_t)maxfd, sizeof (pid_t))) == NULL)
diff --git a/plugins/runcmd.c b/plugins/runcmd.c
index 102191e..9816142 100644
--- a/plugins/runcmd.c
+++ b/plugins/runcmd.c
@@ -88,8 +88,7 @@ extern void die (int, const char *, ...)
  * through this api and thus achieve async-safeness throughout the api */
 void np_runcmd_init(void)
 {
-	if(maxfd == 0)
-		maxfd = open_max();
+  long maxfd = open_max();
 	if(!np_pids) np_pids = calloc(maxfd, sizeof(pid_t));
 }
 
@@ -192,6 +191,7 @@ np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr)
 		/* close all descriptors in np_pids[]
 		 * This is executed in a separate address space (pure child),
 		 * so we don't have to worry about async safety */
+    long maxfd = open_max();
 		for (i = 0; i < maxfd; i++)
 			if(np_pids[i] > 0)
 				close (i);
@@ -219,6 +219,7 @@ np_runcmd_close(int fd)
 	pid_t pid;
 
 	/* make sure this fd was opened by popen() */
+  long maxfd = open_max();
 	if(fd < 0 || fd > maxfd || !np_pids || (pid = np_pids[fd]) == 0)
 		return -1;
 
@@ -242,6 +243,7 @@ runcmd_timeout_alarm_handler (int signo)
 	if (signo == SIGALRM)
 		puts(_("CRITICAL - Plugin timed out while executing system call"));
 
+  long maxfd = open_max();
 	if(np_pids) for(i = 0; i < maxfd; i++) {
 		if(np_pids[i] != 0) kill(np_pids[i], SIGKILL);
 	}
diff --git a/plugins/utils.c b/plugins/utils.c
index b4214c6..71c0bdd 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -804,19 +804,3 @@ char *sperfdata_int (const char *label,
 
 	return data;
 }
-
-int
-open_max (void)
-{
-	errno = 0;
-	if (maxfd > 0)
-		return(maxfd);
-
-	if ((maxfd = sysconf (_SC_OPEN_MAX)) < 0) {
-		if (errno == 0)
-			maxfd = DEFAULT_MAXFD;   /* it's indeterminate */
-	else
-		die (STATE_UNKNOWN, _("sysconf error for _SC_OPEN_MAX\n"));
-	}
-	return(maxfd);
-}
diff --git a/plugins/utils.h b/plugins/utils.h
index c76b321..cb979ce 100644
--- a/plugins/utils.h
+++ b/plugins/utils.h
@@ -106,8 +106,6 @@ char *sperfdata (const char *, double, const char *, char *, char *,
 char *sperfdata_int (const char *, int, const char *, char *, char *,
                      int, int, int, int);
 
-int open_max (void);
-
 /* The idea here is that, although not every plugin will use all of these, 
    most will or should.  Therefore, for consistency, these very common 
    options should have only these meanings throughout the overall suite */
-- 
cgit v0.10-9-g596f


From 0162cb2d4f7040e3b2d48095182f87ce565866a5 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 5 Mar 2023 16:03:37 +0100
Subject: fixup! Rework maxfd/open_max to avoid unused variables


diff --git a/lib/maxfd.c b/lib/maxfd.c
new file mode 100644
index 0000000..dcd4d3d
--- /dev/null
+++ b/lib/maxfd.c
@@ -0,0 +1,26 @@
+#include "./maxfd.h"
+#include <errno.h>
+
+long open_max (void) {
+	long maxfd = 0L;
+	/* Try sysconf(_SC_OPEN_MAX) first, as it can be higher than OPEN_MAX.
+	 * If that fails and the macro isn't defined, we fall back to an educated
+	 * guess. There's no guarantee that our guess is adequate and the program
+	 * will die with SIGSEGV if it isn't and the upper boundary is breached. */
+
+#ifdef _SC_OPEN_MAX
+	errno = 0;
+	if ((maxfd = sysconf (_SC_OPEN_MAX)) < 0) {
+		if (errno == 0)
+			maxfd = DEFAULT_MAXFD;   /* it's indeterminate */
+		else
+			die (STATE_UNKNOWN, _("sysconf error for _SC_OPEN_MAX\n"));
+	}
+#elif defined(OPEN_MAX)
+	return OPEN_MAX
+#else	/* sysconf macro unavailable, so guess (may be wildly inaccurate) */
+	return DEFAULT_MAXFD;
+#endif
+
+	return(maxfd);
+}
diff --git a/lib/maxfd.h b/lib/maxfd.h
new file mode 100644
index 0000000..0d734c5
--- /dev/null
+++ b/lib/maxfd.h
@@ -0,0 +1,9 @@
+#ifndef _MAXFD_
+#define _MAXFD_
+
+#define DEFAULT_MAXFD  256   /* fallback value if no max open files value is set */
+#define MAXFD_LIMIT   8192   /* upper limit of open files */
+
+long open_max (void);
+
+#endif // _MAXFD_
-- 
cgit v0.10-9-g596f


From a3029c5a2e71d4aa4955901f282d3f4669acf97d Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 5 Mar 2023 15:47:49 +0100
Subject: Place _cmd_pids in object not header to avoid unsused variables


diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c
index 34fb390..883f1ec 100644
--- a/lib/utils_cmd.c
+++ b/lib/utils_cmd.c
@@ -42,6 +42,16 @@
 #include "common.h"
 #include "utils.h"
 #include "utils_cmd.h"
+/* This variable must be global, since there's no way the caller
+ * can forcibly slay a dead or ungainly running program otherwise.
+ * Multithreading apps and plugins can initialize it (via CMD_INIT)
+ * in an async safe manner PRIOR to calling cmd_run() or cmd_run_array()
+ * for the first time.
+ *
+ * The check for initialized values is atomic and can
+ * occur in any number of threads simultaneously. */
+static pid_t *_cmd_pids = NULL;
+
 #include "utils_base.h"
 #include <fcntl.h>
 
diff --git a/lib/utils_cmd.h b/lib/utils_cmd.h
index 6f3aeb8..1fc2968 100644
--- a/lib/utils_cmd.h
+++ b/lib/utils_cmd.h
@@ -32,15 +32,6 @@ void cmd_init (void);
 #define CMD_NO_ARRAYS 0x01   /* don't populate arrays at all */
 #define CMD_NO_ASSOC 0x02    /* output.line won't point to buf */
 
-/* This variable must be global, since there's no way the caller
- * can forcibly slay a dead or ungainly running program otherwise.
- * Multithreading apps and plugins can initialize it (via CMD_INIT)
- * in an async safe manner PRIOR to calling cmd_run() or cmd_run_array()
- * for the first time.
- *
- * The check for initialized values is atomic and can
- * occur in any number of threads simultaneously. */
-static pid_t *_cmd_pids = NULL;
 
 RETSIGTYPE timeout_alarm_handler (int);
 
-- 
cgit v0.10-9-g596f


From bef0d0dd4ab04ac1189071526fae4031bec36b1d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?= <lorenz.kaestle@netways.de>
Date: Fri, 22 Sep 2023 15:36:59 +0200
Subject: Update translations


diff --git a/po/de.po b/po/de.po
index 0dedfc1..9ea32df 100644
--- a/po/de.po
+++ b/po/de.po
@@ -9,7 +9,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
-"POT-Creation-Date: 2023-09-21 12:09+0200\n"
+"POT-Creation-Date: 2023-09-22 15:36+0200\n"
 "PO-Revision-Date: 2004-12-23 17:46+0100\n"
 "Last-Translator:  \n"
 "Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins."
@@ -4705,9 +4705,6 @@ msgstr "konnte keinen Speicher für '%s' reservieren\n"
 msgid "failed malloc in xvasprintf\n"
 msgstr "konnte keinen Speicher für '%s' reservieren\n"
 
-msgid "sysconf error for _SC_OPEN_MAX\n"
-msgstr ""
-
 #, c-format
 msgid ""
 "       %s (-h | --help) for detailed help\n"
diff --git a/po/fr.po b/po/fr.po
index ec5651d..28deb94 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -10,7 +10,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
-"POT-Creation-Date: 2023-09-21 12:09+0200\n"
+"POT-Creation-Date: 2023-09-22 15:36+0200\n"
 "PO-Revision-Date: 2010-04-21 23:38-0400\n"
 "Last-Translator: \n"
 "Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins."
@@ -4839,9 +4839,6 @@ msgstr "La fonction malloc à échoué dans strscat\n"
 msgid "failed malloc in xvasprintf\n"
 msgstr "La fonction malloc à échoué dans strscat\n"
 
-msgid "sysconf error for _SC_OPEN_MAX\n"
-msgstr ""
-
 #, c-format
 msgid ""
 "       %s (-h | --help) for detailed help\n"
diff --git a/po/monitoring-plugins.pot b/po/monitoring-plugins.pot
index 2cd94b1..d019a7e 100644
--- a/po/monitoring-plugins.pot
+++ b/po/monitoring-plugins.pot
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
-"POT-Creation-Date: 2023-09-21 12:09+0200\n"
+"POT-Creation-Date: 2023-09-22 15:36+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -4532,9 +4532,6 @@ msgstr ""
 msgid "failed malloc in xvasprintf\n"
 msgstr ""
 
-msgid "sysconf error for _SC_OPEN_MAX\n"
-msgstr ""
-
 #, c-format
 msgid ""
 "       %s (-h | --help) for detailed help\n"
-- 
cgit v0.10-9-g596f


From 4295decfbf06adfa1bf019d28e9044971607b2d6 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sat, 23 Sep 2023 10:33:06 +0200
Subject: open_max is a library function now, it should be mp_open_max


diff --git a/lib/maxfd.c b/lib/maxfd.c
index dcd4d3d..529b356 100644
--- a/lib/maxfd.c
+++ b/lib/maxfd.c
@@ -1,7 +1,7 @@
 #include "./maxfd.h"
 #include <errno.h>
 
-long open_max (void) {
+long mp_open_max (void) {
 	long maxfd = 0L;
 	/* Try sysconf(_SC_OPEN_MAX) first, as it can be higher than OPEN_MAX.
 	 * If that fails and the macro isn't defined, we fall back to an educated
diff --git a/lib/maxfd.h b/lib/maxfd.h
index 0d734c5..45218d0 100644
--- a/lib/maxfd.h
+++ b/lib/maxfd.h
@@ -4,6 +4,6 @@
 #define DEFAULT_MAXFD  256   /* fallback value if no max open files value is set */
 #define MAXFD_LIMIT   8192   /* upper limit of open files */
 
-long open_max (void);
+long mp_open_max (void);
 
 #endif // _MAXFD_
diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c
index 71da9d2..ef7053a 100644
--- a/lib/utils_cmd.c
+++ b/lib/utils_cmd.c
@@ -89,7 +89,7 @@ extern void die (int, const char *, ...)
 void
 cmd_init (void)
 {
-	long maxfd = open_max();
+	long maxfd = mp_open_max();
 
 	/* if maxfd is unnaturally high, we force it to a lower value
 	 * ( e.g. on SunOS, when ulimit is set to unlimited: 2147483647 this would cause
@@ -145,7 +145,7 @@ _cmd_open (char *const *argv, int *pfd, int *pfderr)
 		/* close all descriptors in _cmd_pids[]
 		 * This is executed in a separate address space (pure child),
 		 * so we don't have to worry about async safety */
-		long maxfd = open_max();
+		long maxfd = mp_open_max();
 		for (i = 0; i < maxfd; i++)
 			if (_cmd_pids[i] > 0)
 				close (i);
@@ -172,7 +172,7 @@ _cmd_close (int fd)
 	pid_t pid;
 
 	/* make sure the provided fd was opened */
-	long maxfd = open_max();
+	long maxfd = mp_open_max();
 	if (fd < 0 || fd > maxfd || !_cmd_pids || (pid = _cmd_pids[fd]) == 0)
 		return -1;
 
@@ -385,7 +385,7 @@ timeout_alarm_handler (int signo)
 		printf (_("%s - Plugin timed out after %d seconds\n"),
 						state_text(timeout_state), timeout_interval);
 
-		long maxfd = open_max();
+		long maxfd = mp_open_max();
 		if(_cmd_pids) for(i = 0; i < maxfd; i++) {
 			if(_cmd_pids[i] != 0) kill(_cmd_pids[i], SIGKILL);
 		}
diff --git a/plugins/popen.c b/plugins/popen.c
index 7703afc..b395f14 100644
--- a/plugins/popen.c
+++ b/plugins/popen.c
@@ -178,7 +178,7 @@ spopen (const char *cmdstring)
 	}
 	argv[i] = NULL;
 
-	long maxfd = open_max();
+	long maxfd = mp_open_max();
 
 	if (childpid == NULL) {				/* first time through */
 		if ((childpid = calloc ((size_t)maxfd, sizeof (pid_t))) == NULL)
diff --git a/plugins/runcmd.c b/plugins/runcmd.c
index 9816142..bc0a497 100644
--- a/plugins/runcmd.c
+++ b/plugins/runcmd.c
@@ -88,7 +88,7 @@ extern void die (int, const char *, ...)
  * through this api and thus achieve async-safeness throughout the api */
 void np_runcmd_init(void)
 {
-  long maxfd = open_max();
+  long maxfd = mp_open_max();
 	if(!np_pids) np_pids = calloc(maxfd, sizeof(pid_t));
 }
 
@@ -191,7 +191,7 @@ np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr)
 		/* close all descriptors in np_pids[]
 		 * This is executed in a separate address space (pure child),
 		 * so we don't have to worry about async safety */
-    long maxfd = open_max();
+    long maxfd = mp_open_max();
 		for (i = 0; i < maxfd; i++)
 			if(np_pids[i] > 0)
 				close (i);
@@ -219,7 +219,7 @@ np_runcmd_close(int fd)
 	pid_t pid;
 
 	/* make sure this fd was opened by popen() */
-  long maxfd = open_max();
+  long maxfd = mp_open_max();
 	if(fd < 0 || fd > maxfd || !np_pids || (pid = np_pids[fd]) == 0)
 		return -1;
 
@@ -243,7 +243,7 @@ runcmd_timeout_alarm_handler (int signo)
 	if (signo == SIGALRM)
 		puts(_("CRITICAL - Plugin timed out while executing system call"));
 
-  long maxfd = open_max();
+  long maxfd = mp_open_max();
 	if(np_pids) for(i = 0; i < maxfd; i++) {
 		if(np_pids[i] != 0) kill(np_pids[i], SIGKILL);
 	}
-- 
cgit v0.10-9-g596f


From 513929d796af668e977ca7981800c259304a2f25 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sat, 23 Sep 2023 12:31:33 +0200
Subject: Remove check for RETSIGTYPE in autoconf stuff

autoupdate tells me, that since C89 I can safely assume RETSIGTYPE
is void.

Therefore to simplify things I removed the corresponding configure.ac
line and replaced all mentions of RETSIGTYPE with void.

diff --git a/configure.ac b/configure.ac
index a294b00..e6a40d3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -621,7 +621,6 @@ AC_C_CONST
 AC_STRUCT_TM
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
-AC_TYPE_SIGNAL
 
 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
 AC_TRY_LINK([#include <stdarg.h>
diff --git a/lib/utils_cmd.h b/lib/utils_cmd.h
index 1fc2968..f1b06c8 100644
--- a/lib/utils_cmd.h
+++ b/lib/utils_cmd.h
@@ -33,7 +33,7 @@ void cmd_init (void);
 #define CMD_NO_ASSOC 0x02    /* output.line won't point to buf */
 
 
-RETSIGTYPE timeout_alarm_handler (int);
+void timeout_alarm_handler (int);
 
 
 #endif /* _UTILS_CMD_ */
diff --git a/plugins/netutils.h b/plugins/netutils.h
index d7ee0dd..ea653e7 100644
--- a/plugins/netutils.h
+++ b/plugins/netutils.h
@@ -92,7 +92,7 @@ extern int econn_refuse_state;
 extern int was_refused;
 extern int address_family;
 
-RETSIGTYPE socket_timeout_alarm_handler (int) __attribute__((noreturn));
+void socket_timeout_alarm_handler (int) __attribute__((noreturn));
 
 /* SSL-Related functionality */
 #ifdef HAVE_SSL
diff --git a/plugins/popen.c b/plugins/popen.c
index b395f14..036bc60 100644
--- a/plugins/popen.c
+++ b/plugins/popen.c
@@ -50,9 +50,9 @@ extern FILE *child_process;
 FILE *spopen (const char *);
 int spclose (FILE *);
 #ifdef REDHAT_SPOPEN_ERROR
-RETSIGTYPE popen_sigchld_handler (int);
+void popen_sigchld_handler (int);
 #endif
-RETSIGTYPE popen_timeout_alarm_handler (int);
+void popen_timeout_alarm_handler (int);
 
 #include <stdarg.h>							/* ANSI C header file */
 #include <fcntl.h>
@@ -266,7 +266,7 @@ spclose (FILE * fp)
 }
 
 #ifdef REDHAT_SPOPEN_ERROR
-RETSIGTYPE
+void
 popen_sigchld_handler (int signo)
 {
 	if (signo == SIGCHLD)
@@ -274,7 +274,7 @@ popen_sigchld_handler (int signo)
 }
 #endif
 
-RETSIGTYPE
+void
 popen_timeout_alarm_handler (int signo)
 {
 	int fh;
diff --git a/plugins/popen.h b/plugins/popen.h
index a5dd8fa..1ea6963 100644
--- a/plugins/popen.h
+++ b/plugins/popen.h
@@ -5,7 +5,7 @@
 
 FILE *spopen (const char *);
 int spclose (FILE *);
-RETSIGTYPE popen_timeout_alarm_handler (int);
+void popen_timeout_alarm_handler (int);
 
 pid_t *childpid=NULL;
 int *child_stderr_array=NULL;
-- 
cgit v0.10-9-g596f


From 8272d73e579739cccbfce61f7401cd5f8b9fd0e0 Mon Sep 17 00:00:00 2001
From: Danijel Tasov <m@rbfh.de>
Date: Sat, 23 Sep 2023 16:18:08 +0200
Subject: remove root check

We can perfectly do icmp without root by using capabalities.  So,
instead of doing unsufficient checks beforehand, we just try and fail if
it doesn't work.

Signed-off-by: Danijel Tasov <m@rbfh.de>

diff --git a/lib/utils_base.c b/lib/utils_base.c
index 8a03d09..3822bcf 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -300,19 +300,6 @@ char *np_escaped_string (const char *string) {
 
 int np_check_if_root(void) { return (geteuid() == 0); }
 
-int np_warn_if_not_root(void) {
-        int status = np_check_if_root();
-        if(!status) {
-                printf(_("Warning: "));
-                printf(_("This plugin must be either run as root or setuid root.\n"));
-                printf(_("To run as root, you can use a tool like sudo.\n"));
-                printf(_("To set the setuid permissions, use the command:\n"));
-                /* XXX could we use something like progname? */
-                printf("\tchmod u+s yourpluginfile\n");
-        }
-        return status;
-}
-
 /*
  * Extract the value from key/value pairs, or return NULL. The value returned
  * can be free()ed.
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 2ad644e..a7fad36 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -417,9 +417,6 @@ main(int argc, char **argv)
 	bindtextdomain (PACKAGE, LOCALEDIR);
 	textdomain (PACKAGE);
 
-	/* print a helpful error message if geteuid != 0 */
-	np_warn_if_not_root();
-
 	/* we only need to be setsuid when we get the sockets, so do
 	 * that before pointer magic (esp. on network data) */
 	icmp_sockerrno = udp_sockerrno = tcp_sockerrno = sockets = 0;
-- 
cgit v0.10-9-g596f


From 2f909de3405a2073bafed32a3ce47e466bb562ce Mon Sep 17 00:00:00 2001
From: Danijel Tasov <m@rbfh.de>
Date: Sat, 23 Sep 2023 16:46:15 +0200
Subject: fix merge error

Signed-off-by: Danijel Tasov <m@rbfh.de>

diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 72ad1d7..a485415 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -524,7 +524,6 @@ main(int argc, char **argv)
 	/* parse the arguments */
 	for(i = 1; i < argc; i++) {
 		while((arg = getopt(argc, argv, opts_str)) != EOF) {
-		while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:s:i:b:I:l:m:P:R:J:S:M:O")) != EOF) {
 			switch(arg) {
 			case 'v':
 				debug++;
-- 
cgit v0.10-9-g596f


From bc2d1e4b5ecd5fc9270b8d8a65cbd445b7fb783f Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sat, 23 Sep 2023 21:41:50 +0200
Subject: Somehow this fixes detection of the availability of struct timeval
 for me


diff --git a/configure.ac b/configure.ac
index a294b00..2ddc503 100644
--- a/configure.ac
+++ b/configure.ac
@@ -645,12 +645,16 @@ AC_TRY_COMPILE([#include <sys/time.h>],
                [struct timeval *tv;
                 struct timezone *tz;],
                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
-               AC_TRY_COMPILE([#include <sys/time.h>],
-                              [struct timeval *tv;
-                               struct timezone *tz;
-                               gettimeofday(tv, tz);],
-                              AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
-                              AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
+			   FOUND_STRUCT_TIMEVAL="yes")
+
+if test x$FOUND_STRUCT_TIMEVAL = x"yes"; then
+	AC_TRY_COMPILE([#include <sys/time.h>],
+			  [struct timeval *tv;
+			   struct timezone *tz;
+			   gettimeofday(tv, tz);],
+			  AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
+			  AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed]))
+fi
 
 dnl Checks for library functions.
 AC_CHECK_FUNCS(memmove select socket strdup strstr strtol strtoul floor)
-- 
cgit v0.10-9-g596f


From 9387e21de7b66a44f2b8a5f907124afdcf7b88a8 Mon Sep 17 00:00:00 2001
From: Danijel Tasov <data@consol.de>
Date: Mon, 25 Sep 2023 09:49:11 +0200
Subject: exit UNKNOWN on -V

Signed-off-by: Danijel Tasov <m@rbfh.de>

diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index a485415..18eed74 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -579,7 +579,7 @@ main(int argc, char **argv)
 				break;
 			case 'V': /* version */
 				print_revision (progname, NP_VERSION);
-				exit (STATE_OK);
+				exit (STATE_UNKNOWN);
 			case 'h': /* help */
 				print_help ();
 				exit (STATE_UNKNOWN);
-- 
cgit v0.10-9-g596f


From 3f0cc2533c21e0ce4c1975eac6146d758275a564 Mon Sep 17 00:00:00 2001
From: Danijel Tasov <data@consol.de>
Date: Mon, 25 Sep 2023 09:49:11 +0200
Subject: Fix compile errors

Signed-off-by: Danijel Tasov <m@rbfh.de>

diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 18eed74..d1fe5b1 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -991,17 +991,17 @@ wait_for_reply(int sock, u_int t)
 				if (jitter_tmp > host->jitter_max)
 					host->jitter_max=jitter_tmp;
 			}
-			
+
 			/* Check if packets in order */
-			if (host->last_icmp_seq >= icp.icmp_seq)
+			if (host->last_icmp_seq >= packet.icp->icmp_seq)
 				host->order_status=STATE_CRITICAL;
 		}
 		host->last_tdiff=tdiff;
-		
-		host->last_icmp_seq=icp.icmp_seq;
-		
+
+		host->last_icmp_seq=packet.icp->icmp_seq;
+
 		//printf("%d tdiff %d host->jitter %u  host->last_tdiff %u\n", icp.icmp_seq, tdiff, host->jitter, host->last_tdiff);
-		
+
 		host->time_waited += tdiff;
 		host->icmp_recv++;
 		icmp_recv++;
@@ -1596,8 +1596,6 @@ add_target_ip(char *arg, struct sockaddr_storage *in)
 	}
 
 	/* fill out the sockaddr_in struct */
-	host->saddr_in.sin_family = AF_INET;
-	host->saddr_in.sin_addr.s_addr = in->s_addr;
 	host->rtmin = INFINITY;
 	host->rtmax = 0;
 	host->jitter=0;
-- 
cgit v0.10-9-g596f


From 111e25efcd36b00493f07760ae825b285cdb7037 Mon Sep 17 00:00:00 2001
From: Danijel Tasov <data@consol.de>
Date: Mon, 25 Sep 2023 09:49:11 +0200
Subject: Fix speling

Signed-off-by: Danijel Tasov <m@rbfh.de>

diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index d1fe5b1..e77682c 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -736,7 +736,7 @@ main(int argc, char **argv)
 		if(max_completion_time > (u_int)timeout * 1000000) {
 			printf("max_completion_time: %llu  timeout: %u\n",
 				   max_completion_time, timeout);
-			printf("Timout must be at lest %llu\n",
+			printf("Timeout must be at least %llu\n",
 				   max_completion_time / 1000000 + 1);
 		}
 	}
-- 
cgit v0.10-9-g596f


From 9c1c3fce4388d89a5d201ad731c6a2e115d7d21f Mon Sep 17 00:00:00 2001
From: datamuc <m@rbfh.de>
Date: Mon, 25 Sep 2023 21:30:32 +0200
Subject: run tests with debian:stable

debian:testing is broken

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 77b09f4..eda2790 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -49,10 +49,10 @@ jobs:
       fail-fast: false
       matrix:
         distro:
-          - 'debian:testing'
+          - 'debian:stable'
           #...
         include:
-          - distro: 'debian:testing'
+          - distro: 'debian:stable'
             prepare: .github/prepare_debian.sh
           #...
     steps:
-- 
cgit v0.10-9-g596f


From 2d6b467530ea55eea6341be45f759f67216e1f99 Mon Sep 17 00:00:00 2001
From: Danijel Tasov <m@rbfh.de>
Date: Tue, 26 Sep 2023 10:01:05 +0200
Subject: add missing character


diff --git a/.gitignore b/.gitignore
index 02ca61e..6f903d6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -94,7 +94,7 @@ NP-VERSION-FILE
 /gl/limits.h
 /gl/malloc/dynarray-skeleton.gl.h
 /gl/malloc/dynarray.gl.h
-/gl/stdckdint.
+/gl/stdckdint.h
 
 # /lib/
 /lib/.deps
-- 
cgit v0.10-9-g596f


From 4ed1d74295efe1c41f6a1489e2f187ece0d8452b Mon Sep 17 00:00:00 2001
From: Danijel Tasov <m@rbfh.de>
Date: Tue, 26 Sep 2023 17:26:43 +0200
Subject: fixed comment

Signed-off-by: Danijel Tasov <m@rbfh.de>

diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index e77682c..e2ce059 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -592,7 +592,7 @@ main(int argc, char **argv)
 				get_threshold2(optarg, &warn, &crit,2);
 				pl_mode=1;
 				break;
-			case 'J': /* packet loss mode */
+			case 'J': /* jitter mode */
 				get_threshold2(optarg, &warn, &crit,3);
 				jitter_mode=1;
 				break;
-- 
cgit v0.10-9-g596f


From 42125d928f3792414290b00e184d8859a90fcd9e Mon Sep 17 00:00:00 2001
From: Danijel Tasov <m@rbfh.de>
Date: Tue, 26 Sep 2023 17:35:31 +0200
Subject: Add some spaces to the output

needed if multiple modes are used at once

Signed-off-by: Danijel Tasov <m@rbfh.de>

diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index e2ce059..a537c9c 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1379,10 +1379,10 @@ finish(int sig)
 		else if((hosts_ok + hosts_warn) >= min_hosts_alive) status = STATE_WARNING;
 	}
 	printf("%s - ", status_string[status]);
-	
+
 	host = list;
 	while(host) {
-		
+
 		if(debug) puts("");
 		if(i) {
 			if(i < targets) printf(" :: ");
@@ -1411,54 +1411,54 @@ finish(int sig)
 			/* rta text output */
 			if (rta_mode) {
 				if (status == STATE_OK)
-					printf("rta %0.3fms", host->rta / 1000);
+					printf(" rta %0.3fms", host->rta / 1000);
 				else if (status==STATE_WARNING && host->rta_status==status)
-					printf("rta %0.3fms > %0.3fms", (float)host->rta / 1000, (float)warn.rta/1000);
+					printf(" rta %0.3fms > %0.3fms", (float)host->rta / 1000, (float)warn.rta/1000);
 				else if (status==STATE_CRITICAL && host->rta_status==status)
-					printf("rta %0.3fms > %0.3fms", (float)host->rta / 1000, (float)crit.rta/1000);
+					printf(" rta %0.3fms > %0.3fms", (float)host->rta / 1000, (float)crit.rta/1000);
 			}
 			/* pl text output */
 			if (pl_mode) {
 				if (status == STATE_OK)
-					printf("lost %u%%", host->pl);
+					printf(" lost %u%%", host->pl);
 				else if (status==STATE_WARNING && host->pl_status==status)
-					printf("lost %u%% > %u%%", host->pl, warn.pl);
+					printf(" lost %u%% > %u%%", host->pl, warn.pl);
 				else if (status==STATE_CRITICAL && host->pl_status==status)
-					printf("lost %u%% > %u%%", host->pl, crit.pl);
+					printf(" lost %u%% > %u%%", host->pl, crit.pl);
 			}
 			/* jitter text output */
 			if (jitter_mode) {
 				if (status == STATE_OK)
-					printf("jitter %0.3fms", (float)host->jitter);
+					printf(" jitter %0.3fms", (float)host->jitter);
 				else if (status==STATE_WARNING && host->jitter_status==status)
-					printf("jitter %0.3fms > %0.3fms", (float)host->jitter, warn.jitter);
+					printf(" jitter %0.3fms > %0.3fms", (float)host->jitter, warn.jitter);
 				else if (status==STATE_CRITICAL && host->jitter_status==status)
-					printf("jitter %0.3fms > %0.3fms", (float)host->jitter, crit.jitter);
+					printf(" jitter %0.3fms > %0.3fms", (float)host->jitter, crit.jitter);
 			}
 			/* mos text output */
 			if (mos_mode) {
 				if (status == STATE_OK)
-					printf("MOS %0.1f", (float)host->mos);
+					printf(" MOS %0.1f", (float)host->mos);
 				else if (status==STATE_WARNING && host->mos_status==status)
-					printf("MOS %0.1f < %0.1f", (float)host->mos, (float)warn.mos);
+					printf(" MOS %0.1f < %0.1f", (float)host->mos, (float)warn.mos);
 				else if (status==STATE_CRITICAL && host->mos_status==status)
-					printf("MOS %0.1f < %0.1f", (float)host->mos, (float)crit.mos);
+					printf(" MOS %0.1f < %0.1f", (float)host->mos, (float)crit.mos);
 			}
 			/* score text output */
 			if (score_mode) {
 				if (status == STATE_OK)
-					printf("Score %u", (int)host->score);
+					printf(" Score %u", (int)host->score);
 				else if (status==STATE_WARNING && host->score_status==status )
-					printf("Score %u < %u", (int)host->score, (int)warn.score);
+					printf(" Score %u < %u", (int)host->score, (int)warn.score);
 				else if (status==STATE_CRITICAL && host->score_status==status )
-					printf("Score %u < %u", (int)host->score, (int)crit.score);
+					printf(" Score %u < %u", (int)host->score, (int)crit.score);
 			}
 			/* order statis text output */
 			if (order_mode) {
 				if (status == STATE_OK)
-					printf("Packets in order");
+					printf(" Packets in order");
 				else if (status==STATE_CRITICAL && host->order_status==status)
-					printf("Packets out of order");
+					printf(" Packets out of order");
 			}
 		}
 		host = host->next;
-- 
cgit v0.10-9-g596f


From e6d2b0b08b72eaad11de8d85d13ea995ebcb9561 Mon Sep 17 00:00:00 2001
From: Danijel Tasov <m@rbfh.de>
Date: Wed, 27 Sep 2023 09:52:34 +0200
Subject: cleanup more merge debris

Signed-off-by: Danijel Tasov <m@rbfh.de>

diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index a537c9c..bb6f85b 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -42,6 +42,7 @@ char *progname;
 const char *copyright = "2005-2008";
 const char *email = "devel@monitoring-plugins.org";
 
+/* what does that do? */
 #ifdef __sun
 #define _XPG4_2
 #endif
@@ -761,11 +762,7 @@ main(int argc, char **argv)
 	}
 
 	host = list;
-//<<<<<<< HEAD FIXME
-	table = (struct rta_host**)malloc(sizeof(struct rta_host **) * targets);
-//=======
-//	table = malloc(sizeof(struct rta_host *) * targets);
-//>>>>>>> jitter-orig
+	table = malloc(sizeof(struct rta_host *) * targets);
 	i = 0;
 	while(host) {
 		host->id = i*packets;
@@ -1473,11 +1470,9 @@ finish(int sig)
 	while(host) {
 		if(debug) puts("");
 		if (rta_mode && host->pl<100) {
-			// FIXME printf("%srta=%0.3fms;%0.3f;%0.3f;0; %srtmax=%0.3fms;;;; %srtmin=%0.3fms;;;; ",(targets > 1) ? host->name : "", (float)host->rta / 1000, (float)warn.rta / 1000, (float)crit.rta / 1000, (targets > 1) ? host->name : "", (float)host->rtmax / 1000, (targets > 1) ? host->name : "", (float)host->rtmin / 1000);
-			printf("%srta=%0.3fms;%0.3f;%0.3f;0; %spl=%u%%;%u;%u;; %srtmax=%0.3fms;;;; %srtmin=%0.3fms;;;; ",
+			printf("%srta=%0.3fms;%0.3f;%0.3f;0; %srtmax=%0.3fms;;;; %srtmin=%0.3fms;;;; ",
 			   (targets > 1) ? host->name : "",
 			   host->rta / 1000, (float)warn.rta / 1000, (float)crit.rta / 1000,
-			   (targets > 1) ? host->name : "", host->pl, warn.pl, crit.pl,
 			   (targets > 1) ? host->name : "", (float)host->rtmax / 1000,
 			   (targets > 1) ? host->name : "", (host->rtmin < INFINITY) ? (float)host->rtmin / 1000 : (float)0);
 		}
-- 
cgit v0.10-9-g596f


From f457615d845ec3bf9d3072511999b69d93c934c5 Mon Sep 17 00:00:00 2001
From: "Alexander A. Klimov" <alexander.klimov@icinga.com>
Date: Wed, 23 Aug 2023 17:33:16 +0200
Subject: Introduce regex_list


diff --git a/lib/utils_disk.h b/lib/utils_disk.h
index 3b5a45f..442fd94 100644
--- a/lib/utils_disk.h
+++ b/lib/utils_disk.h
@@ -10,6 +10,12 @@ struct name_list
   struct name_list *next;
 };
 
+struct regex_list
+{
+  regex_t regex;
+  struct regex_list *next;
+};
+
 struct parameter_list
 {
   char *name;
-- 
cgit v0.10-9-g596f


From d31a696cadb0bba0914d76aad0eb48c6e7962b8e Mon Sep 17 00:00:00 2001
From: "Alexander A. Klimov" <alexander.klimov@icinga.com>
Date: Wed, 23 Aug 2023 18:13:01 +0200
Subject: Introduce np_add_regex()


diff --git a/lib/utils_disk.c b/lib/utils_disk.c
index 582d3ea..ce02fdf 100644
--- a/lib/utils_disk.c
+++ b/lib/utils_disk.c
@@ -40,6 +40,17 @@ np_add_name (struct name_list **list, const char *name)
   *list = new_entry;
 }
 
+/* Initialises a new regex at the begin of list via regcomp(3) */
+int
+np_add_regex (struct regex_list **list, const char *regex, int cflags)
+{
+  struct regex_list *new_entry = (struct regex_list *) malloc (sizeof *new_entry);
+  new_entry->next = *list;
+  *list = new_entry;
+
+  return regcomp(&new_entry->regex, regex, cflags);
+}
+
 /* Initialises a new parameter at the end of list */
 struct parameter_list *
 np_add_parameter(struct parameter_list **list, const char *name)
diff --git a/lib/utils_disk.h b/lib/utils_disk.h
index 442fd94..bda088f 100644
--- a/lib/utils_disk.h
+++ b/lib/utils_disk.h
@@ -41,6 +41,7 @@ struct parameter_list
 void np_add_name (struct name_list **list, const char *name);
 int np_find_name (struct name_list *list, const char *name);
 int np_seen_name (struct name_list *list, const char *name);
+int np_add_regex (struct regex_list **list, const char *regex, int cflags);
 struct parameter_list *np_add_parameter(struct parameter_list **list, const char *name);
 struct parameter_list *np_find_parameter(struct parameter_list *list, const char *name);
 struct parameter_list *np_del_parameter(struct parameter_list *item, struct parameter_list *prev);
-- 
cgit v0.10-9-g596f


From 1f694195b4a6beef30bbbbffa5835a993be97a9c Mon Sep 17 00:00:00 2001
From: "Alexander A. Klimov" <alexander.klimov@icinga.com>
Date: Wed, 23 Aug 2023 18:26:12 +0200
Subject: Introduce np_find_regmatch()


diff --git a/lib/utils_disk.c b/lib/utils_disk.c
index ce02fdf..34401e2 100644
--- a/lib/utils_disk.c
+++ b/lib/utils_disk.c
@@ -29,6 +29,7 @@
 #include "common.h"
 #include "utils_disk.h"
 #include "gl/fsusage.h"
+#include <string.h>
 
 void
 np_add_name (struct name_list **list, const char *name)
@@ -207,6 +208,30 @@ np_find_name (struct name_list *list, const char *name)
   return FALSE;
 }
 
+/* Returns TRUE if name is in list */
+bool
+np_find_regmatch (struct regex_list *list, const char *name)
+{
+  int len;
+  regmatch_t m;
+
+  if (name == NULL) {
+    return false;
+  }
+
+  len = strlen(name);
+
+  for (; list; list = list->next) {
+    /* Emulate a full match as if surrounded with ^( )$
+       by checking whether the match spans the whole name */
+    if (!regexec(&list->regex, name, 1, &m, 0) && m.rm_so == 0 && m.rm_eo == len) {
+      return true;
+    }
+  }
+
+  return false;
+}
+
 int
 np_seen_name(struct name_list *list, const char *name)
 {
diff --git a/lib/utils_disk.h b/lib/utils_disk.h
index bda088f..6b83ac7 100644
--- a/lib/utils_disk.h
+++ b/lib/utils_disk.h
@@ -42,6 +42,7 @@ void np_add_name (struct name_list **list, const char *name);
 int np_find_name (struct name_list *list, const char *name);
 int np_seen_name (struct name_list *list, const char *name);
 int np_add_regex (struct regex_list **list, const char *regex, int cflags);
+bool np_find_regmatch (struct regex_list *list, const char *name);
 struct parameter_list *np_add_parameter(struct parameter_list **list, const char *name);
 struct parameter_list *np_find_parameter(struct parameter_list *list, const char *name);
 struct parameter_list *np_del_parameter(struct parameter_list *item, struct parameter_list *prev);
-- 
cgit v0.10-9-g596f


From 4bb444f3353fbb49086bd0e212b3cad8009761dd Mon Sep 17 00:00:00 2001
From: "Alexander A. Klimov" <alexander.klimov@icinga.com>
Date: Tue, 12 Sep 2023 14:55:00 +0200
Subject: check_disk: make -X a regex list


diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 7dc1c4b..e7e9378 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -93,7 +93,7 @@ static int stat_remote_fs = 0;
 
 /* Linked list of filesystem types to omit.
    If the list is empty, don't exclude any types.  */
-static struct name_list *fs_exclude_list;
+static struct regex_list *fs_exclude_list = NULL;
 
 /* Linked list of filesystem types to check.
    If the list is empty, include all types.  */
@@ -300,7 +300,7 @@ main (int argc, char **argv)
       } else if (me->me_dummy && !show_all_fs) {
         continue;
       /* Skip excluded fstypes */
-      } else if (fs_exclude_list && np_find_name (fs_exclude_list, me->me_type)) {
+      } else if (fs_exclude_list && np_find_regmatch (fs_exclude_list, me->me_type)) {
         continue;
       /* Skip excluded fs's */
       } else if (dp_exclude_list &&
@@ -543,7 +543,7 @@ process_arguments (int argc, char **argv)
   if (argc < 2)
     return ERROR;
 
-  np_add_name(&fs_exclude_list, "iso9660");
+  np_add_regex(&fs_exclude_list, "iso9660", REG_EXTENDED);
 
   for (c = 1; c < argc; c++)
     if (strcmp ("-to", argv[c]) == 0)
@@ -716,7 +716,11 @@ process_arguments (int argc, char **argv)
       np_add_name(&dp_exclude_list, optarg);
       break;
     case 'X':                 /* exclude file system type */
-      np_add_name(&fs_exclude_list, optarg);
+      err = np_add_regex(&fs_exclude_list, optarg, REG_EXTENDED);
+      if (err != 0) {
+        regerror (err, &fs_exclude_list->regex, errbuf, MAX_INPUT_BUFFER);
+        die (STATE_UNKNOWN, "DISK %s: %s - %s\n",_("UNKNOWN"), _("Could not compile regular expression"), errbuf);
+      }
       break;
     case 'N':                 /* include file system type */
       np_add_name(&fs_include_list, optarg);
@@ -1003,8 +1007,8 @@ print_help (void)
   printf (" %s\n", "-u, --units=STRING");
   printf ("    %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)"));
   printf (UT_VERBOSE);
-  printf (" %s\n", "-X, --exclude-type=TYPE");
-  printf ("    %s\n", _("Ignore all filesystems of indicated type (may be repeated)"));
+  printf (" %s\n", "-X, --exclude-type=TYPE_REGEX");
+  printf ("    %s\n", _("Ignore all filesystems of types matching given regex(7) (may be repeated)"));
   printf (" %s\n", "-N, --include-type=TYPE");
   printf ("    %s\n", _("Check only filesystems of indicated type (may be repeated)"));
 
@@ -1037,7 +1041,7 @@ print_usage (void)
   printf ("%s\n", _("Usage:"));
   printf (" %s {-w absolute_limit |-w  percentage_limit%% | -W inode_percentage_limit } {-c absolute_limit|-c percentage_limit%% | -K inode_percentage_limit } {-p path | -x device}\n", progname);
   printf ("[-C] [-E] [-e] [-f] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n");
-  printf ("[-t timeout] [-u unit] [-v] [-X type] [-N type]\n");
+  printf ("[-t timeout] [-u unit] [-v] [-X type_regex] [-N type]\n");
 }
 
 bool
-- 
cgit v0.10-9-g596f


From 677bbd21a97a95bf149a8bbbeac397a92a0e19d2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
 <12514511+RincewindsHat@users.noreply.github.com>
Date: Thu, 28 Sep 2023 12:40:27 +0200
Subject: Update translations


diff --git a/po/de.po b/po/de.po
index 9ea32df..bd95ee6 100644
--- a/po/de.po
+++ b/po/de.po
@@ -9,7 +9,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
-"POT-Creation-Date: 2023-09-22 15:36+0200\n"
+"POT-Creation-Date: 2023-09-28 12:40+0200\n"
 "PO-Revision-Date: 2004-12-23 17:46+0100\n"
 "Last-Translator:  \n"
 "Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins."
@@ -308,6 +308,9 @@ msgstr "UNKNOWN"
 msgid "Must set a threshold value before using -p\n"
 msgstr ""
 
+msgid "Could not compile regular expression"
+msgstr ""
+
 msgid "Must set -E before selecting paths\n"
 msgstr ""
 
@@ -319,9 +322,6 @@ msgid ""
 "explicitly"
 msgstr ""
 
-msgid "Could not compile regular expression"
-msgstr ""
-
 msgid ""
 "Must set a threshold value before using -r/-R/-A (--ereg-path/--eregi-path/--"
 "all)\n"
@@ -446,7 +446,8 @@ msgstr ""
 msgid "Choose bytes, kB, MB, GB, TB (default: MB)"
 msgstr ""
 
-msgid "Ignore all filesystems of indicated type (may be repeated)"
+msgid ""
+"Ignore all filesystems of types matching given regex(7) (may be repeated)"
 msgstr ""
 
 msgid "Check only filesystems of indicated type (may be repeated)"
diff --git a/po/fr.po b/po/fr.po
index 28deb94..7c5e80a 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -10,7 +10,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
-"POT-Creation-Date: 2023-09-22 15:36+0200\n"
+"POT-Creation-Date: 2023-09-28 12:40+0200\n"
 "PO-Revision-Date: 2010-04-21 23:38-0400\n"
 "Last-Translator: \n"
 "Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins."
@@ -307,6 +307,9 @@ msgstr "INCONNU"
 msgid "Must set a threshold value before using -p\n"
 msgstr ""
 
+msgid "Could not compile regular expression"
+msgstr "Impossible de compiler l'expression rationnelle"
+
 msgid "Must set -E before selecting paths\n"
 msgstr ""
 
@@ -318,9 +321,6 @@ msgid ""
 "explicitly"
 msgstr ""
 
-msgid "Could not compile regular expression"
-msgstr "Impossible de compiler l'expression rationnelle"
-
 msgid ""
 "Must set a threshold value before using -r/-R/-A (--ereg-path/--eregi-path/--"
 "all)\n"
@@ -461,7 +461,9 @@ msgstr ""
 msgid "Choose bytes, kB, MB, GB, TB (default: MB)"
 msgstr "Choisissez octets, kb, MB, GB, TB (par défaut: MB)"
 
-msgid "Ignore all filesystems of indicated type (may be repeated)"
+#, fuzzy
+msgid ""
+"Ignore all filesystems of types matching given regex(7) (may be repeated)"
 msgstr ""
 "Ignorer tout les systèmes de fichiers qui correspondent au type indiqué "
 "(peut être utilisé plusieurs fois)"
diff --git a/po/monitoring-plugins.pot b/po/monitoring-plugins.pot
index d019a7e..bb0c650 100644
--- a/po/monitoring-plugins.pot
+++ b/po/monitoring-plugins.pot
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
-"POT-Creation-Date: 2023-09-22 15:36+0200\n"
+"POT-Creation-Date: 2023-09-28 12:40+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -291,6 +291,9 @@ msgstr ""
 msgid "Must set a threshold value before using -p\n"
 msgstr ""
 
+msgid "Could not compile regular expression"
+msgstr ""
+
 msgid "Must set -E before selecting paths\n"
 msgstr ""
 
@@ -302,9 +305,6 @@ msgid ""
 "explicitly"
 msgstr ""
 
-msgid "Could not compile regular expression"
-msgstr ""
-
 msgid ""
 "Must set a threshold value before using -r/-R/-A (--ereg-path/--eregi-path/--"
 "all)\n"
@@ -423,7 +423,8 @@ msgstr ""
 msgid "Choose bytes, kB, MB, GB, TB (default: MB)"
 msgstr ""
 
-msgid "Ignore all filesystems of indicated type (may be repeated)"
+msgid ""
+"Ignore all filesystems of types matching given regex(7) (may be repeated)"
 msgstr ""
 
 msgid "Check only filesystems of indicated type (may be repeated)"
-- 
cgit v0.10-9-g596f


From a0eb21988917f81a369208872c92465785ee866f Mon Sep 17 00:00:00 2001
From: Danijel Tasov <m@rbfh.de>
Date: Thu, 28 Sep 2023 15:41:52 +0200
Subject: update-po

Signed-off-by: Danijel Tasov <m@rbfh.de>

diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index bb6f85b..f7e091a 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1943,7 +1943,7 @@ print_help(void)
   printf ("    %s\n", _("verbose"));
   printf ("\n");
   printf ("%s\n", _("Notes:"));
-  printf ("%s\n", _("If not mode R,P,J,M,S or O is informed, default icmp behavior, RTA and packet loss"));
+  printf (" %s\n", _("If none of R,P,J,M,S or O is specified, default behavior is -R -P"));
   printf (" %s\n", _("The -H switch is optional. Naming a host (or several) to check is not."));
   printf ("\n");
   printf (" %s\n", _("Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%"));
diff --git a/po/de.po b/po/de.po
index 9ea32df..3a34db4 100644
--- a/po/de.po
+++ b/po/de.po
@@ -9,7 +9,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
-"POT-Creation-Date: 2023-09-22 15:36+0200\n"
+"POT-Creation-Date: 2023-09-27 12:16+0200\n"
 "PO-Revision-Date: 2004-12-23 17:46+0100\n"
 "Last-Translator:  \n"
 "Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins."
@@ -5067,6 +5067,25 @@ msgstr "Warning threshold  Integer sein"
 msgid "critical threshold (currently "
 msgstr "Critical threshold muss ein Integer sein"
 
+msgid ""
+"RTA, round trip average,  mode  warning,critical, ex. 100ms,200ms unit in ms"
+msgstr ""
+
+msgid "packet loss mode, ex. 40%,50% , unit in %"
+msgstr ""
+
+msgid "jitter mode  warning,critical, ex. 40.000ms,50.000ms , unit in ms "
+msgstr ""
+
+msgid "MOS mode, between 0 and 4.4  warning,critical, ex. 3.5,3.0"
+msgstr ""
+
+msgid "score  mode, max value 100  warning,critical, ex. 80,70 "
+msgstr ""
+
+msgid "detect out of order ICMP packts "
+msgstr ""
+
 #, fuzzy
 msgid "specify a source IP address or device name"
 msgstr "Hostname oder Serveradresse muss angegeben werden"
@@ -5098,6 +5117,9 @@ msgstr ""
 msgid "verbose"
 msgstr ""
 
+msgid "If none of R,P,J,M,S or O is specified, default behavior is -R -P"
+msgstr ""
+
 msgid "The -H switch is optional. Naming a host (or several) to check is not."
 msgstr ""
 
diff --git a/po/fr.po b/po/fr.po
index 28deb94..da9cf19 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -10,7 +10,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
-"POT-Creation-Date: 2023-09-22 15:36+0200\n"
+"POT-Creation-Date: 2023-09-27 12:16+0200\n"
 "PO-Revision-Date: 2010-04-21 23:38-0400\n"
 "Last-Translator: \n"
 "Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins."
@@ -5286,6 +5286,25 @@ msgstr "Valeurs pour le seuil d'avertissement (actuellement "
 msgid "critical threshold (currently "
 msgstr "Valeurs pour le seuil critique (actuellement "
 
+msgid ""
+"RTA, round trip average,  mode  warning,critical, ex. 100ms,200ms unit in ms"
+msgstr ""
+
+msgid "packet loss mode, ex. 40%,50% , unit in %"
+msgstr ""
+
+msgid "jitter mode  warning,critical, ex. 40.000ms,50.000ms , unit in ms "
+msgstr ""
+
+msgid "MOS mode, between 0 and 4.4  warning,critical, ex. 3.5,3.0"
+msgstr ""
+
+msgid "score  mode, max value 100  warning,critical, ex. 80,70 "
+msgstr ""
+
+msgid "detect out of order ICMP packts "
+msgstr ""
+
 msgid "specify a source IP address or device name"
 msgstr "spécifiez une adresse ou un nom d'hôte"
 
@@ -5316,6 +5335,9 @@ msgstr ""
 msgid "verbose"
 msgstr ""
 
+msgid "If none of R,P,J,M,S or O is specified, default behavior is -R -P"
+msgstr ""
+
 msgid "The -H switch is optional. Naming a host (or several) to check is not."
 msgstr ""
 
diff --git a/po/monitoring-plugins.pot b/po/monitoring-plugins.pot
index d019a7e..b10e73f 100644
--- a/po/monitoring-plugins.pot
+++ b/po/monitoring-plugins.pot
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
-"POT-Creation-Date: 2023-09-22 15:36+0200\n"
+"POT-Creation-Date: 2023-09-27 12:16+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -4892,6 +4892,25 @@ msgstr ""
 msgid "critical threshold (currently "
 msgstr ""
 
+msgid ""
+"RTA, round trip average,  mode  warning,critical, ex. 100ms,200ms unit in ms"
+msgstr ""
+
+msgid "packet loss mode, ex. 40%,50% , unit in %"
+msgstr ""
+
+msgid "jitter mode  warning,critical, ex. 40.000ms,50.000ms , unit in ms "
+msgstr ""
+
+msgid "MOS mode, between 0 and 4.4  warning,critical, ex. 3.5,3.0"
+msgstr ""
+
+msgid "score  mode, max value 100  warning,critical, ex. 80,70 "
+msgstr ""
+
+msgid "detect out of order ICMP packts "
+msgstr ""
+
 msgid "specify a source IP address or device name"
 msgstr ""
 
@@ -4922,6 +4941,9 @@ msgstr ""
 msgid "verbose"
 msgstr ""
 
+msgid "If none of R,P,J,M,S or O is specified, default behavior is -R -P"
+msgstr ""
+
 msgid "The -H switch is optional. Naming a host (or several) to check is not."
 msgstr ""
 
-- 
cgit v0.10-9-g596f


From 6947a8cea9335c2eeefb8929aa663db49ecac5a1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
 <12514511+RincewindsHat@users.noreply.github.com>
Date: Sat, 30 Sep 2023 12:54:21 +0200
Subject: check_disk: Use regex also to include fs types


diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index e7e9378..06576d8 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -97,7 +97,7 @@ static struct regex_list *fs_exclude_list = NULL;
 
 /* Linked list of filesystem types to check.
    If the list is empty, include all types.  */
-static struct name_list *fs_include_list;
+static struct regex_list *fs_include_list;
 
 static struct name_list *dp_exclude_list;
 
@@ -308,7 +308,7 @@ main (int argc, char **argv)
                 np_find_name (dp_exclude_list, me->me_mountdir))) {
         continue;
       /* Skip not included fstypes */
-      } else if (fs_include_list && !np_find_name (fs_include_list, me->me_type)) {
+      } else if (fs_include_list && !np_find_regmatch(fs_include_list, me->me_type)) {
         continue;
       }
     }
@@ -723,7 +723,11 @@ process_arguments (int argc, char **argv)
       }
       break;
     case 'N':                 /* include file system type */
-      np_add_name(&fs_include_list, optarg);
+      err = np_add_regex(&fs_include_list, optarg, REG_EXTENDED);
+      if (err != 0) {
+        regerror (err, &fs_exclude_list->regex, errbuf, MAX_INPUT_BUFFER);
+        die (STATE_UNKNOWN, "DISK %s: %s - %s\n",_("UNKNOWN"), _("Could not compile regular expression"), errbuf);
+      }
       break;
     case 'v':                 /* verbose */
       verbose++;
-- 
cgit v0.10-9-g596f


From 51aa8b2d9d3812b74fb4d15da712a31d549d928b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
 <12514511+RincewindsHat@users.noreply.github.com>
Date: Sat, 30 Sep 2023 12:55:49 +0200
Subject: Document new np_add_regex more and add error handling


diff --git a/lib/utils_disk.c b/lib/utils_disk.c
index 34401e2..884f005 100644
--- a/lib/utils_disk.c
+++ b/lib/utils_disk.c
@@ -41,15 +41,40 @@ np_add_name (struct name_list **list, const char *name)
   *list = new_entry;
 }
 
-/* Initialises a new regex at the begin of list via regcomp(3) */
+/* @brief Initialises a new regex at the begin of list via regcomp(3)
+ *
+ * @details if the regex fails to compile the error code of regcomp(3) is returned
+ * 					and list is not modified, otherwise list is modified to point to the new
+ * 					element
+ * @param list Pointer to a linked list of regex_list elements
+ * @param regex the string containing the regex which should be inserted into the list
+ * @param clags the cflags parameter for regcomp(3)
+ */
 int
 np_add_regex (struct regex_list **list, const char *regex, int cflags)
 {
   struct regex_list *new_entry = (struct regex_list *) malloc (sizeof *new_entry);
-  new_entry->next = *list;
-  *list = new_entry;
 
-  return regcomp(&new_entry->regex, regex, cflags);
+	if (new_entry == NULL) {
+		die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
+				strerror(errno));
+	}
+
+  int regcomp_result = regcomp(&new_entry->regex, regex, cflags);
+
+	if (!regcomp_result) {
+		// regcomp succeded
+		new_entry->next = *list;
+		*list = new_entry;
+
+		return 0;
+	} else {
+		// regcomp failed
+		free(new_entry);
+
+		return regcomp_result;
+	}
+
 }
 
 /* Initialises a new parameter at the end of list */
-- 
cgit v0.10-9-g596f


From 128a24be2296af175c5e7adf875f9d0e8a619278 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
 <12514511+RincewindsHat@users.noreply.github.com>
Date: Sat, 30 Sep 2023 12:59:26 +0200
Subject: Fix typo


diff --git a/lib/utils_disk.c b/lib/utils_disk.c
index 884f005..f5ac0b3 100644
--- a/lib/utils_disk.c
+++ b/lib/utils_disk.c
@@ -63,7 +63,7 @@ np_add_regex (struct regex_list **list, const char *regex, int cflags)
   int regcomp_result = regcomp(&new_entry->regex, regex, cflags);
 
 	if (!regcomp_result) {
-		// regcomp succeded
+		// regcomp succeeded
 		new_entry->next = *list;
 		*list = new_entry;
 
-- 
cgit v0.10-9-g596f


From 819f90b726805f50d6de72f06b58bf02744f4763 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
 <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 1 Oct 2023 00:41:55 +0200
Subject: check_disk: Change usage for --include-type to indicated regexes are
 now possible


diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 06576d8..2f066c7 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -1013,8 +1013,8 @@ print_help (void)
   printf (UT_VERBOSE);
   printf (" %s\n", "-X, --exclude-type=TYPE_REGEX");
   printf ("    %s\n", _("Ignore all filesystems of types matching given regex(7) (may be repeated)"));
-  printf (" %s\n", "-N, --include-type=TYPE");
-  printf ("    %s\n", _("Check only filesystems of indicated type (may be repeated)"));
+  printf (" %s\n", "-N, --include-type=TYPE_REGEX");
+  printf ("    %s\n", _("Check only filesystems where the type matches this given regex(7) (may be repeated)"));
 
   printf ("\n");
   printf ("%s\n", _("General usage hints:"));
-- 
cgit v0.10-9-g596f


From 15ceeaf46ed893e86499f25578fd1a27945b2677 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
 <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 1 Oct 2023 00:48:10 +0200
Subject: Update translations


diff --git a/po/de.po b/po/de.po
index bd95ee6..c25a2b4 100644
--- a/po/de.po
+++ b/po/de.po
@@ -9,7 +9,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
-"POT-Creation-Date: 2023-09-28 12:40+0200\n"
+"POT-Creation-Date: 2023-10-01 00:46+0200\n"
 "PO-Revision-Date: 2004-12-23 17:46+0100\n"
 "Last-Translator:  \n"
 "Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins."
@@ -450,7 +450,9 @@ msgid ""
 "Ignore all filesystems of types matching given regex(7) (may be repeated)"
 msgstr ""
 
-msgid "Check only filesystems of indicated type (may be repeated)"
+msgid ""
+"Check only filesystems where the type matches this given regex(7) (may be "
+"repeated)"
 msgstr ""
 
 msgid "General usage hints:"
diff --git a/po/fr.po b/po/fr.po
index 7c5e80a..321a230 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -10,7 +10,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
-"POT-Creation-Date: 2023-09-28 12:40+0200\n"
+"POT-Creation-Date: 2023-10-01 00:46+0200\n"
 "PO-Revision-Date: 2010-04-21 23:38-0400\n"
 "Last-Translator: \n"
 "Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins."
@@ -469,7 +469,9 @@ msgstr ""
 "(peut être utilisé plusieurs fois)"
 
 #, fuzzy
-msgid "Check only filesystems of indicated type (may be repeated)"
+msgid ""
+"Check only filesystems where the type matches this given regex(7) (may be "
+"repeated)"
 msgstr ""
 "Ignorer tout les systèmes de fichiers qui correspondent au type indiqué "
 "(peut être utilisé plusieurs fois)"
@@ -5339,6 +5341,12 @@ msgstr ""
 msgid "The -v switch can be specified several times for increased verbosity."
 msgstr ""
 
+#, fuzzy
+#~ msgid "Check only filesystems of indicated type (may be repeated)"
+#~ msgstr ""
+#~ "Ignorer tout les systèmes de fichiers qui correspondent au type indiqué "
+#~ "(peut être utilisé plusieurs fois)"
+
 #~ msgid "Path or partition (may be repeated)"
 #~ msgstr "Répertoire ou partition (peut être utilisé plusieurs fois)"
 
diff --git a/po/monitoring-plugins.pot b/po/monitoring-plugins.pot
index bb0c650..54d79fe 100644
--- a/po/monitoring-plugins.pot
+++ b/po/monitoring-plugins.pot
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
-"POT-Creation-Date: 2023-09-28 12:40+0200\n"
+"POT-Creation-Date: 2023-10-01 00:46+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -427,7 +427,9 @@ msgid ""
 "Ignore all filesystems of types matching given regex(7) (may be repeated)"
 msgstr ""
 
-msgid "Check only filesystems of indicated type (may be repeated)"
+msgid ""
+"Check only filesystems where the type matches this given regex(7) (may be "
+"repeated)"
 msgstr ""
 
 msgid "General usage hints:"
-- 
cgit v0.10-9-g596f


From e695a81b137e50ebbdf3d78a371a3e2201835440 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 1 Oct 2023 13:40:50 +0200
Subject: Remove unnecessary type defines


diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c
index 2d22619..312de54 100644
--- a/plugins-root/check_dhcp.c
+++ b/plugins-root/check_dhcp.c
@@ -98,10 +98,6 @@ static struct strbuf dat = {AREA_SZ, 0, (char *)dat_area};
 #define GOT_INTR 4
 #define GOT_ERR 128
 
-#define u_int8_t	 uint8_t
-#define u_int16_t	uint16_t
-#define u_int32_t	uint32_t
-
 static int get_msg(int);
 static int check_ctrl(int);
 static int put_ctrl(int, int, int);
@@ -132,13 +128,13 @@ long mac_addr_dlpi( const char *, int, u_char *);
 
 
 typedef struct dhcp_packet_struct{
-        u_int8_t  op;                   /* packet type */
-        u_int8_t  htype;                /* type of hardware address for this machine (Ethernet, etc) */
-        u_int8_t  hlen;                 /* length of hardware address (of this machine) */
-        u_int8_t  hops;                 /* hops */
-        u_int32_t xid;                  /* random transaction id number - chosen by this machine */
-        u_int16_t secs;                 /* seconds used in timing */
-        u_int16_t flags;                /* flags */
+        uint8_t  op;                   /* packet type */
+        uint8_t  htype;                /* type of hardware address for this machine (Ethernet, etc) */
+        uint8_t  hlen;                 /* length of hardware address (of this machine) */
+        uint8_t  hops;                 /* hops */
+        uint32_t xid;                  /* random transaction id number - chosen by this machine */
+        uint16_t secs;                 /* seconds used in timing */
+        uint16_t flags;                /* flags */
         struct in_addr ciaddr;          /* IP address of this machine (if we already have one) */
         struct in_addr yiaddr;          /* IP address of this machine (offered by the DHCP server) */
         struct in_addr siaddr;          /* IP address of next server */
@@ -153,9 +149,9 @@ typedef struct dhcp_packet_struct{
 typedef struct dhcp_offer_struct{
 	struct in_addr server_address;   /* address of DHCP server that sent this offer */
 	struct in_addr offered_address;  /* the IP address that was offered to us */
-	u_int32_t lease_time;            /* lease time in seconds */
-	u_int32_t renewal_time;          /* renewal time in seconds */
-	u_int32_t rebinding_time;        /* rebinding time in seconds */
+	uint32_t lease_time;            /* lease time in seconds */
+	uint32_t renewal_time;          /* renewal time in seconds */
+	uint32_t rebinding_time;        /* rebinding time in seconds */
 	struct dhcp_offer_struct *next;
         }dhcp_offer;
 
@@ -198,7 +194,7 @@ typedef struct requested_server_struct{
 #define ETHERNET_HARDWARE_ADDRESS            1     /* used in htype field of dhcp packet */
 #define ETHERNET_HARDWARE_ADDRESS_LENGTH     6     /* length of Ethernet hardware addresses */
 
-u_int8_t unicast = 0;        /* unicast mode: mimic a DHCP relay */
+uint8_t unicast = 0;        /* unicast mode: mimic a DHCP relay */
 struct in_addr my_ip;        /* our address (required for relay) */
 struct in_addr dhcp_ip;      /* server to query (if in unicast mode) */
 unsigned char client_hardware_address[MAX_DHCP_CHADDR_LENGTH]="";
@@ -206,11 +202,11 @@ unsigned char *user_specified_mac=NULL;
 
 char network_interface_name[IFNAMSIZ]="eth0";
 
-u_int32_t packet_xid=0;
+uint32_t packet_xid=0;
 
-u_int32_t dhcp_lease_time=0;
-u_int32_t dhcp_renewal_time=0;
-u_int32_t dhcp_rebinding_time=0;
+uint32_t dhcp_lease_time=0;
+uint32_t dhcp_renewal_time=0;
+uint32_t dhcp_rebinding_time=0;
 
 int dhcpoffer_timeout=2;
 
@@ -948,7 +944,7 @@ int get_results(void){
 	dhcp_offer *temp_offer;
 	requested_server *temp_server;
 	int result;
-	u_int32_t max_lease_time=0;
+	uint32_t max_lease_time=0;
 
 	received_requested_address=FALSE;
 
-- 
cgit v0.10-9-g596f


From 07510639189539817cee805caa5b6471427b7964 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 1 Oct 2023 13:55:22 +0200
Subject: Homogenize whitespace usage


diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c
index 312de54..99df3d2 100644
--- a/plugins-root/check_dhcp.c
+++ b/plugins-root/check_dhcp.c
@@ -1,37 +1,37 @@
 /*****************************************************************************
-* 
-* Monitoring check_dhcp plugin
-* 
-* License: GPL
-* Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org)
-* Copyright (c) 2001-2007 Monitoring Plugins Development Team
-* 
-* Description:
-* 
-* This file contains the check_dhcp plugin
-* 
-* This plugin tests the availability of DHCP servers on a network.
-* 
-* Unicast mode was originally implemented by Heiti of Boras Kommun with
-* general improvements as well as usability fixes and "forward"-porting by
-* Andreas Ericsson of OP5 AB.
-* 
-* 
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-* 
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU General Public License for more details.
-* 
-* You should have received a copy of the GNU General Public License
-* along with this program.  If not, see <http://www.gnu.org/licenses/>.
-* 
-* 
-*****************************************************************************/
+ *
+ * Monitoring check_dhcp plugin
+ *
+ * License: GPL
+ * Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org)
+ * Copyright (c) 2001-2007 Monitoring Plugins Development Team
+ *
+ * Description:
+ *
+ * This file contains the check_dhcp plugin
+ *
+ * This plugin tests the availability of DHCP servers on a network.
+ *
+ * Unicast mode was originally implemented by Heiti of Boras Kommun with
+ * general improvements as well as usability fixes and "forward"-porting by
+ * Andreas Ericsson of OP5 AB.
+ *
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ *****************************************************************************/
 
 const char *progname = "check_dhcp";
 const char *copyright = "2001-2007";
@@ -128,22 +128,22 @@ long mac_addr_dlpi( const char *, int, u_char *);
 
 
 typedef struct dhcp_packet_struct{
-        uint8_t  op;                   /* packet type */
-        uint8_t  htype;                /* type of hardware address for this machine (Ethernet, etc) */
-        uint8_t  hlen;                 /* length of hardware address (of this machine) */
-        uint8_t  hops;                 /* hops */
-        uint32_t xid;                  /* random transaction id number - chosen by this machine */
-        uint16_t secs;                 /* seconds used in timing */
-        uint16_t flags;                /* flags */
-        struct in_addr ciaddr;          /* IP address of this machine (if we already have one) */
-        struct in_addr yiaddr;          /* IP address of this machine (offered by the DHCP server) */
-        struct in_addr siaddr;          /* IP address of next server */
-        struct in_addr giaddr;          /* IP address of DHCP relay */
-        unsigned char chaddr [MAX_DHCP_CHADDR_LENGTH];      /* hardware address of this machine */
-        char sname [MAX_DHCP_SNAME_LENGTH];    /* name of DHCP server */
-        char file [MAX_DHCP_FILE_LENGTH];      /* boot file name (used for diskless booting?) */
+	uint8_t  op;                   /* packet type */
+	uint8_t  htype;                /* type of hardware address for this machine (Ethernet, etc) */
+	uint8_t  hlen;                 /* length of hardware address (of this machine) */
+	uint8_t  hops;                 /* hops */
+	uint32_t xid;                  /* random transaction id number - chosen by this machine */
+	uint16_t secs;                 /* seconds used in timing */
+	uint16_t flags;                /* flags */
+	struct in_addr ciaddr;          /* IP address of this machine (if we already have one) */
+	struct in_addr yiaddr;          /* IP address of this machine (offered by the DHCP server) */
+	struct in_addr siaddr;          /* IP address of next server */
+	struct in_addr giaddr;          /* IP address of DHCP relay */
+	unsigned char chaddr [MAX_DHCP_CHADDR_LENGTH];      /* hardware address of this machine */
+	char sname [MAX_DHCP_SNAME_LENGTH];    /* name of DHCP server */
+	char file [MAX_DHCP_FILE_LENGTH];      /* boot file name (used for diskless booting?) */
 	char options[MAX_DHCP_OPTIONS_LENGTH];  /* options */
-        }dhcp_packet;
+}dhcp_packet;
 
 
 typedef struct dhcp_offer_struct{
@@ -153,14 +153,14 @@ typedef struct dhcp_offer_struct{
 	uint32_t renewal_time;          /* renewal time in seconds */
 	uint32_t rebinding_time;        /* rebinding time in seconds */
 	struct dhcp_offer_struct *next;
-        }dhcp_offer;
+}dhcp_offer;
 
 
 typedef struct requested_server_struct{
 	struct in_addr server_address;
 	int answered;
 	struct requested_server_struct *next;
-        }requested_server;
+}requested_server;
 
 
 #define BOOTREQUEST     1
@@ -264,7 +264,7 @@ int main(int argc, char **argv){
 
 	if(process_arguments(argc,argv)!=OK){
 		usage4 (_("Could not parse arguments"));
-		}
+	}
 
 	/* create socket for DHCP communications */
 	dhcp_socket=create_dhcp_socket();
@@ -295,7 +295,7 @@ int main(int argc, char **argv){
 	free_requested_server_list();
 
 	return result;
-        }
+}
 
 
 
@@ -310,83 +310,83 @@ int get_hardware_address(int sock,char *interface_name){
 
 	/* try and grab hardware address of requested interface */
 	if(ioctl(sock,SIOCGIFHWADDR,&ifr)<0){
-                printf(_("Error: Could not get hardware address of interface '%s'\n"),interface_name);
+		printf(_("Error: Could not get hardware address of interface '%s'\n"),interface_name);
 		exit(STATE_UNKNOWN);
-	        }
+	}
 
 	memcpy(&client_hardware_address[0],&ifr.ifr_hwaddr.sa_data,6);
 
 #elif defined(__bsd__)
-						/* King 2004	see ACKNOWLEDGEMENTS */
-
-        size_t                  len;
-        int                     mib[6];
-        char                    *buf;
-        unsigned char           *ptr;
-        struct if_msghdr        *ifm;
-        struct sockaddr_dl      *sdl;
-
-        mib[0] = CTL_NET;
-        mib[1] = AF_ROUTE;
-        mib[2] = 0;
-        mib[3] = AF_LINK;
-        mib[4] = NET_RT_IFLIST;
-
-        if((mib[5] = if_nametoindex(interface_name)) == 0){
-                printf(_("Error: if_nametoindex error - %s.\n"), strerror(errno));
-                exit(STATE_UNKNOWN);
-		}
+	/* King 2004	see ACKNOWLEDGEMENTS */
+
+	size_t                  len;
+	int                     mib[6];
+	char                    *buf;
+	unsigned char           *ptr;
+	struct if_msghdr        *ifm;
+	struct sockaddr_dl      *sdl;
+
+	mib[0] = CTL_NET;
+	mib[1] = AF_ROUTE;
+	mib[2] = 0;
+	mib[3] = AF_LINK;
+	mib[4] = NET_RT_IFLIST;
+
+	if((mib[5] = if_nametoindex(interface_name)) == 0){
+		printf(_("Error: if_nametoindex error - %s.\n"), strerror(errno));
+		exit(STATE_UNKNOWN);
+	}
 
-        if(sysctl(mib, 6, NULL, &len, NULL, 0) < 0){
-                printf(_("Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n"), interface_name, strerror(errno));
-                exit(STATE_UNKNOWN);
-		}
+	if(sysctl(mib, 6, NULL, &len, NULL, 0) < 0){
+		printf(_("Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n"), interface_name, strerror(errno));
+		exit(STATE_UNKNOWN);
+	}
 
-        if((buf = malloc(len)) == NULL){
-                printf(_("Error: Couldn't get hardware address from interface %s. malloc error - %s.\n"), interface_name, strerror(errno));
-                exit(4);
-		}
+	if((buf = malloc(len)) == NULL){
+		printf(_("Error: Couldn't get hardware address from interface %s. malloc error - %s.\n"), interface_name, strerror(errno));
+		exit(4);
+	}
 
-        if(sysctl(mib, 6, buf, &len, NULL, 0) < 0){
-                printf(_("Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n"), interface_name, strerror(errno));
-                exit(STATE_UNKNOWN);
-		}
+	if(sysctl(mib, 6, buf, &len, NULL, 0) < 0){
+		printf(_("Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n"), interface_name, strerror(errno));
+		exit(STATE_UNKNOWN);
+	}
 
-        ifm = (struct if_msghdr *)buf;
-        sdl = (struct sockaddr_dl *)(ifm + 1);
-        ptr = (unsigned char *)LLADDR(sdl);
-        memcpy(&client_hardware_address[0], ptr, 6) ;
-						/* King 2004 */
+	ifm = (struct if_msghdr *)buf;
+	sdl = (struct sockaddr_dl *)(ifm + 1);
+	ptr = (unsigned char *)LLADDR(sdl);
+	memcpy(&client_hardware_address[0], ptr, 6) ;
+	/* King 2004 */
 
 #elif defined(__sun__) || defined(__solaris__)
 
-						/* Kompf 2000-2003	see ACKNOWLEDGEMENTS */
+	/* Kompf 2000-2003	see ACKNOWLEDGEMENTS */
 	long stat;
 	char dev[20] = "/dev/";
 	char *p;
 	int unit;
 
-    /* get last number from interfacename, eg lnc0, e1000g0*/
-    int i;
-    p = interface_name + strlen(interface_name) -1;
+	/* get last number from interfacename, eg lnc0, e1000g0*/
+	int i;
+	p = interface_name + strlen(interface_name) -1;
 	for(i = strlen(interface_name) -1; i > 0; p--) {
 		if(isalpha(*p))
-            break;
-    }
-    p++;
+			break;
+	}
+	p++;
 	if( p != interface_name ){
 		unit = atoi(p) ;
 		strncat(dev, interface_name, 6) ;
-		}
+	}
 	else{
 		printf(_("Error: can't find unit number in interface_name (%s) - expecting TypeNumber eg lnc0.\n"), interface_name);
 		exit(STATE_UNKNOWN);
-		}
+	}
 	stat = mac_addr_dlpi(dev, unit, client_hardware_address);
 	if(stat != 0){
 		printf(_("Error: can't read MAC address from DLPI streams interface for device %s unit %d.\n"), dev, unit);
 		exit(STATE_UNKNOWN);
-		}
+	}
 
 #elif defined(__hpux__)
 
@@ -398,8 +398,8 @@ int get_hardware_address(int sock,char *interface_name){
 	if(stat != 0){
 		printf(_("Error: can't read MAC address from DLPI streams interface for device %s unit %d.\n"), dev, unit);
 		exit(STATE_UNKNOWN);
-		}
-						/* Kompf 2000-2003 */
+	}
+	/* Kompf 2000-2003 */
 
 #else
 	printf(_("Error: can't get MAC address for this architecture.  Use the --mac option.\n"));
@@ -410,7 +410,7 @@ int get_hardware_address(int sock,char *interface_name){
 		print_hardware_address(client_hardware_address);
 
 	return OK;
-        }
+}
 
 /* determines IP address of the client interface */
 int get_ip_address(int sock,char *interface_name){
@@ -422,9 +422,9 @@ int get_ip_address(int sock,char *interface_name){
 
 	if(ioctl(sock,SIOCGIFADDR,&ifr)<0){
 		printf(_("Error: Cannot determine IP address of interface %s\n"),
-			interface_name);
+				interface_name);
 		exit(STATE_UNKNOWN);
-		}
+	}
 
 	my_ip=((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr;
 
@@ -437,13 +437,13 @@ int get_ip_address(int sock,char *interface_name){
 		printf(_("Pretending to be relay client %s\n"),inet_ntoa(my_ip));
 
 	return OK;
-	}
+}
 
 /* sends a DHCPDISCOVER broadcast message in an attempt to find DHCP servers */
 int send_dhcp_discover(int sock){
 	dhcp_packet discover_packet;
 	struct sockaddr_in sockaddr_broadcast;
-    unsigned short opts;
+	unsigned short opts;
 
 
 	/* clear the packet data structure */
@@ -484,7 +484,7 @@ int send_dhcp_discover(int sock){
 	discover_packet.options[2]='\x53';
 	discover_packet.options[3]='\x63';
 
-    opts = 4;
+	opts = 4;
 	/* DHCP message type is embedded in options field */
 	discover_packet.options[opts++]=DHCP_OPTION_MESSAGE_TYPE;    /* DHCP message type option identifier */
 	discover_packet.options[opts++]='\x01';               /* DHCP message option length in bytes */
@@ -496,7 +496,7 @@ int send_dhcp_discover(int sock){
 		discover_packet.options[opts++]='\x04';
 		memcpy(&discover_packet.options[opts],&requested_address,sizeof(requested_address));
 		opts += sizeof(requested_address);
-	        }
+	}
 	discover_packet.options[opts++]=DHCP_OPTION_END;
 
 	/* unicast fields */
@@ -507,8 +507,8 @@ int send_dhcp_discover(int sock){
 	discover_packet.hops = unicast ? 1 : 0;
 
 	/* send the DHCPDISCOVER packet to broadcast address */
-        sockaddr_broadcast.sin_family=AF_INET;
-        sockaddr_broadcast.sin_port=htons(DHCP_SERVER_PORT);
+	sockaddr_broadcast.sin_family=AF_INET;
+	sockaddr_broadcast.sin_port=htons(DHCP_SERVER_PORT);
 	sockaddr_broadcast.sin_addr.s_addr = unicast ? dhcp_ip.s_addr : INADDR_BROADCAST;
 	bzero(&sockaddr_broadcast.sin_zero,sizeof(sockaddr_broadcast.sin_zero));
 
@@ -520,7 +520,7 @@ int send_dhcp_discover(int sock){
 		printf("DHCDISCOVER yiaddr:  %s\n",inet_ntoa(discover_packet.yiaddr));
 		printf("DHCDISCOVER siaddr:  %s\n",inet_ntoa(discover_packet.siaddr));
 		printf("DHCDISCOVER giaddr:  %s\n",inet_ntoa(discover_packet.giaddr));
-		}
+	}
 
 	/* send the DHCPDISCOVER packet out */
 	send_dhcp_packet(&discover_packet,sizeof(discover_packet),sock,&sockaddr_broadcast);
@@ -529,7 +529,7 @@ int send_dhcp_discover(int sock){
 		printf("\n\n");
 
 	return OK;
-        }
+}
 
 
 
@@ -569,13 +569,13 @@ int get_dhcp_offer(int sock){
 				printf(_("Result=ERROR\n"));
 
 			continue;
-		        }
+		}
 		else{
 			if(verbose)
 				printf(_("Result=OK\n"));
 
 			responses++;
-		        }
+		}
 
 		/* The "source" is either a server or a relay. */
 		/* Save a copy of "source" into "via" even if it's via itself */
@@ -585,7 +585,7 @@ int get_dhcp_offer(int sock){
 			printf(_("DHCPOFFER from IP address %s"),inet_ntoa(source.sin_addr));
 			printf(_(" via %s\n"),inet_ntoa(via.sin_addr));
 			printf("DHCPOFFER XID: %u (0x%X)\n",ntohl(offer_packet.xid),ntohl(offer_packet.xid));
-			}
+		}
 
 		/* check packet xid to see if its the same as the one we used in the discover packet */
 		if(ntohl(offer_packet.xid)!=packet_xid){
@@ -593,7 +593,7 @@ int get_dhcp_offer(int sock){
 				printf(_("DHCPOFFER XID (%u) did not match DHCPDISCOVER XID (%u) - ignoring packet\n"),ntohl(offer_packet.xid),packet_xid);
 
 			continue;
-		        }
+		}
 
 		/* check hardware address */
 		result=OK;
@@ -606,7 +606,7 @@ int get_dhcp_offer(int sock){
 
 			if(offer_packet.chaddr[x]!=client_hardware_address[x])
 				result=ERROR;
-			}
+		}
 		if(verbose)
 			printf("\n");
 
@@ -615,27 +615,27 @@ int get_dhcp_offer(int sock){
 				printf(_("DHCPOFFER hardware address did not match our own - ignoring packet\n"));
 
 			continue;
-		        }
+		}
 
 		if(verbose){
 			printf("DHCPOFFER ciaddr: %s\n",inet_ntoa(offer_packet.ciaddr));
 			printf("DHCPOFFER yiaddr: %s\n",inet_ntoa(offer_packet.yiaddr));
 			printf("DHCPOFFER siaddr: %s\n",inet_ntoa(offer_packet.siaddr));
 			printf("DHCPOFFER giaddr: %s\n",inet_ntoa(offer_packet.giaddr));
-			}
+		}
 
 		add_dhcp_offer(source.sin_addr,&offer_packet);
 
 		valid_responses++;
-	        }
+	}
 
 	if(verbose){
 		printf(_("Total responses seen on the wire: %d\n"),responses);
 		printf(_("Valid responses for this machine: %d\n"),valid_responses);
-		}
+	}
 
 	return OK;
-        }
+}
 
 
 
@@ -652,14 +652,14 @@ int send_dhcp_packet(void *buffer, int buffer_size, int sock, struct sockaddr_in
 		return ERROR;
 
 	return OK;
-        }
+}
 
 
 
 /* receives a DHCP packet */
 int receive_dhcp_packet(void *buffer, int buffer_size, int sock, int timeout, struct sockaddr_in *address){
-        struct timeval tv;
-        fd_set readfds;
+	struct timeval tv;
+	fd_set readfds;
 	fd_set oobfds;
 	int recv_result;
 	socklen_t address_size;
@@ -667,88 +667,88 @@ int receive_dhcp_packet(void *buffer, int buffer_size, int sock, int timeout, st
 	int nfound;
 
 
-        /* wait for data to arrive (up time timeout) */
-        tv.tv_sec=timeout;
-        tv.tv_usec=0;
-        FD_ZERO(&readfds);
-        FD_ZERO(&oobfds);
-        FD_SET(sock,&readfds);
-        FD_SET(sock,&oobfds);
-        nfound = select(sock+1,&readfds,NULL,&oobfds,&tv);
+	/* wait for data to arrive (up time timeout) */
+	tv.tv_sec=timeout;
+	tv.tv_usec=0;
+	FD_ZERO(&readfds);
+	FD_ZERO(&oobfds);
+	FD_SET(sock,&readfds);
+	FD_SET(sock,&oobfds);
+	nfound = select(sock+1,&readfds,NULL,&oobfds,&tv);
 
-        /* make sure some data has arrived */
-        if(!FD_ISSET(sock,&readfds)){
+	/* make sure some data has arrived */
+	if(!FD_ISSET(sock,&readfds)){
 		if(verbose)
-                	printf(_("No (more) data received (nfound: %d)\n"), nfound);
-                return ERROR;
-                }
+			printf(_("No (more) data received (nfound: %d)\n"), nfound);
+		return ERROR;
+	}
 
-        else{
+	else{
 		bzero(&source_address,sizeof(source_address));
 		address_size=sizeof(source_address);
-                recv_result=recvfrom(sock,(char *)buffer,buffer_size,0,(struct sockaddr *)&source_address,&address_size);
+		recv_result=recvfrom(sock,(char *)buffer,buffer_size,0,(struct sockaddr *)&source_address,&address_size);
 		if(verbose)
 			printf("recv_result: %d\n",recv_result);
 
-                if(recv_result==-1){
+		if(recv_result==-1){
 			if(verbose){
 				printf(_("recvfrom() failed, "));
 				printf("errno: (%d) -> %s\n",errno,strerror(errno));
-				}
-                        return ERROR;
-                        }
+			}
+			return ERROR;
+		}
 		else{
 			if(verbose){
 				printf(_("receive_dhcp_packet() result: %d\n"),recv_result);
 				printf(_("receive_dhcp_packet() source: %s\n"),inet_ntoa(source_address.sin_addr));
-				}
+			}
 
 			memcpy(address,&source_address,sizeof(source_address));
 			return OK;
-		        }
-                }
+		}
+	}
 
 	return OK;
-        }
+}
 
 
 /* creates a socket for DHCP communication */
 int create_dhcp_socket(void){
-        struct sockaddr_in myname;
+	struct sockaddr_in myname;
 	struct ifreq interface;
-        int sock;
-        int flag=1;
+	int sock;
+	int flag=1;
 
-        /* Set up the address we're going to bind to. */
+	/* Set up the address we're going to bind to. */
 	bzero(&myname,sizeof(myname));
-        myname.sin_family=AF_INET;
-        /* listen to DHCP server port if we're in unicast mode */
-        myname.sin_port = htons(unicast ? DHCP_SERVER_PORT : DHCP_CLIENT_PORT);
-        myname.sin_addr.s_addr = unicast ? my_ip.s_addr : INADDR_ANY;
-        bzero(&myname.sin_zero,sizeof(myname.sin_zero));
+	myname.sin_family=AF_INET;
+	/* listen to DHCP server port if we're in unicast mode */
+	myname.sin_port = htons(unicast ? DHCP_SERVER_PORT : DHCP_CLIENT_PORT);
+	myname.sin_addr.s_addr = unicast ? my_ip.s_addr : INADDR_ANY;
+	bzero(&myname.sin_zero,sizeof(myname.sin_zero));
 
-        /* create a socket for DHCP communications */
+	/* create a socket for DHCP communications */
 	sock=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
-        if(sock<0){
+	if(sock<0){
 		printf(_("Error: Could not create socket!\n"));
 		exit(STATE_UNKNOWN);
-	        }
+	}
 
 	if(verbose)
 		printf("DHCP socket: %d\n",sock);
 
-        /* set the reuse address flag so we don't get errors when restarting */
-        flag=1;
-        if(setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(char *)&flag,sizeof(flag))<0){
+	/* set the reuse address flag so we don't get errors when restarting */
+	flag=1;
+	if(setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(char *)&flag,sizeof(flag))<0){
 		printf(_("Error: Could not set reuse address option on DHCP socket!\n"));
 		exit(STATE_UNKNOWN);
-	        }
+	}
 
-        /* set the broadcast option - we need this to listen to DHCP broadcast messages */
-        if(!unicast && setsockopt(sock,SOL_SOCKET,SO_BROADCAST,(char *)&flag,sizeof flag)<0){
+	/* set the broadcast option - we need this to listen to DHCP broadcast messages */
+	if(!unicast && setsockopt(sock,SOL_SOCKET,SO_BROADCAST,(char *)&flag,sizeof flag)<0){
 		printf(_("Error: Could not set broadcast option on DHCP socket!\n"));
 		exit(STATE_UNKNOWN);
-	        }
+	}
 
 	/* bind socket to interface */
 #if defined(__linux__)
@@ -757,21 +757,21 @@ int create_dhcp_socket(void){
 	if(setsockopt(sock,SOL_SOCKET,SO_BINDTODEVICE,(char *)&interface,sizeof(interface))<0){
 		printf(_("Error: Could not bind socket to interface %s.  Check your privileges...\n"),network_interface_name);
 		exit(STATE_UNKNOWN);
-	        }
+	}
 
 #else
 	strncpy(interface.ifr_name,network_interface_name,IFNAMSIZ-1);
 	interface.ifr_name[IFNAMSIZ-1]='\0';
 #endif
 
-        /* bind the socket */
-        if(bind(sock,(struct sockaddr *)&myname,sizeof(myname))<0){
+	/* bind the socket */
+	if(bind(sock,(struct sockaddr *)&myname,sizeof(myname))<0){
 		printf(_("Error: Could not bind to DHCP socket (port %d)!  Check your privileges...\n"),DHCP_CLIENT_PORT);
 		exit(STATE_UNKNOWN);
-	        }
+	}
 
-        return sock;
-        }
+	return sock;
+}
 
 
 /* closes DHCP socket */
@@ -780,7 +780,7 @@ int close_dhcp_socket(int sock){
 	close(sock);
 
 	return OK;
-        }
+}
 
 
 /* adds a requested server address to list in memory */
@@ -803,7 +803,7 @@ int add_requested_server(struct in_addr server_address){
 		printf(_("Requested server address: %s\n"),inet_ntoa(new_server->server_address));
 
 	return OK;
-        }
+}
 
 
 
@@ -836,29 +836,29 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){
 
 		/* get option data */
 		switch(option_type){
-		case DHCP_OPTION_LEASE_TIME:
-			memcpy(&dhcp_lease_time, &offer_packet->options[x],sizeof(dhcp_lease_time));
-			dhcp_lease_time = ntohl(dhcp_lease_time);
-			break;
-		case DHCP_OPTION_RENEWAL_TIME:
-			memcpy(&dhcp_renewal_time, &offer_packet->options[x],sizeof(dhcp_renewal_time));
-			dhcp_renewal_time = ntohl(dhcp_renewal_time);
-			break;
-		case DHCP_OPTION_REBINDING_TIME:
-			memcpy(&dhcp_rebinding_time, &offer_packet->options[x],sizeof(dhcp_rebinding_time));
-			dhcp_rebinding_time = ntohl(dhcp_rebinding_time);
-			break;
-		case DHCP_OPTION_SERVER_IDENTIFIER:
-			memcpy(&serv_ident.s_addr, &offer_packet->options[x],sizeof(serv_ident.s_addr));
-			break;
-			}
+			case DHCP_OPTION_LEASE_TIME:
+				memcpy(&dhcp_lease_time, &offer_packet->options[x],sizeof(dhcp_lease_time));
+				dhcp_lease_time = ntohl(dhcp_lease_time);
+				break;
+			case DHCP_OPTION_RENEWAL_TIME:
+				memcpy(&dhcp_renewal_time, &offer_packet->options[x],sizeof(dhcp_renewal_time));
+				dhcp_renewal_time = ntohl(dhcp_renewal_time);
+				break;
+			case DHCP_OPTION_REBINDING_TIME:
+				memcpy(&dhcp_rebinding_time, &offer_packet->options[x],sizeof(dhcp_rebinding_time));
+				dhcp_rebinding_time = ntohl(dhcp_rebinding_time);
+				break;
+			case DHCP_OPTION_SERVER_IDENTIFIER:
+				memcpy(&serv_ident.s_addr, &offer_packet->options[x],sizeof(serv_ident.s_addr));
+				break;
+		}
 
 		/* skip option data we're ignoring */
 		if(option_type==0) /* "pad" option, see RFC 2132 (3.1) */
 			x+=1;
 		else
 			x+=option_length;
-		}
+	}
 
 	if(verbose){
 		if(dhcp_lease_time==DHCP_INFINITE_TIME)
@@ -872,7 +872,7 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){
 		if(dhcp_rebinding_time==DHCP_INFINITE_TIME)
 			printf(_("Rebinding Time: Infinite\n"));
 		printf(_("Rebinding Time: %lu seconds\n"),(unsigned long)dhcp_rebinding_time);
-		}
+	}
 
 	new_offer=(dhcp_offer *)malloc(sizeof(dhcp_offer));
 
@@ -901,14 +901,14 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){
 	if(verbose){
 		printf(_("Added offer from server @ %s"),inet_ntoa(new_offer->server_address));
 		printf(_(" of IP address %s\n"),inet_ntoa(new_offer->offered_address));
-		}
+	}
 
 	/* add new offer to head of list */
 	new_offer->next=dhcp_offer_list;
 	dhcp_offer_list=new_offer;
 
 	return OK;
-        }
+}
 
 
 /* frees memory allocated to DHCP OFFER list */
@@ -919,10 +919,10 @@ int free_dhcp_offer_list(void){
 	for(this_offer=dhcp_offer_list;this_offer!=NULL;this_offer=next_offer){
 		next_offer=this_offer->next;
 		free(this_offer);
-	        }
+	}
 
 	return OK;
-        }
+}
 
 
 /* frees memory allocated to requested server list */
@@ -933,10 +933,10 @@ int free_requested_server_list(void){
 	for(this_server=requested_server_list;this_server!=NULL;this_server=next_server){
 		next_server=this_server->next;
 		free(this_server);
-	        }
+	}
 
 	return OK;
-        }
+}
 
 
 /* gets state and plugin output to return */
@@ -972,16 +972,16 @@ int get_results(void){
 						if(temp_server->answered)
 							printf(_(" (duplicate)"));
 						printf(_("\n"));
-						}
+					}
 					if(temp_server->answered == FALSE){
 						requested_responses++;
 						temp_server->answered=TRUE;
-						}
-				        }
-		                }
-		        }
+					}
+				}
+			}
+		}
 
-	        }
+	}
 
 	/* else check and see if we got our requested address from any server */
 	else{
@@ -995,8 +995,8 @@ int get_results(void){
 			/* see if we got the address we requested */
 			if(!memcmp(&requested_address,&temp_offer->offered_address,sizeof(requested_address)))
 				received_requested_address=TRUE;
-	                }
-	        }
+		}
+	}
 
 	result=STATE_OK;
 	if(valid_responses==0)
@@ -1021,7 +1021,7 @@ int get_results(void){
 	if(dhcp_offer_list==NULL){
 		printf(_("No DHCPOFFERs were received.\n"));
 		return result;
-	        }
+	}
 
 	printf(_("Received %d DHCPOFFER(s)"),valid_responses);
 
@@ -1040,7 +1040,7 @@ int get_results(void){
 	printf(".\n");
 
 	return result;
-        }
+}
 
 
 /* process command-line arguments */
@@ -1083,71 +1083,71 @@ int call_getopt(int argc, char **argv){
 
 		switch(c){
 
-		case 's': /* DHCP server address */
-			resolve_host(optarg,&dhcp_ip);
-			add_requested_server(dhcp_ip);
-			break;
+			case 's': /* DHCP server address */
+				resolve_host(optarg,&dhcp_ip);
+				add_requested_server(dhcp_ip);
+				break;
 
-		case 'r': /* address we are requested from DHCP servers */
-			resolve_host(optarg,&requested_address);
-			request_specific_address=TRUE;
-			break;
+			case 'r': /* address we are requested from DHCP servers */
+				resolve_host(optarg,&requested_address);
+				request_specific_address=TRUE;
+				break;
 
-		case 't': /* timeout */
-
-			/*
-			if(is_intnonneg(optarg))
-			*/
-			if(atoi(optarg)>0)
-				dhcpoffer_timeout=atoi(optarg);
-			/*
-			else
-				usage("Time interval must be a nonnegative integer\n");
-			*/
-			break;
+			case 't': /* timeout */
 
-		case 'm': /* MAC address */
+				/*
+					 if(is_intnonneg(optarg))
+					 */
+				if(atoi(optarg)>0)
+					dhcpoffer_timeout=atoi(optarg);
+				/*
+					 else
+					 usage("Time interval must be a nonnegative integer\n");
+					 */
+				break;
 
-			if((user_specified_mac=mac_aton(optarg)) == NULL)
-				usage("Cannot parse MAC address.\n");
-			if(verbose)
-				print_hardware_address(user_specified_mac);
+			case 'm': /* MAC address */
 
-			break;
+				if((user_specified_mac=mac_aton(optarg)) == NULL)
+					usage("Cannot parse MAC address.\n");
+				if(verbose)
+					print_hardware_address(user_specified_mac);
 
-		case 'i': /* interface name */
+				break;
 
-			strncpy(network_interface_name,optarg,sizeof(network_interface_name)-1);
-			network_interface_name[sizeof(network_interface_name)-1]='\x0';
+			case 'i': /* interface name */
 
-			break;
+				strncpy(network_interface_name,optarg,sizeof(network_interface_name)-1);
+				network_interface_name[sizeof(network_interface_name)-1]='\x0';
 
-		case 'u': /* unicast testing */
-			unicast=1;
-			break;
+				break;
 
-		case 'V': /* version */
-			print_revision(progname, NP_VERSION);
-			exit(STATE_UNKNOWN);
+			case 'u': /* unicast testing */
+				unicast=1;
+				break;
 
-		case 'h': /* help */
-			print_help();
-			exit(STATE_UNKNOWN);
+			case 'V': /* version */
+				print_revision(progname, NP_VERSION);
+				exit(STATE_UNKNOWN);
 
-		case 'v': /* verbose */
-			verbose=1;
-			break;
+			case 'h': /* help */
+				print_help();
+				exit(STATE_UNKNOWN);
 
-		case '?': /* help */
-			usage5 ();
-			break;
+			case 'v': /* verbose */
+				verbose=1;
+				break;
 
-		default:
-			break;
-		        }
-	        }
+			case '?': /* help */
+				usage5 ();
+				break;
+
+			default:
+				break;
+		}
+	}
 	return optind;
-        }
+}
 
 
 int validate_arguments(int argc){
@@ -1174,21 +1174,21 @@ static int get_msg(int fd){
 	if(res < 0){
 		if(errno == EINTR){
 			return(GOT_INTR);
-			}
+		}
 		else{
 			printf("%s\n", "get_msg FAILED.");
 			return(GOT_ERR);
-			}
 		}
+	}
 	if(ctl.len > 0){
 		ret |= GOT_CTRL;
-		}
+	}
 	if(dat.len > 0){
 		ret |= GOT_DATA;
-		}
+	}
 
 	return(ret);
-	}
+}
 
 /* verify that dl_primitive in ctl_area = prim */
 static int check_ctrl(int prim){
@@ -1197,10 +1197,10 @@ static int check_ctrl(int prim){
 	if(err_ack->dl_primitive != prim){
 		printf(_("Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n"), strerror(errno));
 		exit(STATE_UNKNOWN);
-		}
+	}
 
 	return 0;
-	}
+}
 
 /* put a control message on a stream */
 static int put_ctrl(int fd, int len, int pri){
@@ -1209,10 +1209,10 @@ static int put_ctrl(int fd, int len, int pri){
 	if(putmsg(fd, &ctl, 0, pri) < 0){
 		printf(_("Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n"), strerror(errno));
 		exit(STATE_UNKNOWN);
-		}
+	}
 
 	return  0;
-	}
+}
 
 /* put a control + data message on a stream */
 static int put_both(int fd, int clen, int dlen, int pri){
@@ -1222,10 +1222,10 @@ static int put_both(int fd, int clen, int dlen, int pri){
 	if(putmsg(fd, &ctl, &dat, pri) < 0){
 		printf(_("Error: DLPI stream API failed to get MAC in put_both/putmsg().\n"), strerror(errno));
 		exit(STATE_UNKNOWN);
-		}
+	}
 
 	return  0;
-	}
+}
 
 /* open file descriptor and attach */
 static int dl_open(const char *dev, int unit, int *fd){
@@ -1234,13 +1234,13 @@ static int dl_open(const char *dev, int unit, int *fd){
 	if((*fd = open(dev, O_RDWR)) == -1){
 		printf(_("Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n"), dev, strerror(errno));
 		exit(STATE_UNKNOWN);
-		}
+	}
 	attach_req->dl_primitive = DL_ATTACH_REQ;
 	attach_req->dl_ppa = unit;
 	put_ctrl(*fd, sizeof(dl_attach_req_t), 0);
 	get_msg(*fd);
 	return check_ctrl(DL_OK_ACK);
-	}
+}
 
 /* send DL_BIND_REQ */
 static int dl_bind(int fd, int sap, u_char *addr){
@@ -1258,12 +1258,12 @@ static int dl_bind(int fd, int sap, u_char *addr){
 	if (GOT_ERR == check_ctrl(DL_BIND_ACK)){
 		printf(_("Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n"), strerror(errno));
 		exit(STATE_UNKNOWN);
-		}
+	}
 	bcopy((u_char *)bind_ack + bind_ack->dl_addr_offset, addr,
-	      bind_ack->dl_addr_length);
+			bind_ack->dl_addr_length);
 
 	return 0;
-	}
+}
 
 /***********************************************************************
  * interface:
@@ -1282,15 +1282,15 @@ long mac_addr_dlpi( const char *dev, int unit, u_char  *addr){
 	u_char mac_addr[25];
 
 	if(GOT_ERR != dl_open(dev, unit, &fd)){
-        	if(GOT_ERR != dl_bind(fd, INSAP, mac_addr)){
-                	bcopy( mac_addr, addr, 6);
-                	return 0;
-			}
+		if(GOT_ERR != dl_bind(fd, INSAP, mac_addr)){
+			bcopy( mac_addr, addr, 6);
+			return 0;
 		}
-        close(fd);
+	}
+	close(fd);
 
 	return -1;
-	}
+}
 
 /* Kompf 2000-2003 */
 #endif
@@ -1307,7 +1307,7 @@ void resolve_host(const char *in,struct in_addr *out){
 
 	memcpy(out,&((struct sockaddr_in *)ai->ai_addr)->sin_addr,sizeof(*out));
 	freeaddrinfo(ai);
-	}
+}
 
 
 /* parse MAC address string, return 6 bytes (unterminated) or NULL */
@@ -1326,10 +1326,10 @@ unsigned char *mac_aton(const char *string){
 		result[j]=strtol(tmp,(char **)NULL,16);
 		i++;
 		j++;
-		}
+	}
 
 	return (j==6) ? result : NULL;
-	}
+}
 
 
 void print_hardware_address(const unsigned char *address){
@@ -1340,7 +1340,7 @@ void print_hardware_address(const unsigned char *address){
 		printf("%2.2x:", address[i]);
 	printf("%2.2x", address[i]);
 	putchar('\n');
-	}
+}
 
 
 /* print usage help */
@@ -1353,7 +1353,7 @@ void print_help(void){
 
 	printf("%s\n", _("This plugin tests the availability of DHCP servers on a network."));
 
-  printf ("\n\n");
+	printf ("\n\n");
 
 	print_usage();
 
@@ -1363,32 +1363,32 @@ void print_help(void){
 	printf (UT_VERBOSE);
 
 	printf (" %s\n", "-s, --serverip=IPADDRESS");
-  printf ("    %s\n", _("IP address of DHCP server that we must hear from"));
-  printf (" %s\n", "-r, --requestedip=IPADDRESS");
-  printf ("    %s\n", _("IP address that should be offered by at least one DHCP server"));
-  printf (" %s\n", "-t, --timeout=INTEGER");
-  printf ("    %s\n", _("Seconds to wait for DHCPOFFER before timeout occurs"));
-  printf (" %s\n", "-i, --interface=STRING");
-  printf ("    %s\n", _("Interface to to use for listening (i.e. eth0)"));
-  printf (" %s\n", "-m, --mac=STRING");
-  printf ("    %s\n", _("MAC address to use in the DHCP request"));
-  printf (" %s\n", "-u, --unicast");
-  printf ("    %s\n", _("Unicast testing: mimic a DHCP relay, requires -s"));
-
-  printf (UT_SUPPORT);
+	printf ("    %s\n", _("IP address of DHCP server that we must hear from"));
+	printf (" %s\n", "-r, --requestedip=IPADDRESS");
+	printf ("    %s\n", _("IP address that should be offered by at least one DHCP server"));
+	printf (" %s\n", "-t, --timeout=INTEGER");
+	printf ("    %s\n", _("Seconds to wait for DHCPOFFER before timeout occurs"));
+	printf (" %s\n", "-i, --interface=STRING");
+	printf ("    %s\n", _("Interface to to use for listening (i.e. eth0)"));
+	printf (" %s\n", "-m, --mac=STRING");
+	printf ("    %s\n", _("MAC address to use in the DHCP request"));
+	printf (" %s\n", "-u, --unicast");
+	printf ("    %s\n", _("Unicast testing: mimic a DHCP relay, requires -s"));
+
+	printf (UT_SUPPORT);
 	return;
-	}
+}
 
 
 void
 print_usage(void){
 
-  printf ("%s\n", _("Usage:"));
-  printf (" %s [-v] [-u] [-s serverip] [-r requestedip] [-t timeout]\n",progname);
-  printf ("                  [-i interface] [-m mac]\n");
+	printf ("%s\n", _("Usage:"));
+	printf (" %s [-v] [-u] [-s serverip] [-r requestedip] [-t timeout]\n",progname);
+	printf ("                  [-i interface] [-m mac]\n");
 
 	return;
-	}
+}
 
 
 
-- 
cgit v0.10-9-g596f


From 1aaa2385031da8de6c9d74cecf589482a56b9e35 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 1 Oct 2023 13:59:00 +0200
Subject: Use real booleans


diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c
index 99df3d2..0c18d5f 100644
--- a/plugins-root/check_dhcp.c
+++ b/plugins-root/check_dhcp.c
@@ -115,9 +115,6 @@ long mac_addr_dlpi( const char *, int, u_char *);
 #define OK                0
 #define ERROR             -1
 
-#define FALSE             0
-#define TRUE              1
-
 
 /**** DHCP definitions ****/
 
@@ -158,7 +155,7 @@ typedef struct dhcp_offer_struct{
 
 typedef struct requested_server_struct{
 	struct in_addr server_address;
-	int answered;
+	bool answered;
 	struct requested_server_struct *next;
 }requested_server;
 
@@ -217,8 +214,8 @@ int valid_responses=0;     /* number of valid DHCPOFFERs we received */
 int requested_servers=0;
 int requested_responses=0;
 
-int request_specific_address=FALSE;
-int received_requested_address=FALSE;
+bool request_specific_address=false;
+bool received_requested_address=false;
 int verbose=0;
 struct in_addr requested_address;
 
@@ -491,7 +488,7 @@ int send_dhcp_discover(int sock){
 	discover_packet.options[opts++]=DHCPDISCOVER;
 
 	/* the IP address we're requesting */
-	if(request_specific_address==TRUE){
+	if(request_specific_address){
 		discover_packet.options[opts++]=DHCP_OPTION_REQUESTED_ADDRESS;
 		discover_packet.options[opts++]='\x04';
 		memcpy(&discover_packet.options[opts],&requested_address,sizeof(requested_address));
@@ -792,7 +789,7 @@ int add_requested_server(struct in_addr server_address){
 		return ERROR;
 
 	new_server->server_address=server_address;
-	new_server->answered=FALSE;
+	new_server->answered=false;
 
 	new_server->next=requested_server_list;
 	requested_server_list=new_server;
@@ -946,7 +943,7 @@ int get_results(void){
 	int result;
 	uint32_t max_lease_time=0;
 
-	received_requested_address=FALSE;
+	received_requested_address=false;
 
 	/* checks responses from requested servers */
 	requested_responses=0;
@@ -962,7 +959,7 @@ int get_results(void){
 
 				/* see if we got the address we requested */
 				if(!memcmp(&requested_address,&temp_offer->offered_address,sizeof(requested_address)))
-					received_requested_address=TRUE;
+					received_requested_address=true;
 
 				/* see if the servers we wanted a response from talked to us or not */
 				if(!memcmp(&temp_offer->server_address,&temp_server->server_address,sizeof(temp_server->server_address))){
@@ -973,9 +970,9 @@ int get_results(void){
 							printf(_(" (duplicate)"));
 						printf(_("\n"));
 					}
-					if(temp_server->answered == FALSE){
+					if(!temp_server->answered){
 						requested_responses++;
-						temp_server->answered=TRUE;
+						temp_server->answered=true;
 					}
 				}
 			}
@@ -994,7 +991,7 @@ int get_results(void){
 
 			/* see if we got the address we requested */
 			if(!memcmp(&requested_address,&temp_offer->offered_address,sizeof(requested_address)))
-				received_requested_address=TRUE;
+				received_requested_address=true;
 		}
 	}
 
@@ -1005,7 +1002,7 @@ int get_results(void){
 		result=STATE_CRITICAL;
 	else if(requested_responses<requested_servers)
 		result=STATE_WARNING;
-	else if(request_specific_address==TRUE && received_requested_address==FALSE)
+	else if(request_specific_address && !received_requested_address)
 		result=STATE_WARNING;
 
 	if(result==0)               /* garrett honeycutt 2005 */
@@ -1028,8 +1025,8 @@ int get_results(void){
 	if(requested_servers>0)
 		printf(_(", %s%d of %d requested servers responded"),((requested_responses<requested_servers) && requested_responses>0)?"only ":"",requested_responses,requested_servers);
 
-	if(request_specific_address==TRUE)
-		printf(_(", requested address (%s) was %soffered"),inet_ntoa(requested_address),(received_requested_address==TRUE)?"":_("not "));
+	if(request_specific_address)
+		printf(_(", requested address (%s) was %soffered"),inet_ntoa(requested_address),(received_requested_address)?"":_("not "));
 
 	printf(_(", max lease time = "));
 	if(max_lease_time==DHCP_INFINITE_TIME)
@@ -1090,7 +1087,7 @@ int call_getopt(int argc, char **argv){
 
 			case 'r': /* address we are requested from DHCP servers */
 				resolve_host(optarg,&requested_address);
-				request_specific_address=TRUE;
+				request_specific_address=true;
 				break;
 
 			case 't': /* timeout */
-- 
cgit v0.10-9-g596f


From 11487d161c6ca3152ab3fa6dbece8d0e2d18ea46 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 1 Oct 2023 14:03:34 +0200
Subject: Comment some endifs to make comprehension easier


diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c
index 0c18d5f..d74d4ac 100644
--- a/plugins-root/check_dhcp.c
+++ b/plugins-root/check_dhcp.c
@@ -57,9 +57,10 @@ const char *email = "devel@monitoring-plugins.org";
 #include <netinet/in.h>
 #include <net/if.h>
 #include <arpa/inet.h>
+
 #if HAVE_SYS_SOCKIO_H
 #include <sys/sockio.h>
-#endif
+#endif // HAVE_SYS_SOCKIO_H
 
 #if defined( __linux__ )
 
@@ -106,7 +107,7 @@ static int dl_open(const char *, int, int *);
 static int dl_bind(int, int, u_char *);
 long mac_addr_dlpi( const char *, int, u_char *);
 
-#endif
+#endif // __sun__ || __solaris__ || __hpux
 
 
 
-- 
cgit v0.10-9-g596f


From f2ed728823276fc3f861ce909953c318f83aef74 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 1 Oct 2023 14:03:44 +0200
Subject: Remove trailing lines


diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c
index d74d4ac..4d16772 100644
--- a/plugins-root/check_dhcp.c
+++ b/plugins-root/check_dhcp.c
@@ -1387,6 +1387,3 @@ print_usage(void){
 
 	return;
 }
-
-
-
-- 
cgit v0.10-9-g596f


From 9f9f5fd9b22e6e6d6415be3c3ecde9f795b55fe2 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 1 Oct 2023 14:05:59 +0200
Subject: Update copyright


diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c
index 4d16772..0ddace5 100644
--- a/plugins-root/check_dhcp.c
+++ b/plugins-root/check_dhcp.c
@@ -34,7 +34,7 @@
  *****************************************************************************/
 
 const char *progname = "check_dhcp";
-const char *copyright = "2001-2007";
+const char *copyright = "2001-2023";
 const char *email = "devel@monitoring-plugins.org";
 
 #include "common.h"
-- 
cgit v0.10-9-g596f


From e1e1291b72e2f1df81d0346d77e65da677e57878 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Tue, 3 Oct 2023 22:22:51 +0200
Subject: Fix some more typos


diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index eda2790..0f845de 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -21,7 +21,7 @@ jobs:
         uses: codespell-project/actions-codespell@v2
         with:
           skip: "./.git,./.gitignore,./ABOUT-NLS,*.po,./gl,./po,./tools/squid.conf,./build-aux/ltmain.sh"
-          ignore_words_list: allright,gord,didi,hda,nd,alis,clen,scrit,ser,fot,te,parm,isnt,consol,oneliners
+          ignore_words_list: allright,gord,didi,hda,nd,alis,clen,scrit,ser,fot,te,parm,isnt,consol,oneliners,esponse
           check_filenames: true
           check_hidden: true
 #  super-linter:
diff --git a/m4/np_mysqlclient.m4 b/m4/np_mysqlclient.m4
index 9f533ea..9fe38ac 100644
--- a/m4/np_mysqlclient.m4
+++ b/m4/np_mysqlclient.m4
@@ -13,7 +13,7 @@ dnl   np_mysql_libs    = flags for libs,    from mysql_config --libs
 dnl   np_mysql_cflags  = flags for cflags,  from mysql_config --cflags
 dnl Also sets in config.h:
 dnl   HAVE_MYSQLCLIENT
-dnl Copile your code with:
+dnl Compile your code with:
 dnl   $(CC) $(np_mysql_include) code.c $(np_mysql_libs)
 
 AC_DEFUN([np_mysqlclient],
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c
index 3614650..99537c8 100644
--- a/plugins/check_ntp.c
+++ b/plugins/check_ntp.c
@@ -486,7 +486,7 @@ double offset_request(const char *host, int *status){
 	}
 
 	/* cleanup */
-	/* FIXME: Not closing the socket to avoid re-use of the local port
+	/* FIXME: Not closing the socket to avoid reuse of the local port
 	 * which can cause old NTP packets to be read instead of NTP control
 	 * packets in jitter_request(). THERE MUST BE ANOTHER WAY...
 	 * for(j=0; j<num_hosts; j++){ close(socklist[j]); } */
diff --git a/plugins/t/check_imap.t b/plugins/t/check_imap.t
index 7c74e56..cf2f81c 100644
--- a/plugins/t/check_imap.t
+++ b/plugins/t/check_imap.t
@@ -25,7 +25,7 @@ $t = NPTest->testCmd( "./check_imap $host_tcp_imap -p 143 -wt 9 -ct 9 -to 10 -e
 cmp_ok( $t->return_code, '==', 0, "Check old parameter options" );
 
 $t = NPTest->testCmd( "./check_imap $host_nonresponsive" );
-cmp_ok( $t->return_code, '==', 2, "Get error with non reponsive host" );
+cmp_ok( $t->return_code, '==', 2, "Get error with non responsive host" );
 
 $t = NPTest->testCmd( "./check_imap $hostname_invalid" );
 cmp_ok( $t->return_code, '==', 2, "Invalid hostname" );
diff --git a/plugins/t/check_users.t b/plugins/t/check_users.t
index 088f3b5..9ebc2fc 100644
--- a/plugins/t/check_users.t
+++ b/plugins/t/check_users.t
@@ -2,7 +2,7 @@
 #
 # Logged in Users Tests via check_users
 #
-# Trick: This ckeck requires at least 1 user logged in. These commands should
+# Trick: This check requires at least 1 user logged in. These commands should
 #        leave a session open forever in the background:
 #
 #   $ ssh -tt localhost </dev/null >/dev/null 2>/dev/null &
diff --git a/plugins/tests/check_curl.t b/plugins/tests/check_curl.t
index 72f2b7c..3c91483 100755
--- a/plugins/tests/check_curl.t
+++ b/plugins/tests/check_curl.t
@@ -9,7 +9,7 @@
 # Country Name (2 letter code) [AU]:DE
 # State or Province Name (full name) [Some-State]:Bavaria
 # Locality Name (eg, city) []:Munich
-# Organization Name (eg, company) [Internet Widgits Pty Ltd]:Monitoring Plugins
+# Organization Name (eg, company) [Internet Widgets Pty Ltd]:Monitoring Plugins
 # Organizational Unit Name (eg, section) []:
 # Common Name (e.g. server FQDN or YOUR name) []:Monitoring Plugins
 # Email Address []:devel@monitoring-plugins.org
-- 
cgit v0.10-9-g596f


From 396bcf50ce23fc34d14e4ef8fb6d9843b977f95c Mon Sep 17 00:00:00 2001
From: Danijel Tasov <m@rbfh.de>
Date: Wed, 4 Oct 2023 10:21:41 +0200
Subject: adjust check_icmp tests


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index f7e091a..a9a24ee 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1404,7 +1404,7 @@ finish(int sig)
 			}
 		}
 		else {	/* !icmp_recv */
-			printf("%s ", host->name);
+			printf("%s:", host->name);
 			/* rta text output */
 			if (rta_mode) {
 				if (status == STATE_OK)
diff --git a/plugins-root/t/check_icmp.t b/plugins-root/t/check_icmp.t
index 96addd3..07e175e 100644
--- a/plugins-root/t/check_icmp.t
+++ b/plugins-root/t/check_icmp.t
@@ -18,8 +18,8 @@ if ($allow_sudo eq "yes" or $> == 0) {
 }
 my $sudo = $> == 0 ? '' : 'sudo';
 
-my $successOutput = '/OK - .*?: rta (?:[\d\.]+ms)|(?:nan), lost \d+%/';
-my $failureOutput = '/(WARNING|CRITICAL) - .*?: rta [\d\.]+ms, lost \d%/';
+my $successOutput = '/OK - .*? rta (?:[\d\.]+ms)|(?:nan), lost \d+%/';
+my $failureOutput = '/(WARNING|CRITICAL) - .*? rta [\d\.]+ms > [\d\.]+ms/';
 
 my $host_responsive    = getTestParameter( "NP_HOST_RESPONSIVE",
 				"The hostname of system responsive to network requests",
@@ -54,7 +54,7 @@ is( $res->return_code, 2, "Syntax ok, with forced critical" );
 like( $res->output, $failureOutput, "Output OK" );
 
 $res = NPTest->testCmd(
-	"$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100%"
+	"$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -t 2"
 	);
 is( $res->return_code, 2, "Timeout - host nonresponsive" );
 like( $res->output, '/100%/', "Error contains '100%' string (for 100% packet loss)" );
@@ -66,13 +66,13 @@ is( $res->return_code, 3, "No hostname" );
 like( $res->output, '/No hosts to check/', "Output with appropriate error message");
 
 $res = NPTest->testCmd(
-	"$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 0"
+	"$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 0 -t 2"
 	);
 is( $res->return_code, 0, "One host nonresponsive - zero required" );
 like( $res->output, $successOutput, "Output OK" );
 
 $res = NPTest->testCmd(
-	"$sudo ./check_icmp -H $host_responsive -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 1"
+	"$sudo ./check_icmp -H $host_responsive -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 1 -t 2"
 	);
 is( $res->return_code, 0, "One of two host nonresponsive - one required" );
 like( $res->output, $successOutput, "Output OK" );
-- 
cgit v0.10-9-g596f


From 6585711b0b5beafed69881b66d9c105dad658a3f Mon Sep 17 00:00:00 2001
From: Danijel Tasov <m@rbfh.de>
Date: Wed, 4 Oct 2023 10:22:35 +0200
Subject: fix host count on when checking multiple hosts


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index a9a24ee..321612b 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1236,6 +1236,7 @@ finish(int sig)
 	{"OK", "WARNING", "CRITICAL", "UNKNOWN", "DEPENDENT"};
 	int hosts_ok = 0;
 	int hosts_warn = 0;
+	int this_status;
 	double R;
 
 	alarm(0);
@@ -1256,6 +1257,7 @@ finish(int sig)
 	host = list;
 
 	while(host) {
+		this_status = STATE_OK;
 		if(!host->icmp_recv) {
 			/* rta 0 is ofcourse not entirely correct, but will still show up
 			 * conspicuously as missing entries in perfparse and cacti */
@@ -1296,79 +1298,80 @@ finish(int sig)
 			pl_mode=1;
 		}
 
+#define THIS_STATUS_WARNING this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status)
 		/* Check which mode is on and do the warn / Crit stuff */
 		if (rta_mode) {
 			if(rta >= crit.rta) {
+				this_status = STATE_CRITICAL;
 				status = STATE_CRITICAL;
 				host->rta_status=STATE_CRITICAL;
 			}
 			else if(status!=STATE_CRITICAL && (rta >= warn.rta)) {
+				THIS_STATUS_WARNING;
 				status = STATE_WARNING;
-				hosts_warn++;
 				host->rta_status=STATE_WARNING;
 			}
-			else {
-				hosts_ok++;
-			}
 		}
 		if (pl_mode) {
 			if(pl >= crit.pl) {
+				this_status = STATE_CRITICAL;
 				status = STATE_CRITICAL;
 				host->pl_status=STATE_CRITICAL;
 			}
 			else if(status!=STATE_CRITICAL && (pl >= warn.pl)) {
+				THIS_STATUS_WARNING;
 				status = STATE_WARNING;
-				hosts_warn++;
 				host->pl_status=STATE_WARNING;
 			}
-			else {
-				hosts_ok++;
-			}
 		}
 		if (jitter_mode) {
 			if(host->jitter >= crit.jitter) {
+				this_status = STATE_CRITICAL;
 				status = STATE_CRITICAL;
 				host->jitter_status=STATE_CRITICAL;
 			}
 			else if(status!=STATE_CRITICAL && (host->jitter >= warn.jitter)) {
+				THIS_STATUS_WARNING;
 				status = STATE_WARNING;
-				hosts_warn++;
 				host->jitter_status=STATE_WARNING;
 			}
-			else {
-				hosts_ok++;
-			}
 		}
 		if (mos_mode) {
 			if(host->mos <= crit.mos) {
+				this_status = STATE_CRITICAL;
 				status = STATE_CRITICAL;
 				host->mos_status=STATE_CRITICAL;
 			}
 			else if(status!=STATE_CRITICAL && (host->mos <= warn.mos)) {
+				THIS_STATUS_WARNING;
 				status = STATE_WARNING;
-				hosts_warn++;
 				host->mos_status=STATE_WARNING;
 			}
-			else {
-				hosts_ok++;
-			}
 		}
 		if (score_mode) {
 			if(host->score <= crit.score) {
+				this_status = STATE_CRITICAL;
 				status = STATE_CRITICAL;
 				host->score_status=STATE_CRITICAL;
 			}
 			else if(status!=STATE_CRITICAL && (host->score <= warn.score)) {
+				THIS_STATUS_WARNING;
 				status = STATE_WARNING;
-				score_mode++;
 				host->score_status=STATE_WARNING;
 			}
-			else {
-				hosts_ok++;
-			}
 		}
+
+		if (this_status == STATE_WARNING) {
+			hosts_warn++;
+		}
+		else if (this_status == STATE_OK) {
+			hosts_ok++;
+		}
+
 		host = host->next;
 	}
+
+
 	/* this is inevitable */
 	if(!targets_alive) status = STATE_CRITICAL;
 	if(min_hosts_alive > -1) {
@@ -1404,7 +1407,7 @@ finish(int sig)
 			}
 		}
 		else {	/* !icmp_recv */
-			printf("%s:", host->name);
+			printf("%s", host->name);
 			/* rta text output */
 			if (rta_mode) {
 				if (status == STATE_OK)
-- 
cgit v0.10-9-g596f


From df57a23e0ace0c1d1c19038fd3834b20742ef24a Mon Sep 17 00:00:00 2001
From: Danijel Tasov <m@rbfh.de>
Date: Wed, 4 Oct 2023 10:39:30 +0200
Subject: update failure regex


diff --git a/plugins-root/t/check_icmp.t b/plugins-root/t/check_icmp.t
index 07e175e..9fb8fa0 100644
--- a/plugins-root/t/check_icmp.t
+++ b/plugins-root/t/check_icmp.t
@@ -19,7 +19,7 @@ if ($allow_sudo eq "yes" or $> == 0) {
 my $sudo = $> == 0 ? '' : 'sudo';
 
 my $successOutput = '/OK - .*? rta (?:[\d\.]+ms)|(?:nan), lost \d+%/';
-my $failureOutput = '/(WARNING|CRITICAL) - .*? rta [\d\.]+ms > [\d\.]+ms/';
+my $failureOutput = '/(WARNING|CRITICAL) - .*? rta (?:[\d\.]+ms > [\d\.]+ms|nan)/';
 
 my $host_responsive    = getTestParameter( "NP_HOST_RESPONSIVE",
 				"The hostname of system responsive to network requests",
-- 
cgit v0.10-9-g596f


From 4e7eb550791afdb5d3e496a84be00286ccb6fb5b Mon Sep 17 00:00:00 2001
From: Danijel Tasov <m@rbfh.de>
Date: Wed, 4 Oct 2023 11:34:25 +0200
Subject: add some basic tests for the new modes

Signed-off-by: Danijel Tasov <m@rbfh.de>

diff --git a/plugins-root/t/check_icmp.t b/plugins-root/t/check_icmp.t
index 9fb8fa0..4f9db86 100644
--- a/plugins-root/t/check_icmp.t
+++ b/plugins-root/t/check_icmp.t
@@ -12,7 +12,7 @@ my $allow_sudo = getTestParameter( "NP_ALLOW_SUDO",
 	"no" );
 
 if ($allow_sudo eq "yes" or $> == 0) {
-	plan tests => 20;
+	plan tests => 39;
 } else {
 	plan skip_all => "Need sudo to test check_icmp";
 }
@@ -94,3 +94,49 @@ $res = NPTest->testCmd(
 	);
 is( $res->return_code, 0, "Try max packet size" );
 like( $res->output, $successOutput, "Output OK - Didn't overflow" );
+
+$res = NPTest->testCmd(
+	"$sudo ./check_icmp -H $host_responsive -R 100,100 -n 1 -t 2"
+	);
+is( $res->return_code, 0, "rta works" );
+like( $res->output, $successOutput, "Output OK" );
+$res = NPTest->testCmd(
+	"$sudo ./check_icmp -H $host_responsive -P 80,90 -n 1 -t 2"
+	);
+is( $res->return_code, 0, "pl works" );
+like( $res->output, '/lost 0%/', "Output OK" );
+
+$res = NPTest->testCmd(
+	"$sudo ./check_icmp -H $host_responsive -J 80,90 -t 2"
+	);
+is( $res->return_code, 0, "jitter works" );
+like( $res->output, '/jitter \d/', "Output OK" );
+
+$res = NPTest->testCmd(
+	"$sudo ./check_icmp -H $host_responsive -M 4,3 -t 2"
+	);
+is( $res->return_code, 0, "mos works" );
+like( $res->output, '/MOS \d/', "Output OK" );
+
+$res = NPTest->testCmd(
+	"$sudo ./check_icmp -H $host_responsive -S 80,70 -t 2"
+	);
+is( $res->return_code, 0, "score works" );
+like( $res->output, '/Score \d/', "Output OK" );
+
+$res = NPTest->testCmd(
+	"$sudo ./check_icmp -H $host_responsive -O -t 2"
+	);
+is( $res->return_code, 0, "order works" );
+like( $res->output, '/Packets in order/', "Output OK" );
+
+$res = NPTest->testCmd(
+	"$sudo ./check_icmp -H $host_responsive -O -S 80,70 -M 4,3 -J 80,90 -P 80,90 -R 100,100 -t 2"
+	);
+is( $res->return_code, 0, "order works" );
+like( $res->output, '/Packets in order/', "Output OK" );
+like( $res->output, '/Score \d/', "Output OK" );
+like( $res->output, '/MOS \d/', "Output OK" );
+like( $res->output, '/jitter \d/', "Output OK" );
+like( $res->output, '/lost 0%/', "Output OK" );
+like( $res->output, $successOutput, "Output OK" );
-- 
cgit v0.10-9-g596f


From 843c0bfa46ed6d02c9b4998f66a9cc3a2834271d Mon Sep 17 00:00:00 2001
From: Danijel Tasov <m@rbfh.de>
Date: Wed, 4 Oct 2023 11:44:22 +0200
Subject: remove sun ifdef

my be readded later with proper comments

Signed-off-by: Danijel Tasov <m@rbfh.de>

diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 321612b..4a72315 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -42,11 +42,6 @@ char *progname;
 const char *copyright = "2005-2008";
 const char *email = "devel@monitoring-plugins.org";
 
-/* what does that do? */
-#ifdef __sun
-#define _XPG4_2
-#endif
-
 /** Monitoring Plugins basic includes */
 #include "common.h"
 #include "netutils.h"
-- 
cgit v0.10-9-g596f


From 1f49981982cb47227457f8b37997f5639fceb778 Mon Sep 17 00:00:00 2001
From: Danijel Tasov <m@rbfh.de>
Date: Wed, 4 Oct 2023 11:52:09 +0200
Subject: readability improvements

Signed-off-by: Danijel Tasov <m@rbfh.de>

diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 4a72315..246b466 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1478,13 +1478,31 @@ finish(int sig)
 			printf("%spl=%u%%;%u;%u;0;100 ", (targets > 1) ? host->name : "", host->pl, warn.pl, crit.pl);
 		}
 		if (jitter_mode && host->pl<100) {
-			printf("%sjitter_avg=%0.3fms;%0.3f;%0.3f;0; %sjitter_max=%0.3fms;;;; %sjitter_min=%0.3fms;;;; ", (targets > 1) ? host->name : "", (float)host->jitter, (float)warn.jitter, (float)crit.jitter, (targets > 1) ? host->name : "", (float)host->jitter_max / 1000, (targets > 1) ? host->name : "",(float)host->jitter_min / 1000);
+			printf("%sjitter_avg=%0.3fms;%0.3f;%0.3f;0; %sjitter_max=%0.3fms;;;; %sjitter_min=%0.3fms;;;; ",
+				(targets > 1) ? host->name : "",
+				(float)host->jitter,
+				(float)warn.jitter,
+				(float)crit.jitter,
+				(targets > 1) ? host->name : "",
+				(float)host->jitter_max / 1000, (targets > 1) ? host->name : "",
+				(float)host->jitter_min / 1000
+			);
 		}
 		if (mos_mode && host->pl<100) {
-			printf("%smos=%0.1f;%0.1f;%0.1f;0;5 ", (targets > 1) ? host->name : "", (float)host->mos, (float)warn.mos, (float)crit.mos);
+			printf("%smos=%0.1f;%0.1f;%0.1f;0;5 ",
+				(targets > 1) ? host->name : "",
+				(float)host->mos,
+				(float)warn.mos,
+				(float)crit.mos
+			);
 		}
 		if (score_mode && host->pl<100) {
-			printf("%sscore=%u;%u;%u;0;100 ", (targets > 1) ? host->name : "", (int)host->score, (int)warn.score, (int)crit.score);
+			printf("%sscore=%u;%u;%u;0;100 ",
+				(targets > 1) ? host->name : "",
+				(int)host->score,
+				(int)warn.score,
+				(int)crit.score
+			);
 		}
 		host = host->next;
 	}
-- 
cgit v0.10-9-g596f


From dfa5aa4b83c33ed6b609e7f79ebe1f03507b679c Mon Sep 17 00:00:00 2001
From: Danijel Tasov <m@rbfh.de>
Date: Wed, 4 Oct 2023 11:56:23 +0200
Subject: unnecessary space

Signed-off-by: Danijel Tasov <m@rbfh.de>

diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 246b466..0401788 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1781,7 +1781,7 @@ get_timevar(const char *str)
 	else if(u == 's') factor = 1000000;	/* seconds */
 	if(debug > 2) printf("factor is %u\n", factor);
 
-	i =  strtoul(str, &ptr, 0);
+	i = strtoul(str, &ptr, 0);
 	if(!ptr || *ptr != '.' || strlen(ptr) < 2 || factor == 1)
 		return i * factor;
 
-- 
cgit v0.10-9-g596f


From e365f9f58eed501baf1a80c47556191a48b99c3f Mon Sep 17 00:00:00 2001
From: Danijel Tasov <m@rbfh.de>
Date: Fri, 6 Oct 2023 10:51:27 +0200
Subject: do not introduce new ints as bools


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 0401788..274277b 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -242,12 +242,12 @@ static unsigned int warn_down = 1, crit_down = 1; /* host down threshold values
 static int min_hosts_alive = -1;
 float pkt_backoff_factor = 1.5;
 float target_backoff_factor = 1.5;
-int	rta_mode=0;
-int	pl_mode=0;
-int	jitter_mode=0;
-int	score_mode=0;
-int	mos_mode=0;
-int	order_mode=0;
+bool rta_mode=false;
+bool pl_mode=false;
+bool jitter_mode=false;
+bool score_mode=false;
+bool mos_mode=false;
+bool order_mode=false;
 
 /** code start **/
 static void
@@ -582,26 +582,26 @@ main(int argc, char **argv)
 				break;
 			case 'R': /* RTA mode */
 				get_threshold2(optarg, &warn, &crit,1);
-				rta_mode=1;
+				rta_mode=true;
 				break;
 			case 'P': /* packet loss mode */
 				get_threshold2(optarg, &warn, &crit,2);
-				pl_mode=1;
+				pl_mode=true;
 				break;
 			case 'J': /* jitter mode */
 				get_threshold2(optarg, &warn, &crit,3);
-				jitter_mode=1;
+				jitter_mode=true;
 				break;
 			case 'M': /* MOS mode */
 				get_threshold2(optarg, &warn, &crit,4);
-				mos_mode=1;
+				mos_mode=true;
 				break;
 			case 'S': /* score mode */
 				get_threshold2(optarg, &warn, &crit,5);
-				score_mode=1;
+				score_mode=true;
 				break;
 			case 'O': /* out of order mode */
-				order_mode=1;
+				order_mode=true;
 				break;
 			}
 		}
@@ -758,6 +758,7 @@ main(int argc, char **argv)
 
 	host = list;
 	table = malloc(sizeof(struct rta_host *) * targets);
+
 	i = 0;
 	while(host) {
 		host->id = i*packets;
@@ -1831,7 +1832,8 @@ get_threshold(char *str, threshold *th)
 static int
 get_threshold2(char *str, threshold *warn, threshold *crit, int type)
 {
-	char *p = NULL, i = 0;
+	char *p = NULL;
+	bool i = false;
 
 	if(!str || !strlen(str) || !warn || !crit) return -1;
 	/* pointer magic slims code by 10 lines. i is bof-stop on stupid libc's */
@@ -1851,7 +1853,7 @@ get_threshold2(char *str, threshold *warn, threshold *crit, int type)
 			else if (type==5)
 				crit->score = atof(p+1);
 		}
-		i = 1;
+		i = true;
 		p--;
 	}
 	if (type==1)
-- 
cgit v0.10-9-g596f


From 1ad7e163fad45d33a44f398fb2416f1b9086469a Mon Sep 17 00:00:00 2001
From: Danijel Tasov <m@rbfh.de>
Date: Fri, 6 Oct 2023 10:54:20 +0200
Subject: check malloc


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 274277b..197ce32 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -758,6 +758,10 @@ main(int argc, char **argv)
 
 	host = list;
 	table = malloc(sizeof(struct rta_host *) * targets);
+	if(!table) {
+		crash("main(): malloc failed for host table");
+		return 3;
+	}
 
 	i = 0;
 	while(host) {
-- 
cgit v0.10-9-g596f


From c2f20fdd94feb06e815a891b22f25fac10c2cc13 Mon Sep 17 00:00:00 2001
From: Stuart Henderson <stu@spacehopper.org>
Date: Fri, 27 Jan 2017 12:56:11 +0000
Subject: use pack_sockaddr_in rather than hand-rolled

On some OS, sockaddr structs include a length field. Perl's pack_sockaddr_in
takes this into account; the hand-rolled "pack('S n a4 x8'..." doesn't do so,
resulting in connection failures.

diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl
index 84f2022..4822fe6 100755
--- a/plugins-scripts/check_ircd.pl
+++ b/plugins-scripts/check_ircd.pl
@@ -146,7 +146,6 @@ sub bindRemote ($$)
 {
 	my ($in_remotehost, $in_remoteport) = @_;
 	my $proto = getprotobyname('tcp');
-	my $sockaddr;
 	my $that;
 	my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost);
 
@@ -154,8 +153,7 @@ sub bindRemote ($$)
 	    print "IRCD UNKNOWN: Could not start socket ($!)\n";
 	    exit $ERRORS{"UNKNOWN"};
 	}
-	$sockaddr = 'S n a4 x8';
-	$that = pack($sockaddr, AF_INET, $in_remoteport, $thataddr);
+	$that = pack_sockaddr_in ($in_remoteport, $thataddr);
 	if (!connect(ClientSocket, $that)) { 
 	    print "IRCD UNKNOWN: Could not connect socket ($!)\n";
 	    exit $ERRORS{"UNKNOWN"};
-- 
cgit v0.10-9-g596f


From 6d7d9a87aa74f00ed5603e13ebf96bb2b72e084a Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Fri, 6 Oct 2023 15:08:52 +0200
Subject: Refactor get_threshold2 to be barely understandable


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 197ce32..79b9357 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -176,6 +176,16 @@ typedef union icmp_packet {
 #define MODE_ALL 2
 #define MODE_ICMP 3
 
+enum enum_threshold_mode {
+	const_rta_mode,
+	const_packet_loss_mode,
+	const_jitter_mode,
+	const_mos_mode,
+	const_score_mode
+};
+
+typedef enum enum_threshold_mode threshold_mode;
+
 /* the different ping types we can do
  * TODO: investigate ARP ping as well */
 #define HAVE_ICMP 1
@@ -205,7 +215,7 @@ static int wait_for_reply(int, u_int);
 static int recvfrom_wto(int, void *, unsigned int, struct sockaddr *, u_int *, struct timeval*);
 static int send_icmp_ping(int, struct rta_host *);
 static int get_threshold(char *str, threshold *th);
-static int get_threshold2(char *str, threshold *, threshold *, int type);
+static int get_threshold2(char *str, size_t length, threshold *, threshold *, threshold_mode mode);
 static void run_checks(void);
 static void set_source_ip(char *);
 static int add_target(char *);
@@ -581,23 +591,23 @@ main(int argc, char **argv)
 				exit (STATE_UNKNOWN);
 				break;
 			case 'R': /* RTA mode */
-				get_threshold2(optarg, &warn, &crit,1);
+				get_threshold2(optarg, strlen(optarg), &warn, &crit, const_rta_mode);
 				rta_mode=true;
 				break;
 			case 'P': /* packet loss mode */
-				get_threshold2(optarg, &warn, &crit,2);
+				get_threshold2(optarg, strlen(optarg), &warn, &crit, const_packet_loss_mode);
 				pl_mode=true;
 				break;
 			case 'J': /* jitter mode */
-				get_threshold2(optarg, &warn, &crit,3);
+				get_threshold2(optarg, strlen(optarg), &warn, &crit, const_jitter_mode);
 				jitter_mode=true;
 				break;
 			case 'M': /* MOS mode */
-				get_threshold2(optarg, &warn, &crit,4);
+				get_threshold2(optarg, strlen(optarg), &warn, &crit, const_mos_mode);
 				mos_mode=true;
 				break;
 			case 'S': /* score mode */
-				get_threshold2(optarg, &warn, &crit,5);
+				get_threshold2(optarg, strlen(optarg), &warn, &crit, const_score_mode);
 				score_mode=true;
 				break;
 			case 'O': /* out of order mode */
@@ -1834,43 +1844,63 @@ get_threshold(char *str, threshold *th)
 
 /* not too good at checking errors, but it'll do (main() should barfe on -1) */
 static int
-get_threshold2(char *str, threshold *warn, threshold *crit, int type)
+get_threshold2(char *str, size_t length, threshold *warn, threshold *crit, threshold_mode mode)
 {
+	if (!str || !length || !warn || !crit) return -1;
+
 	char *p = NULL;
-	bool i = false;
+	bool first_iteration = true;
+
+	// pointer magic slims code by 10 lines. i is bof-stop on stupid libc's
+	// p points to the last char in str
+	p = &str[length - 1];
 
-	if(!str || !strlen(str) || !warn || !crit) return -1;
-	/* pointer magic slims code by 10 lines. i is bof-stop on stupid libc's */
-	p = &str[strlen(str) - 1];
 	while(p != &str[0]) {
-		if( (*p == 'm') || (*p == '%') ) *p = '\0';
-		else if(*p == ',' && i) {
+		if( (*p == 'm') || (*p == '%') ) {
+			*p = '\0';
+		} else if(*p == ',' && !first_iteration) {
 			*p = '\0';	/* reset it so get_timevar(str) works nicely later */
-			if (type==1)
-				crit->rta = atof(p+1)*1000;
-			else if  (type==2)
-				crit->pl = (unsigned char)strtoul(p+1, NULL, 0);
-			else if  (type==3)
-				crit->jitter = atof(p+1);
-			else if (type==4)
-				crit->mos = atof(p+1);
-			else if (type==5)
-				crit->score = atof(p+1);
+
+			switch (mode) {
+				case const_rta_mode:
+					crit->rta = atof(p+1)*1000;
+					break;
+				case  const_packet_loss_mode:
+					crit->pl = (unsigned char)strtoul(p+1, NULL, 0);
+					break;
+				case const_jitter_mode:
+					crit->jitter = atof(p+1);
+					break;
+				case const_mos_mode:
+					crit->mos = atof(p+1);
+					break;
+				case const_score_mode:
+					crit->score = atof(p+1);
+					break;
+			}
 		}
-		i = true;
+		first_iteration = false;
 		p--;
 	}
-	if (type==1)
-		warn->rta = atof(p)*1000;
-	else if (type==2)
-		warn->pl = (unsigned char)strtoul(p, NULL, 0);
-	if (type==3)
-		warn->jitter = atof(p);
-	else if (type==4)
-		warn->mos = atof(p);
-	else if (type==5)
-		warn->score = atof(p);
-	return 0;
+
+		switch (mode) {
+			case const_rta_mode:
+				warn->rta = atof(p)*1000;
+				break;
+			case const_packet_loss_mode:
+				warn->pl = (unsigned char)strtoul(p, NULL, 0);
+				break;
+			case const_jitter_mode:
+				warn->jitter = atof(p);
+				break;
+			case const_mos_mode:
+				warn->mos = atof(p);
+				break;
+			case const_score_mode:
+				warn->score = atof(p);
+				break;
+		}
+		return 0;
 }
 
 unsigned short
-- 
cgit v0.10-9-g596f


From d54588eaf0fc1ec35cfac988dbb2764069fbc909 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Fri, 6 Oct 2023 15:19:33 +0200
Subject: Update comment


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 79b9357..541e795 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -43,7 +43,7 @@ const char *copyright = "2005-2008";
 const char *email = "devel@monitoring-plugins.org";
 
 /** Monitoring Plugins basic includes */
-#include "common.h"
+#include "../plugins/common.h"
 #include "netutils.h"
 #include "utils.h"
 
@@ -1851,10 +1851,10 @@ get_threshold2(char *str, size_t length, threshold *warn, threshold *crit, thres
 	char *p = NULL;
 	bool first_iteration = true;
 
-	// pointer magic slims code by 10 lines. i is bof-stop on stupid libc's
 	// p points to the last char in str
 	p = &str[length - 1];
 
+	// first_iteration is bof-stop on stupid libc's
 	while(p != &str[0]) {
 		if( (*p == 'm') || (*p == '%') ) {
 			*p = '\0';
-- 
cgit v0.10-9-g596f


From aba1ef97f3fdfea191fe8ace2a41551be3dab027 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Fri, 6 Oct 2023 16:04:43 +0200
Subject: Change function type of get_thresholds to better reflect the options
 and describe it in general


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 541e795..ce88bec 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -215,7 +215,7 @@ static int wait_for_reply(int, u_int);
 static int recvfrom_wto(int, void *, unsigned int, struct sockaddr *, u_int *, struct timeval*);
 static int send_icmp_ping(int, struct rta_host *);
 static int get_threshold(char *str, threshold *th);
-static int get_threshold2(char *str, size_t length, threshold *, threshold *, threshold_mode mode);
+static bool get_threshold2(char *str, size_t length, threshold *, threshold *, threshold_mode mode);
 static void run_checks(void);
 static void set_source_ip(char *);
 static int add_target(char *);
@@ -1842,11 +1842,18 @@ get_threshold(char *str, threshold *th)
 	return 0;
 }
 
-/* not too good at checking errors, but it'll do (main() should barfe on -1) */
-static int
-get_threshold2(char *str, size_t length, threshold *warn, threshold *crit, threshold_mode mode)
-{
-	if (!str || !length || !warn || !crit) return -1;
+/*
+ * This functions receives a pointer to a string which should contain a threshold for the
+ * rta, packet_loss, jitter, mos or score mode in the form number,number[m|%]* assigns the
+ * parsed number to the corresponding threshold variable.
+ * @param[in,out] str String containing the given threshold values
+ * @param[in] length strlen(str)
+ * @param[out] warn Pointer to the warn threshold struct to which the values should be assigned
+ * @param[out] crit Pointer to the crit threshold struct to which the values should be assigned
+ * @param[in] mode Determines whether this a threshold vor rta, packet_loss, jitter, mos or score (exclusively)
+ */
+static bool get_threshold2(char *str, size_t length, threshold *warn, threshold *crit, threshold_mode mode) {
+	if (!str || !length || !warn || !crit) return false;
 
 	char *p = NULL;
 	bool first_iteration = true;
@@ -1900,7 +1907,7 @@ get_threshold2(char *str, size_t length, threshold *warn, threshold *crit, thres
 				warn->score = atof(p);
 				break;
 		}
-		return 0;
+		return true;
 }
 
 unsigned short
-- 
cgit v0.10-9-g596f


From 9faa417aeb468be0ebb646ee3fc276014795e76f Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Fri, 6 Oct 2023 16:05:01 +0200
Subject: Remove useless return after crash


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index ce88bec..c71ea29 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -770,7 +770,6 @@ main(int argc, char **argv)
 	table = malloc(sizeof(struct rta_host *) * targets);
 	if(!table) {
 		crash("main(): malloc failed for host table");
-		return 3;
 	}
 
 	i = 0;
-- 
cgit v0.10-9-g596f


From 19dc0039365e5cae0ed866c10202c50338f70b0a Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sat, 7 Oct 2023 11:48:57 +0200
Subject: Do some actual error checking on the threshold parser


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index c71ea29..7140aa5 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -526,7 +526,8 @@ main(int argc, char **argv)
 	/* Reset argument scanning */
 	optind = 1;
 
-        unsigned long size;
+	unsigned long size;
+	bool err;
 	/* parse the arguments */
 	for(i = 1; i < argc; i++) {
 		while((arg = getopt(argc, argv, opts_str)) != EOF) {
@@ -591,23 +592,48 @@ main(int argc, char **argv)
 				exit (STATE_UNKNOWN);
 				break;
 			case 'R': /* RTA mode */
-				get_threshold2(optarg, strlen(optarg), &warn, &crit, const_rta_mode);
+				err = get_threshold2(optarg, strlen(optarg), &warn, &crit, const_rta_mode);
+
+				if (!err) {
+						crash("Failed to parse RTA threshold");
+				}
+
 				rta_mode=true;
 				break;
 			case 'P': /* packet loss mode */
-				get_threshold2(optarg, strlen(optarg), &warn, &crit, const_packet_loss_mode);
+				err = get_threshold2(optarg, strlen(optarg), &warn, &crit, const_packet_loss_mode);
+
+				if (!err) {
+						crash("Failed to parse packet loss threshold");
+				}
+
 				pl_mode=true;
 				break;
 			case 'J': /* jitter mode */
-				get_threshold2(optarg, strlen(optarg), &warn, &crit, const_jitter_mode);
+				err = get_threshold2(optarg, strlen(optarg), &warn, &crit, const_jitter_mode);
+
+				if (!err) {
+						crash("Failed to parse jitter threshold");
+				}
+
 				jitter_mode=true;
 				break;
 			case 'M': /* MOS mode */
-				get_threshold2(optarg, strlen(optarg), &warn, &crit, const_mos_mode);
+				err = get_threshold2(optarg, strlen(optarg), &warn, &crit, const_mos_mode);
+
+				if (!err) {
+						crash("Failed to parse MOS threshold");
+				}
+
 				mos_mode=true;
 				break;
 			case 'S': /* score mode */
-				get_threshold2(optarg, strlen(optarg), &warn, &crit, const_score_mode);
+				err = get_threshold2(optarg, strlen(optarg), &warn, &crit, const_score_mode);
+
+				if (!err) {
+						crash("Failed to parse score threshold");
+				}
+
 				score_mode=true;
 				break;
 			case 'O': /* out of order mode */
-- 
cgit v0.10-9-g596f


From b81847cb5f520ec23a1c907be330c1ad8eeeba2d Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sat, 7 Oct 2023 11:49:27 +0200
Subject: Refactor new threshold parser


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 7140aa5..7c04ef2 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -216,6 +216,7 @@ static int recvfrom_wto(int, void *, unsigned int, struct sockaddr *, u_int *, s
 static int send_icmp_ping(int, struct rta_host *);
 static int get_threshold(char *str, threshold *th);
 static bool get_threshold2(char *str, size_t length, threshold *, threshold *, threshold_mode mode);
+static bool parse_threshold2_helper(char *s, size_t length, threshold *thr, threshold_mode mode);
 static void run_checks(void);
 static void set_source_ip(char *);
 static int add_target(char *);
@@ -1880,59 +1881,66 @@ get_threshold(char *str, threshold *th)
 static bool get_threshold2(char *str, size_t length, threshold *warn, threshold *crit, threshold_mode mode) {
 	if (!str || !length || !warn || !crit) return false;
 
-	char *p = NULL;
-	bool first_iteration = true;
 
 	// p points to the last char in str
-	p = &str[length - 1];
+	char *p = &str[length - 1];
 
 	// first_iteration is bof-stop on stupid libc's
+	bool first_iteration = true;
+
 	while(p != &str[0]) {
 		if( (*p == 'm') || (*p == '%') ) {
 			*p = '\0';
 		} else if(*p == ',' && !first_iteration) {
 			*p = '\0';	/* reset it so get_timevar(str) works nicely later */
 
-			switch (mode) {
-				case const_rta_mode:
-					crit->rta = atof(p+1)*1000;
-					break;
-				case  const_packet_loss_mode:
-					crit->pl = (unsigned char)strtoul(p+1, NULL, 0);
-					break;
-				case const_jitter_mode:
-					crit->jitter = atof(p+1);
-					break;
-				case const_mos_mode:
-					crit->mos = atof(p+1);
-					break;
-				case const_score_mode:
-					crit->score = atof(p+1);
-					break;
+			char *start_of_value = p + 1;
+
+			if (!parse_threshold2_helper(start_of_value, strlen(start_of_value), crit, mode)){
+				return false;
 			}
+
 		}
 		first_iteration = false;
 		p--;
 	}
 
-		switch (mode) {
-			case const_rta_mode:
-				warn->rta = atof(p)*1000;
-				break;
-			case const_packet_loss_mode:
-				warn->pl = (unsigned char)strtoul(p, NULL, 0);
-				break;
-			case const_jitter_mode:
-				warn->jitter = atof(p);
-				break;
-			case const_mos_mode:
-				warn->mos = atof(p);
-				break;
-			case const_score_mode:
-				warn->score = atof(p);
-				break;
-		}
-		return true;
+	return parse_threshold2_helper(p, strlen(p), warn, mode);
+}
+
+static bool parse_threshold2_helper(char *s, size_t length, threshold *thr, threshold_mode mode) {
+	char *resultChecker = {0};
+
+	switch (mode) {
+		case const_rta_mode:
+			thr->rta = strtod(s, &resultChecker) * 1000;
+			break;
+		case const_packet_loss_mode:
+			thr->pl = (unsigned char)strtoul(s, &resultChecker, 0);
+			break;
+		case const_jitter_mode:
+			thr->jitter = strtod(s, &resultChecker);
+
+			break;
+		case const_mos_mode:
+			thr->mos = strtod(s, &resultChecker);
+			break;
+		case const_score_mode:
+			thr->score = strtod(s, &resultChecker);
+			break;
+	}
+
+	if (resultChecker == s) {
+		// Failed to parse
+		return false;
+	}
+
+	if (resultChecker != (s + length)) {
+		// Trailing symbols
+		return false;
+	}
+
+	return true;
 }
 
 unsigned short
-- 
cgit v0.10-9-g596f


From da59856f99815cb86c2b6c633a4a49bc6895fd7b Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sat, 7 Oct 2023 22:43:44 +0200
Subject: Fix typo


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 7c04ef2..e96fa3e 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1876,7 +1876,7 @@ get_threshold(char *str, threshold *th)
  * @param[in] length strlen(str)
  * @param[out] warn Pointer to the warn threshold struct to which the values should be assigned
  * @param[out] crit Pointer to the crit threshold struct to which the values should be assigned
- * @param[in] mode Determines whether this a threshold vor rta, packet_loss, jitter, mos or score (exclusively)
+ * @param[in] mode Determines whether this a threshold for rta, packet_loss, jitter, mos or score (exclusively)
  */
 static bool get_threshold2(char *str, size_t length, threshold *warn, threshold *crit, threshold_mode mode) {
 	if (!str || !length || !warn || !crit) return false;
-- 
cgit v0.10-9-g596f


From 09923e8a0ffd3540f7c950743ef6b60ea85fe9cd Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sat, 7 Oct 2023 23:31:59 +0200
Subject: Fix missing include in plugins/runcmd.c


diff --git a/plugins/runcmd.c b/plugins/runcmd.c
index bc0a497..4f3e349 100644
--- a/plugins/runcmd.c
+++ b/plugins/runcmd.c
@@ -60,6 +60,8 @@
 # define SIG_ERR ((Sigfunc *)-1)
 #endif
 
+#include "../lib/maxfd.h"
+
 /* This variable must be global, since there's no way the caller
  * can forcibly slay a dead or ungainly running program otherwise.
  * Multithreading apps and plugins can initialize it (via NP_RUNCMD_INIT)
-- 
cgit v0.10-9-g596f


From 9426b9a33828c19188d6928ac862dd3179e44e68 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 8 Oct 2023 22:48:39 +0200
Subject: Initialise threshold variables properly


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index e96fa3e..abc5595 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -234,7 +234,22 @@ extern char **environ;
 
 /** global variables **/
 static struct rta_host **table, *cursor, *list;
-static threshold crit = {80, 500000}, warn = {40, 200000};
+
+static threshold crit = {
+	.pl = 80,
+	.rta = 500000,
+	.jitter = 0.0,
+	.mos = 0.0,
+	.score = 0.0
+};
+static threshold warn = {
+	.pl = 40,
+	.rta = 200000,
+	.jitter = 0.0,
+	.mos = 0.0,
+	.score = 0.0
+};
+
 static int mode, protocols, sockets, debug = 0, timeout = 10;
 static unsigned short icmp_data_size = DEFAULT_PING_DATA_SIZE;
 static unsigned short icmp_pkt_size = DEFAULT_PING_DATA_SIZE + ICMP_MINLEN;
-- 
cgit v0.10-9-g596f


From b053278b186b4b9dfacff53b30cc2c7967923724 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 8 Oct 2023 22:49:45 +0200
Subject: fix sign compare compiler warnings


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index abc5595..f21bf3b 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1053,9 +1053,9 @@ wait_for_reply(int sock, u_int t)
 		host->time_waited += tdiff;
 		host->icmp_recv++;
 		icmp_recv++;
-		if (tdiff > (int)host->rtmax)
+		if (tdiff > (unsigned int)host->rtmax)
 			host->rtmax = tdiff;
-		if (tdiff < (int)host->rtmin)
+		if (tdiff < (unsigned int)host->rtmin)
 			host->rtmin = tdiff;
 
 		if(debug) {
-- 
cgit v0.10-9-g596f


From 6a4b9927cb8bf3ca96c83735c97ccb4ca9ddd4e8 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 8 Oct 2023 22:50:17 +0200
Subject: fix unused variables compiler warning


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index f21bf3b..06c8b78 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1216,7 +1216,9 @@ recvfrom_wto(int sock, void *buf, unsigned int len, struct sockaddr *saddr,
 	int n, ret;
 	struct timeval to, then, now;
 	fd_set rd, wr;
+#ifdef HAVE_MSGHDR_MSG_CONTROL
 	char ans_data[4096];
+#endif // HAVE_MSGHDR_MSG_CONTROL
 	struct msghdr hdr;
 	struct iovec iov;
 #ifdef SO_TIMESTAMP
-- 
cgit v0.10-9-g596f


From b6fea24c3deaf73ee4fa8052fe435ece445fdc4f Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Mon, 9 Oct 2023 01:17:44 +0200
Subject: More consequent booleans


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 06c8b78..99bd667 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1347,8 +1347,8 @@ finish(int sig)
 
 		/* if no new mode selected, use old schema */
 		if (!rta_mode && !pl_mode && !jitter_mode && !score_mode && !mos_mode && !order_mode) {
-			rta_mode=1;
-			pl_mode=1;
+			rta_mode = true;
+			pl_mode = true;
 		}
 
 #define THIS_STATUS_WARNING this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status)
-- 
cgit v0.10-9-g596f


From f7df88dac3528b0834c897dfdfff07b9f56fd8d3 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Mon, 9 Oct 2023 01:18:04 +0200
Subject: Do some code formatting


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 99bd667..39ca302 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1327,21 +1327,24 @@ finish(int sig)
 		if (host->icmp_recv>1) {
 			host->jitter=(host->jitter / (host->icmp_recv - 1)/1000);
 			host->EffectiveLatency = (rta/1000) + host->jitter * 2 + 10;
-			if (host->EffectiveLatency < 160)
+
+			if (host->EffectiveLatency < 160) {
 			   R = 93.2 - (host->EffectiveLatency / 40);
-			else
+			} else {
 			   R = 93.2 - ((host->EffectiveLatency - 120) / 10);
+			}
+
 			R = R - (pl * 2.5);
 			if (R<0) R=0;
 			host->score = R;
 			host->mos= 1 + ((0.035) * R) + ((.000007) * R * (R-60) * (100-R));
-		}
-		else {
+		} else {
 			host->jitter=0;
 			host->jitter_min=0;
 			host->jitter_max=0;
 			host->mos=0;
 		}
+
 		host->pl = pl;
 		host->rta = rta;
 
@@ -1358,56 +1361,55 @@ finish(int sig)
 				this_status = STATE_CRITICAL;
 				status = STATE_CRITICAL;
 				host->rta_status=STATE_CRITICAL;
-			}
-			else if(status!=STATE_CRITICAL && (rta >= warn.rta)) {
+			} else if(status!=STATE_CRITICAL && (rta >= warn.rta)) {
 				THIS_STATUS_WARNING;
 				status = STATE_WARNING;
 				host->rta_status=STATE_WARNING;
 			}
 		}
+
 		if (pl_mode) {
 			if(pl >= crit.pl) {
 				this_status = STATE_CRITICAL;
 				status = STATE_CRITICAL;
 				host->pl_status=STATE_CRITICAL;
-			}
-			else if(status!=STATE_CRITICAL && (pl >= warn.pl)) {
+			} else if(status!=STATE_CRITICAL && (pl >= warn.pl)) {
 				THIS_STATUS_WARNING;
 				status = STATE_WARNING;
 				host->pl_status=STATE_WARNING;
 			}
 		}
+
 		if (jitter_mode) {
 			if(host->jitter >= crit.jitter) {
 				this_status = STATE_CRITICAL;
 				status = STATE_CRITICAL;
 				host->jitter_status=STATE_CRITICAL;
-			}
-			else if(status!=STATE_CRITICAL && (host->jitter >= warn.jitter)) {
+			} else if(status!=STATE_CRITICAL && (host->jitter >= warn.jitter)) {
 				THIS_STATUS_WARNING;
 				status = STATE_WARNING;
 				host->jitter_status=STATE_WARNING;
 			}
 		}
+
 		if (mos_mode) {
 			if(host->mos <= crit.mos) {
 				this_status = STATE_CRITICAL;
 				status = STATE_CRITICAL;
 				host->mos_status=STATE_CRITICAL;
-			}
-			else if(status!=STATE_CRITICAL && (host->mos <= warn.mos)) {
+			} else if(status!=STATE_CRITICAL && (host->mos <= warn.mos)) {
 				THIS_STATUS_WARNING;
 				status = STATE_WARNING;
 				host->mos_status=STATE_WARNING;
 			}
 		}
+
 		if (score_mode) {
 			if(host->score <= crit.score) {
 				this_status = STATE_CRITICAL;
 				status = STATE_CRITICAL;
 				host->score_status=STATE_CRITICAL;
-			}
-			else if(status!=STATE_CRITICAL && (host->score <= warn.score)) {
+			} else if(status!=STATE_CRITICAL && (host->score <= warn.score)) {
 				THIS_STATUS_WARNING;
 				status = STATE_WARNING;
 				host->score_status=STATE_WARNING;
@@ -1416,8 +1418,7 @@ finish(int sig)
 
 		if (this_status == STATE_WARNING) {
 			hosts_warn++;
-		}
-		else if (this_status == STATE_OK) {
+		} else if (this_status == STATE_OK) {
 			hosts_ok++;
 		}
 
-- 
cgit v0.10-9-g596f


From c568ad207c7284f301120698d20aec57ed4f24f6 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Mon, 9 Oct 2023 01:31:52 +0200
Subject: Remove preprocessor macro


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 39ca302..5a9485d 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1354,7 +1354,6 @@ finish(int sig)
 			pl_mode = true;
 		}
 
-#define THIS_STATUS_WARNING this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status)
 		/* Check which mode is on and do the warn / Crit stuff */
 		if (rta_mode) {
 			if(rta >= crit.rta) {
@@ -1362,7 +1361,7 @@ finish(int sig)
 				status = STATE_CRITICAL;
 				host->rta_status=STATE_CRITICAL;
 			} else if(status!=STATE_CRITICAL && (rta >= warn.rta)) {
-				THIS_STATUS_WARNING;
+				this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status)
 				status = STATE_WARNING;
 				host->rta_status=STATE_WARNING;
 			}
@@ -1374,7 +1373,7 @@ finish(int sig)
 				status = STATE_CRITICAL;
 				host->pl_status=STATE_CRITICAL;
 			} else if(status!=STATE_CRITICAL && (pl >= warn.pl)) {
-				THIS_STATUS_WARNING;
+				this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status)
 				status = STATE_WARNING;
 				host->pl_status=STATE_WARNING;
 			}
@@ -1386,7 +1385,7 @@ finish(int sig)
 				status = STATE_CRITICAL;
 				host->jitter_status=STATE_CRITICAL;
 			} else if(status!=STATE_CRITICAL && (host->jitter >= warn.jitter)) {
-				THIS_STATUS_WARNING;
+				this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status)
 				status = STATE_WARNING;
 				host->jitter_status=STATE_WARNING;
 			}
@@ -1398,7 +1397,7 @@ finish(int sig)
 				status = STATE_CRITICAL;
 				host->mos_status=STATE_CRITICAL;
 			} else if(status!=STATE_CRITICAL && (host->mos <= warn.mos)) {
-				THIS_STATUS_WARNING;
+				this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status)
 				status = STATE_WARNING;
 				host->mos_status=STATE_WARNING;
 			}
@@ -1410,7 +1409,7 @@ finish(int sig)
 				status = STATE_CRITICAL;
 				host->score_status=STATE_CRITICAL;
 			} else if(status!=STATE_CRITICAL && (host->score <= warn.score)) {
-				THIS_STATUS_WARNING;
+				this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status)
 				status = STATE_WARNING;
 				host->score_status=STATE_WARNING;
 			}
-- 
cgit v0.10-9-g596f


From 9da06d562515d6b443e4bbb54652a88f6a1cb4ca Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Mon, 9 Oct 2023 01:57:37 +0200
Subject: Do some more formatting


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 5a9485d..1573dca 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -109,24 +109,24 @@ typedef struct rta_host {
 	unsigned char icmp_type, icmp_code; /* type and code from errors */
 	unsigned short flags;        /* control/status flags */
 	double rta;                  /* measured RTA */
-	int			rta_status;
+	int rta_status;              // check result for RTA checks
 	double rtmax;                /* max rtt */
 	double rtmin;                /* min rtt */
-	double jitter;                  /* measured jitter */
-	int			jitter_status;
-	double jitter_max;                /* jitter rtt */
-	double jitter_min;                /* jitter rtt */
+	double jitter;               /* measured jitter */
+	int jitter_status;           // check result for Jitter checks
+	double jitter_max;           /* jitter rtt maximum */
+	double jitter_min;           /* jitter rtt minimum */
 	double EffectiveLatency;
-	double mos;									/* Mean opnion score */
-	int			mos_status;
-	double	score;							/* score */
-	int			score_status;
+	double mos;                  /* Mean opnion score */
+	int mos_status;              // check result for MOS checks
+	double  score;               /* score */
+	int score_status;            // check result for score checks
 	u_int last_tdiff;
-	u_int	last_icmp_seq;        /* Last ICMP_SEQ to check out of order pkts */
+	u_int last_icmp_seq;         /* Last ICMP_SEQ to check out of order pkts */
 	unsigned char pl;            /* measured packet loss */
-	int			pl_status;
+	int pl_status;               // check result for packet loss checks
 	struct rta_host *next;       /* linked list */
-	int	order_status;
+	int order_status;            // check result for packet order checks
 } rta_host;
 
 #define FLAG_LOST_CAUSE 0x01  /* decidedly dead target. */
@@ -228,7 +228,7 @@ static void finish(int);
 static void crash(const char *, ...);
 
 /** external **/
-extern int optind, opterr, optopt;
+extern int optind;
 extern char *optarg;
 extern char **environ;
 
@@ -459,7 +459,7 @@ main(int argc, char **argv)
 	 * that before pointer magic (esp. on network data) */
 	icmp_sockerrno = udp_sockerrno = tcp_sockerrno = sockets = 0;
 
-        address_family = -1;
+	address_family = -1;
 	int icmp_proto = IPPROTO_ICMP;
 
 	/* get calling name the old-fashioned way for portability instead
@@ -1361,7 +1361,7 @@ finish(int sig)
 				status = STATE_CRITICAL;
 				host->rta_status=STATE_CRITICAL;
 			} else if(status!=STATE_CRITICAL && (rta >= warn.rta)) {
-				this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status)
+				this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status);
 				status = STATE_WARNING;
 				host->rta_status=STATE_WARNING;
 			}
@@ -1373,7 +1373,7 @@ finish(int sig)
 				status = STATE_CRITICAL;
 				host->pl_status=STATE_CRITICAL;
 			} else if(status!=STATE_CRITICAL && (pl >= warn.pl)) {
-				this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status)
+				this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status);
 				status = STATE_WARNING;
 				host->pl_status=STATE_WARNING;
 			}
@@ -1385,7 +1385,7 @@ finish(int sig)
 				status = STATE_CRITICAL;
 				host->jitter_status=STATE_CRITICAL;
 			} else if(status!=STATE_CRITICAL && (host->jitter >= warn.jitter)) {
-				this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status)
+				this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status);
 				status = STATE_WARNING;
 				host->jitter_status=STATE_WARNING;
 			}
@@ -1397,7 +1397,7 @@ finish(int sig)
 				status = STATE_CRITICAL;
 				host->mos_status=STATE_CRITICAL;
 			} else if(status!=STATE_CRITICAL && (host->mos <= warn.mos)) {
-				this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status)
+				this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status);
 				status = STATE_WARNING;
 				host->mos_status=STATE_WARNING;
 			}
@@ -1409,7 +1409,7 @@ finish(int sig)
 				status = STATE_CRITICAL;
 				host->score_status=STATE_CRITICAL;
 			} else if(status!=STATE_CRITICAL && (host->score <= warn.score)) {
-				this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status)
+				this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status);
 				status = STATE_WARNING;
 				host->score_status=STATE_WARNING;
 			}
@@ -1763,7 +1763,7 @@ add_target(char *arg)
 		}
 		break;
 	}
-        freeaddrinfo(res);
+	freeaddrinfo(res);
 
 	return 0;
 }
@@ -1985,91 +1985,91 @@ icmp_checksum(uint16_t *p, size_t n)
 void
 print_help(void)
 {
-  /*print_revision (progname);*/ /* FIXME: Why? */
-  printf ("Copyright (c) 2005 Andreas Ericsson <ae@op5.se>\n");
-
-  printf (COPYRIGHT, copyright, email);
-
-  printf ("\n\n");
-
-  print_usage ();
-
-  printf (UT_HELP_VRSN);
-  printf (UT_EXTRA_OPTS);
-
-  printf (" %s\n", "-H");
-  printf ("    %s\n", _("specify a target"));
-  printf (" %s\n", "[-4|-6]");
-  printf ("    %s\n", _("Use IPv4 (default) or IPv6 to communicate with the targets"));
-  printf (" %s\n", "-w");
-  printf ("    %s", _("warning threshold (currently "));
-  printf ("%0.3fms,%u%%)\n", (float)warn.rta / 1000, warn.pl);
-  printf (" %s\n", "-c");
-  printf ("    %s", _("critical threshold (currently "));
-  printf ("%0.3fms,%u%%)\n", (float)crit.rta / 1000, crit.pl);
-
-  printf (" %s\n", "-R");
-  printf ("    %s\n", _("RTA, round trip average,  mode  warning,critical, ex. 100ms,200ms unit in ms"));
-  printf (" %s\n", "-P");
-  printf ("    %s\n", _("packet loss mode, ex. 40%,50% , unit in %"));
-  printf (" %s\n", "-J");
-  printf ("    %s\n", _("jitter mode  warning,critical, ex. 40.000ms,50.000ms , unit in ms "));
-  printf (" %s\n", "-M");
-  printf ("    %s\n", _("MOS mode, between 0 and 4.4  warning,critical, ex. 3.5,3.0"));
-  printf (" %s\n", "-S");
-  printf ("    %s\n", _("score  mode, max value 100  warning,critical, ex. 80,70 "));
-  printf (" %s\n", "-O");
-  printf ("    %s\n", _("detect out of order ICMP packts "));
-  printf (" %s\n", "-H");
-  printf ("    %s\n", _("specify a target"));
-  printf (" %s\n", "-s");
-  printf ("    %s\n", _("specify a source IP address or device name"));
-  printf (" %s\n", "-n");
-  printf ("    %s", _("number of packets to send (currently "));
-  printf ("%u)\n",packets);
-  printf (" %s\n", "-p");
-  printf ("    %s", _("number of packets to send (currently "));
-  printf ("%u)\n",packets);
-  printf (" %s\n", "-i");
-  printf ("    %s", _("max packet interval (currently "));
-  printf ("%0.3fms)\n",(float)pkt_interval / 1000);
-  printf (" %s\n", "-I");
-  printf ("    %s", _("max target interval (currently "));
-  printf ("%0.3fms)\n", (float)target_interval / 1000);
-  printf (" %s\n", "-m");
-  printf ("    %s",_("number of alive hosts required for success"));
-  printf ("\n");
-  printf (" %s\n", "-l");
-  printf ("    %s", _("TTL on outgoing packets (currently "));
-  printf ("%u)\n", ttl);
-  printf (" %s\n", "-t");
-  printf ("    %s",_("timeout value (seconds, currently  "));
-  printf ("%u)\n", timeout);
-  printf (" %s\n", "-b");
-  printf ("    %s\n", _("Number of icmp data bytes to send"));
-  printf ("    %s %u + %d)\n", _("Packet size will be data bytes + icmp header (currently"),icmp_data_size, ICMP_MINLEN);
-  printf (" %s\n", "-v");
-  printf ("    %s\n", _("verbose"));
-  printf ("\n");
-  printf ("%s\n", _("Notes:"));
-  printf (" %s\n", _("If none of R,P,J,M,S or O is specified, default behavior is -R -P"));
-  printf (" %s\n", _("The -H switch is optional. Naming a host (or several) to check is not."));
-  printf ("\n");
-  printf (" %s\n", _("Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%"));
-  printf (" %s\n", _("packet loss.  The default values should work well for most users."));
-  printf (" %s\n", _("You can specify different RTA factors using the standardized abbreviations"));
-  printf (" %s\n", _("us (microseconds), ms (milliseconds, default) or just plain s for seconds."));
-/* -d not yet implemented */
-/*  printf ("%s\n", _("Threshold format for -d is warn,crit.  12,14 means WARNING if >= 12 hops"));
-  printf ("%s\n", _("are spent and CRITICAL if >= 14 hops are spent."));
-  printf ("%s\n\n", _("NOTE: Some systems decrease TTL when forming ICMP_ECHOREPLY, others do not."));*/
-  printf ("\n");
-  printf (" %s\n", _("The -v switch can be specified several times for increased verbosity."));
-/*  printf ("%s\n", _("Long options are currently unsupported."));
-  printf ("%s\n", _("Options marked with * require an argument"));
-*/
-
-  printf (UT_SUPPORT);
+	/*print_revision (progname);*/ /* FIXME: Why? */
+	printf ("Copyright (c) 2005 Andreas Ericsson <ae@op5.se>\n");
+
+	printf (COPYRIGHT, copyright, email);
+
+	printf ("\n\n");
+
+	print_usage ();
+
+	printf (UT_HELP_VRSN);
+	printf (UT_EXTRA_OPTS);
+
+	printf (" %s\n", "-H");
+	printf ("    %s\n", _("specify a target"));
+	printf (" %s\n", "[-4|-6]");
+	printf ("    %s\n", _("Use IPv4 (default) or IPv6 to communicate with the targets"));
+	printf (" %s\n", "-w");
+	printf ("    %s", _("warning threshold (currently "));
+	printf ("%0.3fms,%u%%)\n", (float)warn.rta / 1000, warn.pl);
+	printf (" %s\n", "-c");
+	printf ("    %s", _("critical threshold (currently "));
+	printf ("%0.3fms,%u%%)\n", (float)crit.rta / 1000, crit.pl);
+
+	printf (" %s\n", "-R");
+	printf ("    %s\n", _("RTA, round trip average,  mode  warning,critical, ex. 100ms,200ms unit in ms"));
+	printf (" %s\n", "-P");
+	printf ("    %s\n", _("packet loss mode, ex. 40%,50% , unit in %"));
+	printf (" %s\n", "-J");
+	printf ("    %s\n", _("jitter mode  warning,critical, ex. 40.000ms,50.000ms , unit in ms "));
+	printf (" %s\n", "-M");
+	printf ("    %s\n", _("MOS mode, between 0 and 4.4  warning,critical, ex. 3.5,3.0"));
+	printf (" %s\n", "-S");
+	printf ("    %s\n", _("score  mode, max value 100  warning,critical, ex. 80,70 "));
+	printf (" %s\n", "-O");
+	printf ("    %s\n", _("detect out of order ICMP packts "));
+	printf (" %s\n", "-H");
+	printf ("    %s\n", _("specify a target"));
+	printf (" %s\n", "-s");
+	printf ("    %s\n", _("specify a source IP address or device name"));
+	printf (" %s\n", "-n");
+	printf ("    %s", _("number of packets to send (currently "));
+	printf ("%u)\n",packets);
+	printf (" %s\n", "-p");
+	printf ("    %s", _("number of packets to send (currently "));
+	printf ("%u)\n",packets);
+	printf (" %s\n", "-i");
+	printf ("    %s", _("max packet interval (currently "));
+	printf ("%0.3fms)\n",(float)pkt_interval / 1000);
+	printf (" %s\n", "-I");
+	printf ("    %s", _("max target interval (currently "));
+	printf ("%0.3fms)\n", (float)target_interval / 1000);
+	printf (" %s\n", "-m");
+	printf ("    %s",_("number of alive hosts required for success"));
+	printf ("\n");
+	printf (" %s\n", "-l");
+	printf ("    %s", _("TTL on outgoing packets (currently "));
+	printf ("%u)\n", ttl);
+	printf (" %s\n", "-t");
+	printf ("    %s",_("timeout value (seconds, currently  "));
+	printf ("%u)\n", timeout);
+	printf (" %s\n", "-b");
+	printf ("    %s\n", _("Number of icmp data bytes to send"));
+	printf ("    %s %u + %d)\n", _("Packet size will be data bytes + icmp header (currently"),icmp_data_size, ICMP_MINLEN);
+	printf (" %s\n", "-v");
+	printf ("    %s\n", _("verbose"));
+	printf ("\n");
+	printf ("%s\n", _("Notes:"));
+	printf (" %s\n", _("If none of R,P,J,M,S or O is specified, default behavior is -R -P"));
+	printf (" %s\n", _("The -H switch is optional. Naming a host (or several) to check is not."));
+	printf ("\n");
+	printf (" %s\n", _("Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%"));
+	printf (" %s\n", _("packet loss.  The default values should work well for most users."));
+	printf (" %s\n", _("You can specify different RTA factors using the standardized abbreviations"));
+	printf (" %s\n", _("us (microseconds), ms (milliseconds, default) or just plain s for seconds."));
+	/* -d not yet implemented */
+	/*  printf ("%s\n", _("Threshold format for -d is warn,crit.  12,14 means WARNING if >= 12 hops"));
+			printf ("%s\n", _("are spent and CRITICAL if >= 14 hops are spent."));
+			printf ("%s\n\n", _("NOTE: Some systems decrease TTL when forming ICMP_ECHOREPLY, others do not."));*/
+	printf ("\n");
+	printf (" %s\n", _("The -v switch can be specified several times for increased verbosity."));
+	/*  printf ("%s\n", _("Long options are currently unsupported."));
+			printf ("%s\n", _("Options marked with * require an argument"));
+			*/
+
+	printf (UT_SUPPORT);
 }
 
 
@@ -2077,6 +2077,6 @@ print_help(void)
 void
 print_usage (void)
 {
-  printf ("%s\n", _("Usage:"));
-  printf(" %s [options] [-H] host1 host2 hostN\n", progname);
+	printf ("%s\n", _("Usage:"));
+	printf(" %s [options] [-H] host1 host2 hostN\n", progname);
 }
-- 
cgit v0.10-9-g596f


From eb6c83a6501151fcd4e01256e71415c25b25b7da Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Mon, 9 Oct 2023 13:32:04 +0200
Subject: Even more code formatting and cleanup


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 1573dca..915710b 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -609,7 +609,6 @@ main(int argc, char **argv)
 				break;
 			case 'R': /* RTA mode */
 				err = get_threshold2(optarg, strlen(optarg), &warn, &crit, const_rta_mode);
-
 				if (!err) {
 						crash("Failed to parse RTA threshold");
 				}
@@ -618,7 +617,6 @@ main(int argc, char **argv)
 				break;
 			case 'P': /* packet loss mode */
 				err = get_threshold2(optarg, strlen(optarg), &warn, &crit, const_packet_loss_mode);
-
 				if (!err) {
 						crash("Failed to parse packet loss threshold");
 				}
@@ -627,7 +625,6 @@ main(int argc, char **argv)
 				break;
 			case 'J': /* jitter mode */
 				err = get_threshold2(optarg, strlen(optarg), &warn, &crit, const_jitter_mode);
-
 				if (!err) {
 						crash("Failed to parse jitter threshold");
 				}
@@ -636,7 +633,6 @@ main(int argc, char **argv)
 				break;
 			case 'M': /* MOS mode */
 				err = get_threshold2(optarg, strlen(optarg), &warn, &crit, const_mos_mode);
-
 				if (!err) {
 						crash("Failed to parse MOS threshold");
 				}
@@ -645,7 +641,6 @@ main(int argc, char **argv)
 				break;
 			case 'S': /* score mode */
 				err = get_threshold2(optarg, strlen(optarg), &warn, &crit, const_score_mode);
-
 				if (!err) {
 						crash("Failed to parse score threshold");
 				}
@@ -675,10 +670,10 @@ main(int argc, char **argv)
 		add_target(*argv);
 		argv++;
 	}
+
 	if(!targets) {
 		errno = 0;
 		crash("No hosts to check");
-		exit(3);
 	}
 
 	// add_target might change address_family
@@ -1023,21 +1018,24 @@ wait_for_reply(int sock, u_int t)
 			/* Calculate jitter */
 			if (host->last_tdiff > tdiff) {
 				jitter_tmp = host->last_tdiff - tdiff;
-			}
-			else {
+			} else {
 				jitter_tmp = tdiff - host->last_tdiff;
 			}
+
 			if (host->jitter==0) {
 				host->jitter=jitter_tmp;
 				host->jitter_max=jitter_tmp;
 				host->jitter_min=jitter_tmp;
-			}
-			else {
+			} else {
 				host->jitter+=jitter_tmp;
-				if (jitter_tmp < host->jitter_min)
+
+				if (jitter_tmp < host->jitter_min) {
 					host->jitter_min=jitter_tmp;
-				if (jitter_tmp > host->jitter_max)
+				}
+
+				if (jitter_tmp > host->jitter_max) {
 					host->jitter_max=jitter_tmp;
+				}
 			}
 
 			/* Check if packets in order */
@@ -1048,8 +1046,6 @@ wait_for_reply(int sock, u_int t)
 
 		host->last_icmp_seq=packet.icp->icmp_seq;
 
-		//printf("%d tdiff %d host->jitter %u  host->last_tdiff %u\n", icp.icmp_seq, tdiff, host->jitter, host->last_tdiff);
-
 		host->time_waited += tdiff;
 		host->icmp_recv++;
 		icmp_recv++;
@@ -1311,6 +1307,7 @@ finish(int sig)
 
 	while(host) {
 		this_status = STATE_OK;
+
 		if(!host->icmp_recv) {
 			/* rta 0 is ofcourse not entirely correct, but will still show up
 			 * conspicuously as missing entries in perfparse and cacti */
@@ -1319,11 +1316,11 @@ finish(int sig)
 			status = STATE_CRITICAL;
 			/* up the down counter if not already counted */
 			if(!(host->flags & FLAG_LOST_CAUSE) && targets_alive) targets_down++;
-		}
-		else {
+		} else {
 			pl = ((host->icmp_sent - host->icmp_recv) * 100) / host->icmp_sent;
 			rta = (double)host->time_waited / host->icmp_recv;
 		}
+
 		if (host->icmp_recv>1) {
 			host->jitter=(host->jitter / (host->icmp_recv - 1)/1000);
 			host->EffectiveLatency = (rta/1000) + host->jitter * 2 + 10;
@@ -1335,7 +1332,11 @@ finish(int sig)
 			}
 
 			R = R - (pl * 2.5);
-			if (R<0) R=0;
+
+			if (R < 0) {
+				R = 0;
+			}
+
 			host->score = R;
 			host->mos= 1 + ((0.035) * R) + ((.000007) * R * (R-60) * (100-R));
 		} else {
@@ -1454,12 +1455,10 @@ finish(int sig)
 					   get_icmp_error_msg(host->icmp_type, host->icmp_code),
 					   address,
 					   100);
-			}
-			else { /* not marked as lost cause, so we have no flags for it */
+			} else { /* not marked as lost cause, so we have no flags for it */
 				printf("%s: rta nan, lost 100%%", host->name);
 			}
-		}
-		else {	/* !icmp_recv */
+		} else {	/* !icmp_recv */
 			printf("%s", host->name);
 			/* rta text output */
 			if (rta_mode) {
@@ -1525,6 +1524,7 @@ finish(int sig)
 	host = list;
 	while(host) {
 		if(debug) puts("");
+
 		if (rta_mode && host->pl<100) {
 			printf("%srta=%0.3fms;%0.3f;%0.3f;0; %srtmax=%0.3fms;;;; %srtmin=%0.3fms;;;; ",
 			   (targets > 1) ? host->name : "",
@@ -1532,9 +1532,11 @@ finish(int sig)
 			   (targets > 1) ? host->name : "", (float)host->rtmax / 1000,
 			   (targets > 1) ? host->name : "", (host->rtmin < INFINITY) ? (float)host->rtmin / 1000 : (float)0);
 		}
+
 		if (pl_mode) {
 			printf("%spl=%u%%;%u;%u;0;100 ", (targets > 1) ? host->name : "", host->pl, warn.pl, crit.pl);
 		}
+
 		if (jitter_mode && host->pl<100) {
 			printf("%sjitter_avg=%0.3fms;%0.3f;%0.3f;0; %sjitter_max=%0.3fms;;;; %sjitter_min=%0.3fms;;;; ",
 				(targets > 1) ? host->name : "",
@@ -1546,6 +1548,7 @@ finish(int sig)
 				(float)host->jitter_min / 1000
 			);
 		}
+
 		if (mos_mode && host->pl<100) {
 			printf("%smos=%0.1f;%0.1f;%0.1f;0;5 ",
 				(targets > 1) ? host->name : "",
@@ -1554,6 +1557,7 @@ finish(int sig)
 				(float)crit.mos
 			);
 		}
+
 		if (score_mode && host->pl<100) {
 			printf("%sscore=%u;%u;%u;0;100 ",
 				(targets > 1) ? host->name : "",
@@ -1562,6 +1566,7 @@ finish(int sig)
 				(int)crit.score
 			);
 		}
+
 		host = host->next;
 	}
 
-- 
cgit v0.10-9-g596f


From 0de0daccec8cb1ac4b54f0d9b981cf89c1961209 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Fri, 13 Oct 2023 01:25:22 +0200
Subject: Add some more comments about the MOS score


diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 915710b..12fb7b7 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1322,7 +1322,27 @@ finish(int sig)
 		}
 
 		if (host->icmp_recv>1) {
+			/*
+			 * This algorithm is probably pretty much blindly copied from
+			 * locations like this one: https://www.slac.stanford.edu/comp/net/wan-mon/tutorial.html#mos
+			 * It calucates a MOS value (range of 1 to 5, where 1 is bad and 5 really good).
+			 * According to some quick research MOS originates from the Audio/Video transport network area.
+			 * Whether it can and should be computed from ICMP data, I can not say.
+			 *
+			 * Anyway the basic idea is to map a value "R" with a range of 0-100 to the MOS value
+			 *
+			 * MOS stands likely for Mean Opinion Score ( https://en.wikipedia.org/wiki/Mean_Opinion_Score )
+			 *
+			 * More links:
+			 * - https://confluence.slac.stanford.edu/display/IEPM/MOS
+			 */
 			host->jitter=(host->jitter / (host->icmp_recv - 1)/1000);
+
+			/*
+			 * Take the average round trip latency (in milliseconds), add
+			 * round trip jitter, but double the impact to latency
+			 * then add 10 for protocol latencies (in milliseconds).
+			 */
 			host->EffectiveLatency = (rta/1000) + host->jitter * 2 + 10;
 
 			if (host->EffectiveLatency < 160) {
@@ -1331,6 +1351,8 @@ finish(int sig)
 			   R = 93.2 - ((host->EffectiveLatency - 120) / 10);
 			}
 
+			// Now, let us deduct 2.5 R values per percentage of packet loss (i.e. a
+			// loss of 5% will be entered as 5).
 			R = R - (pl * 2.5);
 
 			if (R < 0) {
-- 
cgit v0.10-9-g596f


From f5074ac7f01ba95469748531b503c56b31e55cc3 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Fri, 13 Oct 2023 01:29:31 +0200
Subject: Fix spelling stuff


diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 0f845de..ea0b38b 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -21,7 +21,7 @@ jobs:
         uses: codespell-project/actions-codespell@v2
         with:
           skip: "./.git,./.gitignore,./ABOUT-NLS,*.po,./gl,./po,./tools/squid.conf,./build-aux/ltmain.sh"
-          ignore_words_list: allright,gord,didi,hda,nd,alis,clen,scrit,ser,fot,te,parm,isnt,consol,oneliners,esponse
+          ignore_words_list: allright,gord,didi,hda,nd,alis,clen,scrit,ser,fot,te,parm,isnt,consol,oneliners,esponse,slac
           check_filenames: true
           check_hidden: true
 #  super-linter:
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 12fb7b7..303241d 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1325,7 +1325,7 @@ finish(int sig)
 			/*
 			 * This algorithm is probably pretty much blindly copied from
 			 * locations like this one: https://www.slac.stanford.edu/comp/net/wan-mon/tutorial.html#mos
-			 * It calucates a MOS value (range of 1 to 5, where 1 is bad and 5 really good).
+			 * It calculates a MOS value (range of 1 to 5, where 1 is bad and 5 really good).
 			 * According to some quick research MOS originates from the Audio/Video transport network area.
 			 * Whether it can and should be computed from ICMP data, I can not say.
 			 *
-- 
cgit v0.10-9-g596f


From dbd49978afb1accb78b083d788fd2a7f4b0edef8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
 <12514511+RincewindsHat@users.noreply.github.com>
Date: Fri, 13 Oct 2023 01:38:42 +0200
Subject: Update configure.ac

Co-authored-by: waja <waja@users.noreply.github.com>

diff --git a/configure.ac b/configure.ac
index 58a299f..b5374b2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -646,7 +646,7 @@ AC_TRY_COMPILE([#include <sys/time.h>],
                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
 			   FOUND_STRUCT_TIMEVAL="yes")
 
-if test x$FOUND_STRUCT_TIMEVAL = x"yes"; then
+if test x"$FOUND_STRUCT_TIMEVAL" = x"yes"; then
 	AC_TRY_COMPILE([#include <sys/time.h>],
 			  [struct timeval *tv;
 			   struct timezone *tz;
-- 
cgit v0.10-9-g596f

