aboutsummaryrefslogtreecommitdiff
path: root/src/report.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/report.c')
-rw-r--r--src/report.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/report.c b/src/report.c
index 398881b..71a735f 100644
--- a/src/report.c
+++ b/src/report.c
@@ -30,6 +30,7 @@
#include <arpa/inet.h>
#include <tagr.h>
#include <report.h>
+#include <fprintftime.h>
#include <gdbm.h>
static char *dbname;
@@ -144,6 +145,14 @@ write_db (struct monitor *mon, struct traffic_record *tr)
}
static void
+print_time (FILE *fp, time_t time)
+{
+ fprintf (fp, "%lu [", (unsigned long) time);
+ fprintftime (fp, "%Y-%m-%d %H:%M:%S %z", localtime (&time), 0, 0);
+ fprintf (fp, "]");
+}
+
+static void
print_queue (const char *title, queue_t *q)
{
int i, count;
@@ -155,7 +164,9 @@ print_queue (const char *title, queue_t *q)
for (i = count - 1; i >= 0; i--)
{
struct traffic_history *th = queue_get_ptr (q, i);
- printf("%d %g %g\n", count - i, th->inrate, th->outrate);
+ printf ("%d ", count - i);
+ print_time (stdout, th->time);
+ printf (" %g %g\n", th->inrate, th->outrate);
}
}
@@ -172,15 +183,13 @@ print_avg (const char *title, struct avg_acc *avg)
static void
print_tr (datum key, struct traffic_record *tr)
{
- char buf[512];
- struct tm *tm;
int i, count;
- tm = localtime (&tr->last.time);
printf ("ID: %*.*s\n", key.dsize, key.dsize, key.dptr);
- strftime (buf, sizeof buf, "%c", tm);
- printf (_("Last sample: %lu (%s) %lu %lu\n"),
- tr->last.time, buf, tr->last.in, tr->last.out);
+
+ printf (_("Last sample: "));
+ print_time (stdout, tr->last.time);
+ printf (" %lu %lu\n", tr->last.in, tr->last.out);
printf (_("Last rates: %g %g\n"),
tr->last_rates.inrate, tr->last_rates.outrate);

Return to:

Send suggestions and report system problems to the System administrator.