void print_netdata(void);
void print_global_stats(void);
void main_loop();
+void sigstatus();
void finish();
- char* sprint_tm(int t);
+ const char* sprint_tm(int64_t t);
void ev_enqueue(HOST_ENTRY* h);
HOST_ENTRY* ev_dequeue();
void ev_remove(HOST_ENTRY* h);
#endif
signal(SIGINT, finish);
+ signal(SIGQUIT, sigstatus);
+ setlinebuf(stdout);
- gettimeofday(&start_time, NULL);
+ clock_gettime(CLOCKID, &start_time);
current_time = start_time;
if (report_interval) {
; /* process other replies in the queue */
}
- gettimeofday(¤t_time, NULL);
+ clock_gettime(CLOCKID, ¤t_time);
+ 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 (report_interval && (loop_flag || count_flag) && (timespec_diff_10us(¤t_time, &next_report_time) >= 0)) {
if (netdata_flag)
print_netdata();
else
{
int i, j, avg, outage_ms;
HOST_ENTRY* h;
- int resp;
+ int64_t resp;
- fflush(stdout);
-
if (verbose_flag || per_recv_flag)
fprintf(stderr, "\n");
}
}
- if (h->num_recv == 1) {
- num_alive++;
- if (verbose_flag || alive_flag) {
- printf("%s", h->host);
-
- if (verbose_flag)
- printf(" is alive");
-
- if (elapsed_flag)
- printf(" (%s ms)", sprint_tm(this_reply));
-
- if (addr_cmp((struct sockaddr*)&response_addr, (struct sockaddr*)&h->saddr)) {
- char buf[INET6_ADDRSTRLEN];
- getnameinfo((struct sockaddr*)&response_addr, sizeof(response_addr), buf, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST);
- fprintf(stderr, " [<- %s]", buf);
- }
-
- printf("\n");
- }
- }
-
if (per_recv_flag) {
if (timestamp_flag) {
- printf("[%lu.%06lu] ",
+ printf("[%lu.%09lu] ",
(unsigned long)recv_time.tv_sec,
- (unsigned long)recv_time.tv_usec);
+ (unsigned long)recv_time.tv_nsec);
}
avg = h->total_time / h->num_recv;
printf("%s%s : [%d], %d bytes, %s ms",