--- check_icmp.c-orig	2007-03-07 09:09:56.495583310 -0700
+++ check_icmp.c	2007-03-07 09:24:22.453239194 -0700
@@ -212,6 +212,7 @@
 static unsigned long long max_completion_time = 0;
 static unsigned char ttl = 0;	/* outgoing ttl */
 static unsigned int warn_down = 1, crit_down = 1; /* host down threshold values */
+static int minHostsOk = 9999;
 float pkt_backoff_factor = 1.5;
 float target_backoff_factor = 1.5;
 
@@ -437,7 +438,7 @@
 
 	/* parse the arguments */
 	for(i = 1; i < argc; i++) {
-		while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:i:b:I:l:")) != EOF) {
+		while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:i:b:I:l:m:")) != EOF) {
 			switch(arg) {
 			case 'v':
 				debug++;
@@ -471,6 +472,9 @@
 			case 'l':
 				ttl = (unsigned char)strtoul(optarg, NULL, 0);
 				break;
+			case 'm':
+				minHostsOk = (int)strtoul(optarg, NULL, 0);
+				break;
 			case 'd': /* implement later, for cluster checks */
 				warn_down = (unsigned char)strtoul(optarg, &ptr, 0);
 				if(ptr) {
@@ -879,6 +883,7 @@
 	struct rta_host *host;
 	char *status_string[] =
 	{"OK", "WARNING", "CRITICAL", "UNKNOWN", "DEPENDENT"};
+	int hosts_ok = 0;
 
 	alarm(0);
 	if(debug > 1) printf("finish(%d) called\n", sig);
@@ -913,11 +918,13 @@
 		host->rta = rta;
 		if(!status && (pl >= warn.pl || rta >= warn.rta)) status = STATE_WARNING;
 		if(pl >= crit.pl || rta >= crit.rta) status = STATE_CRITICAL;
+		if (pl < warn.pl && rta < warn.rta) hosts_ok++;
 
 		host = host->next;
 	}
 	/* this is inevitable */
 	if(!targets_alive) status = STATE_CRITICAL;
+	if (hosts_ok >= minHostsOk) status = STATE_OK;
 	printf("%s - ", status_string[status]);
 
 	host = list;
@@ -969,6 +976,8 @@
 	if(debug) printf("targets: %u, targets_alive: %u\n",
 					 targets, targets_alive);
 
+	if (hosts_ok >= minHostsOk) status = STATE_OK;
+
 	exit(status);
 }
 
@@ -1221,8 +1230,11 @@
   printf ("    %s\n", _("icmp packet size (currenly ignored)"));
   printf (" %s\n", "-v");
   printf ("    %s\n", _("verbose"));
+  printf (" %s\n", "-m");
+  printf ("    %s",_("minimum hosts which must return for OK status (default: all)"));
 
   printf ("\n");
+  printf ("\n");
 	printf ("%s\n\n", _("The -H switch is optional. Naming a host (or several) to check is not."));
   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."));