* (bugfix) Exit code should be 2 when the hostname can't be resolved
(fixes #98, reported by @green-fox)
* (bugfix) Fix issue compliling on RHEL/Centos 7 (#95, @jbackman)
+ * (bugfix) Lower -i limit to 1 instead of 10
+ * (bugfix) Improve interval preciseness of -Q reporting
2015-10-21 David Schweikert <david@schweikert.ch>
* Version 3.13
# fping -s -l -i 1 -p 1 -T 1 -Q 1 127.0.0.1
-Note that ping intervals less than 10ms can only be used as root.
+Note that ping intervals less than 1ms can only be used as root.
=head1 AUTHORS
=item *
-B<-i> I<n>, where I<n> < 10 msec
+B<-i> I<n>, where I<n> < 1 msec
=item *
/* maxima and minima */
#define MAX_COUNT 10000
-#define MIN_INTERVAL 10 /* in millisec */
+#define MIN_INTERVAL 1 /* in millisec */
#define MIN_PERHOST_INTERVAL 20 /* in millisec */
#define MIN_TIMEOUT 50 /* in millisec */
#define MAX_RETRY 20
struct timeval start_time;
struct timeval end_time;
struct timeval last_send_time; /* time last ping was sent */
-struct timeval last_report_time; /* time last report was printed */
+struct timeval next_report_time; /* time next -Q report is expected */
struct timezone tz;
/* switches */
gettimeofday( &start_time, &tz );
current_time = start_time;
- if( report_interval )
- last_report_time = start_time;
+ if( report_interval ) {
+ next_report_time = start_time;
+ timeval_add(&next_report_time, report_interval);
+ }
last_send_time.tv_sec = current_time.tv_sec - 10000;
{
long lt;
long wait_time;
+ long wait_time_next_report;
HOST_ENTRY *h;
while(ev_first) {
wait_time = interval;
}
+ /* Make sure we don't wait too long, in case a report is expected */
+ if( report_interval && ( loop_flag || count_flag ) ) {
+ wait_time_next_report = timeval_diff ( ¤t_time, &next_report_time );
+ if(wait_time_next_report < wait_time) {
+ wait_time = wait_time_next_report;
+ if(wait_time < 0) { wait_time = 0; }
+ }
+ }
+
/* Receive replies */
/* (this is what sleeps during each loop iteration) */
if(wait_for_reply(wait_time)) {
/* Print report */
if( report_interval && ( loop_flag || count_flag ) &&
- ( timeval_diff ( ¤t_time, &last_report_time ) > report_interval ) )
+ ( timeval_diff ( ¤t_time, &next_report_time ) >= 0 ) )
{
if(netdata_flag)
print_netdata();
else
print_per_system_splits();
- last_report_time = current_time;
+ while(timeval_diff ( ¤t_time, &next_report_time ) >= 0 )
+ timeval_add(&next_report_time, report_interval);
}
}
}