Add SIGQUIT summary support similar to ping

This reverts commit 3b3877f651af816006ab620f7a189c2c1a3fad8a.
pull/185/head
Patrick Ladd 5 years ago committed by Patrick Ladd
parent ee648fccde
commit e064c36df8

@ -1,6 +1,6 @@
#!/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)
@ -24,6 +24,21 @@ $cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 84 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0
});
}
# 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') {

@ -19,7 +19,8 @@ of targets to check; if a target does not respond within a certain time limit
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

@ -252,6 +252,8 @@ int socket6 = -1;
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 */
@ -329,6 +331,7 @@ void print_per_system_splits(void);
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);
@ -1027,6 +1030,7 @@ int main(int argc, char** argv)
#endif
signal(SIGINT, finish);
signal(SIGQUIT, sigstatus);
gettimeofday(&start_time, NULL);
current_time = start_time;
@ -1302,6 +1306,11 @@ void main_loop()
gettimeofday(&current_time, NULL);
if (status_snapshot) {
status_snapshot = 0;
print_per_system_splits();
}
/* Print report */
if (report_interval && (loop_flag || count_flag) && (timeval_diff(&current_time, &next_report_time) >= 0)) {
if (netdata_flag)
@ -1315,6 +1324,26 @@ void main_loop()
}
}
/************************************************************
Function: sigstatus
*************************************************************
Inputs: void (none)
Description:
SIGQUIT signal handler - set flag and return
************************************************************/
void sigstatus()
{
status_snapshot = 1;
}
/************************************************************
Function: finish

Loading…
Cancel
Save