- (bugfix) Lower -i limit to 1 instead of 10

- (bugfix) Improve interval preciseness of -Q reporting
pull/106/head
David Schweikert 8 years ago
parent c79a5212e4
commit 7c7e007502

@ -6,6 +6,8 @@ UNRELEASED
* (bugfix) Exit code should be 2 when the hostname can't be resolved * (bugfix) Exit code should be 2 when the hostname can't be resolved
(fixes #98, reported by @green-fox) (fixes #98, reported by @green-fox)
* (bugfix) Fix issue compliling on RHEL/Centos 7 (#95, @jbackman) * (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> 2015-10-21 David Schweikert <david@schweikert.ch>
* Version 3.13 * Version 3.13

@ -214,7 +214,7 @@ on the fly at one second intervals, and printing statistics at the end:
# fping -s -l -i 1 -p 1 -T 1 -Q 1 127.0.0.1 # 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 =head1 AUTHORS
@ -257,7 +257,7 @@ to stop mere mortals from hosing the network, normal users can't specify the fol
=item * =item *
B<-i> I<n>, where I<n> < 10 msec B<-i> I<n>, where I<n> < 1 msec
=item * =item *

@ -128,7 +128,7 @@ extern int h_errno;
/* maxima and minima */ /* maxima and minima */
#define MAX_COUNT 10000 #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_PERHOST_INTERVAL 20 /* in millisec */
#define MIN_TIMEOUT 50 /* in millisec */ #define MIN_TIMEOUT 50 /* in millisec */
#define MAX_RETRY 20 #define MAX_RETRY 20
@ -290,7 +290,7 @@ struct timeval current_time; /* current time (pseudo) */
struct timeval start_time; struct timeval start_time;
struct timeval end_time; struct timeval end_time;
struct timeval last_send_time; /* time last ping was sent */ 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; struct timezone tz;
/* switches */ /* switches */
@ -846,8 +846,10 @@ int main( int argc, char **argv )
gettimeofday( &start_time, &tz ); gettimeofday( &start_time, &tz );
current_time = start_time; current_time = start_time;
if( report_interval ) if( report_interval ) {
last_report_time = start_time; next_report_time = start_time;
timeval_add(&next_report_time, report_interval);
}
last_send_time.tv_sec = current_time.tv_sec - 10000; last_send_time.tv_sec = current_time.tv_sec - 10000;
@ -988,6 +990,7 @@ void main_loop()
{ {
long lt; long lt;
long wait_time; long wait_time;
long wait_time_next_report;
HOST_ENTRY *h; HOST_ENTRY *h;
while(ev_first) { while(ev_first) {
@ -1092,6 +1095,15 @@ void main_loop()
wait_time = interval; 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 ( &current_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 */ /* Receive replies */
/* (this is what sleeps during each loop iteration) */ /* (this is what sleeps during each loop iteration) */
if(wait_for_reply(wait_time)) { if(wait_for_reply(wait_time)) {
@ -1102,14 +1114,15 @@ void main_loop()
/* Print report */ /* Print report */
if( report_interval && ( loop_flag || count_flag ) && if( report_interval && ( loop_flag || count_flag ) &&
( timeval_diff ( &current_time, &last_report_time ) > report_interval ) ) ( timeval_diff ( &current_time, &next_report_time ) >= 0 ) )
{ {
if(netdata_flag) if(netdata_flag)
print_netdata(); print_netdata();
else else
print_per_system_splits(); print_per_system_splits();
last_report_time = current_time; while(timeval_diff ( &current_time, &next_report_time ) >= 0 )
timeval_add(&next_report_time, report_interval);
} }
} }
} }

Loading…
Cancel
Save