#!/usr/bin/perl -w
-use Test::Command tests => 7;
+use Test::Command tests => 9;
use Test::More;
# -i n interval between sending ping packets (in millisec) (default 25)
});
}
+# fping -l with SIGQUIT
+{
+my $cmd = Test::Command->new(cmd => '(sleep 2; pkill -QUIT fping; sleep 2; pkill fping)& fping -p 900 -l 127.0.0.1');
+$cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 84 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
+127\.0\.0\.1 : \[1\], 84 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
+127\.0\.0\.1 : \[2\], 84 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
+127\.0\.0\.1 : \[3\], 84 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
+127\.0\.0\.1 : \[4\], 84 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
+});
+$cmd->stderr_like(qr{\[\d+:\d+:\d+\]
+127\.0\.0\.1 : xmt/rcv/%loss = \d+/\d+/\d+%, min/avg/max = \d+\.\d+/\d+\.\d+/\d+\.\d+
+});
+}
+
+
# fping -M
SKIP: {
if($^O eq 'darwin') {
and/or retry limit it is designated as unreachable. B<fping> also supports
sending a specified number of pings to a target, or looping indefinitely (as in
B<ping> ). Unlike B<ping>, B<fping> is meant to be used in scripts, so its
-output is designed to be easy to parse.
+output is designed to be easy to parse. Current statistics can be obtained without
+termination of process with signal SIGQUIT (^\ from the keyboard on most systems).
=head1 OPTIONS
int hints_ai_family = AF_UNSPEC;
#endif
+volatile sig_atomic_t status_snapshot = 0;
+
unsigned int debugging = 0;
/* times get *100 because all times are calculated in 10 usec units, not ms */
void print_netdata(void);
void print_global_stats(void);
void main_loop();
+void sigstatus();
void finish();
char* sprint_tm(int t);
void ev_enqueue(HOST_ENTRY* h);
#endif
signal(SIGINT, finish);
+ signal(SIGQUIT, sigstatus);
gettimeofday(&start_time, NULL);
current_time = start_time;
gettimeofday(¤t_time, NULL);
+ if (status_snapshot) {
+ status_snapshot = 0;
+ print_per_system_splits();
+ }
+
/* Print report */
if (report_interval && (loop_flag || count_flag) && (timeval_diff(¤t_time, &next_report_time) >= 0)) {
if (netdata_flag)
}
}
+/************************************************************
+
+ Function: sigstatus
+
+*************************************************************
+
+ Inputs: void (none)
+
+ Description:
+
+ SIGQUIT signal handler - set flag and return
+
+************************************************************/
+
+void sigstatus()
+{
+ status_snapshot = 1;
+}
+
+
/************************************************************
Function: finish