#include "client.h"
#include "logging.h"
#include "main.h"
+#include "util.h"
// Struct to collect client statistics
struct fireperf_client_stats {
+ struct timespec last_printed;
+
// Total number of open connections
unsigned int connections;
};
}
static int dump_stats(struct fireperf_config* conf, struct fireperf_client_stats* stats) {
- INFO(conf, "Dumping stats...\n");
+ struct timespec now;
+
+ // Fetch the time
+ int r = clock_gettime(CLOCK_REALTIME, &now);
+ if (r) {
+ ERROR(conf, "Could not fetch the time: %s\n", strerror(errno));
+ return 1;
+ }
+
+ double delta = timespec_delta(&now, &stats->last_printed);
+
+ // Called too soon again?
+ if (delta < 0.1)
+ return 0;
+
+ // Format timestamp
+ const char* timestamp = format_timespec(&now);
+
+ INFO( conf, "--- %s --------------------\n", timestamp);
+
+ // Remember when this was printed last
+ stats->last_printed = now;
return 0;
}