summaryrefslogtreecommitdiffstats
path: root/plugins-root/check_icmp.c
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@users.sourceforge.net>2008-11-07 01:41:17 (GMT)
committerThomas Guyot-Sionnest <dermoth@users.sourceforge.net>2008-11-07 01:41:17 (GMT)
commit526c3ad7a766832676780a82847bcb0756f73c8b (patch)
tree569a3d1fbf1e381f456c59cfab53b3b5c5c1a42c /plugins-root/check_icmp.c
parentdac9d73736570d175ce40a0cc5151e6b0ee3d3d0 (diff)
downloadmonitoring-plugins-526c3ad7a766832676780a82847bcb0756f73c8b.tar.gz
check_icmp now reports min and max round trip time perfdata (Steve Rader)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2073 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins-root/check_icmp.c')
-rw-r--r--plugins-root/check_icmp.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index dff3abb..ff6c73b 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -106,6 +106,9 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
106# define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 106# define ICMP_UNREACH_PRECEDENCE_CUTOFF 15
107#endif 107#endif
108 108
109#ifndef DBL_MAX
110# define DBL_MAX 9.9999999999e999
111#endif
109 112
110typedef unsigned short range_t; /* type for get_range() -- unimplemented */ 113typedef unsigned short range_t; /* type for get_range() -- unimplemented */
111 114
@@ -120,6 +123,8 @@ typedef struct rta_host {
120 unsigned char icmp_type, icmp_code; /* type and code from errors */ 123 unsigned char icmp_type, icmp_code; /* type and code from errors */
121 unsigned short flags; /* control/status flags */ 124 unsigned short flags; /* control/status flags */
122 double rta; /* measured RTA */ 125 double rta; /* measured RTA */
126 double rtmax; /* max rtt */
127 double rtmin; /* min rtt */
123 unsigned char pl; /* measured packet loss */ 128 unsigned char pl; /* measured packet loss */
124 struct rta_host *next; /* linked list */ 129 struct rta_host *next; /* linked list */
125} rta_host; 130} rta_host;
@@ -782,11 +787,15 @@ wait_for_reply(int sock, u_int t)
782 host->time_waited += tdiff; 787 host->time_waited += tdiff;
783 host->icmp_recv++; 788 host->icmp_recv++;
784 icmp_recv++; 789 icmp_recv++;
790 if (tdiff > host->rtmax)
791 host->rtmax = tdiff;
792 if (tdiff < host->rtmin)
793 host->rtmin = tdiff;
785 794
786 if(debug) { 795 if(debug) {
787 printf("%0.3f ms rtt from %s, outgoing ttl: %u, incoming ttl: %u\n", 796 printf("%0.3f ms rtt from %s, outgoing ttl: %u, incoming ttl: %u, max: %0.3f, min: %0.3f\n",
788 (float)tdiff / 1000, inet_ntoa(resp_addr.sin_addr), 797 (float)tdiff / 1000, inet_ntoa(resp_addr.sin_addr),
789 ttl, ip->ip_ttl); 798 ttl, ip->ip_ttl, (float)host->rtmax / 1000, (float)host->rtmin / 1000);
790 } 799 }
791 800
792 /* if we're in hostcheck mode, exit with limited printouts */ 801 /* if we're in hostcheck mode, exit with limited printouts */
@@ -993,11 +1002,12 @@ finish(int sig)
993 host = list; 1002 host = list;
994 while(host) { 1003 while(host) {
995 if(debug) puts(""); 1004 if(debug) puts("");
996 printf("%srta=%0.3fms;%0.3f;%0.3f;0; %spl=%u%%;%u;%u;; ", 1005 printf("%srta=%0.3fms;%0.3f;%0.3f;0; %spl=%u%%;%u;%u;; %srtmax=%0.3fms;;;; %srtmin=%0.3fms;;;; ",
997 (targets > 1) ? host->name : "", 1006 (targets > 1) ? host->name : "",
998 host->rta / 1000, (float)warn.rta / 1000, (float)crit.rta / 1000, 1007 host->rta / 1000, (float)warn.rta / 1000, (float)crit.rta / 1000,
999 (targets > 1) ? host->name : "", 1008 (targets > 1) ? host->name : "", host->pl, warn.pl, crit.pl,
1000 host->pl, warn.pl, crit.pl); 1009 (targets > 1) ? host->name : "", (float)host->rtmax / 1000,
1010 (targets > 1) ? host->name : "", (host->rtmin < DBL_MAX) ? (float)host->rtmin / 1000 : (float)0);
1001 1011
1002 host = host->next; 1012 host = host->next;
1003 } 1013 }
@@ -1074,6 +1084,8 @@ add_target_ip(char *arg, struct in_addr *in)
1074 host->saddr_in.sin_family = AF_INET; 1084 host->saddr_in.sin_family = AF_INET;
1075 host->saddr_in.sin_addr.s_addr = in->s_addr; 1085 host->saddr_in.sin_addr.s_addr = in->s_addr;
1076 1086
1087 host->rtmin = DBL_MAX;
1088
1077 if(!list) list = cursor = host; 1089 if(!list) list = cursor = host;
1078 else cursor->next = host; 1090 else cursor->next = host;
1079 1091