summaryrefslogtreecommitdiffabout
path: root/src/report.c
authorSergey Poznyakoff <gray@Pirx.gnu.org.ua>2009-04-28 13:27:03 (GMT)
committer Sergey Poznyakoff <gray@Pirx.gnu.org.ua>2009-04-28 13:27:03 (GMT)
commit20d7f1d7e051c6b021a3f5d088985a74c3370b29 (patch) (side-by-side diff)
tree5c5dc1c1b401e055096b8ec216a6bd97eb76a520 /src/report.c
parent29e4b3da0990aca9db232dc3ce0a57722ccf1cac (diff)
downloadtagr-20d7f1d7e051c6b021a3f5d088985a74c3370b29.tar.gz
tagr-20d7f1d7e051c6b021a3f5d088985a74c3370b29.tar.bz2
Store timestamps. Implement zero-unknown option.
* src/graph.c (draw_graph): Use timestamps from queue entries. Implement zero_unknown_option. * src/output.c: Store timestamps in traffic_history entries. * src/readconfig.c (cb_monitor, cb_server): Fix checks for empty ID. (tagr_kw): New keyword cut-out-fraction. (readconfig): Reset cut_out_fraction if it is < 1.0. * src/report.c: Print timestamps. * src/stat.c (cut_out_fraction): New variable. (ovf_t, overflow): Remove (spurious now) arguments. (interpolate, overflow, update_stats): Don't interpolate if time interval between this sample and the lastly taken one is greater than step * cut_out_fraction. * src/tagr.h (TAGR_CUT_OUT): New define.
Diffstat (limited to 'src/report.c') (more/less context) (ignore whitespace changes)
-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.