aboutsummaryrefslogtreecommitdiff
path: root/src/report.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@Pirx.gnu.org.ua>2009-04-28 16:27:03 +0300
committerSergey Poznyakoff <gray@Pirx.gnu.org.ua>2009-04-28 16:27:03 +0300
commit20d7f1d7e051c6b021a3f5d088985a74c3370b29 (patch)
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')
-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
@@ -32,2 +32,3 @@
#include <report.h>
+#include <fprintftime.h>
#include <gdbm.h>
@@ -146,2 +147,10 @@ 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)
@@ -157,3 +166,5 @@ print_queue (const char *title, queue_t *q)
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);
}
@@ -174,11 +185,9 @@ 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);

Return to:

Send suggestions and report system problems to the System administrator.