diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-04-25 10:44:14 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-04-25 10:44:14 +0300 |
commit | d8c782807ffbd0e7e30b07f88dd91b6dc0988219 (patch) | |
tree | 64cdbde6fc4f6ae6f3c2c0564cd1fc57d5de9088 /src/stat.c | |
parent | cedb36dcc43d5cb89a0b4af0e7eeeddb02401595 (diff) | |
download | tagr-d8c782807ffbd0e7e30b07f88dd91b6dc0988219.tar.gz tagr-d8c782807ffbd0e7e30b07f88dd91b6dc0988219.tar.bz2 |
Normalize terminology.
* etc/upgrade.awk: Translate "router" to "monitor".
Divide max rate by 8.
* src/graph.c (rate_unit): New global.
(draw_graph): Take monitor as an argument. Make rate
units configurable.
* src/readconfig.c (find_router, find_router_id): Rename
to find_monitor, find_monitor_id.
Rename "router" section to "monitor".
New statement "rate-units", allowed both at top level and
within a monitor.
* src/tagr.h (HostData): Rename to monitor. Add new field: rate_unit.
Rename `max' to `max_rate'.
Remove t, in, out.
(rate_unit): New declaration.
(find_router, find_router_id): Rename
to find_monitor, find_monitor_id.
(struct last_sample): Rename to struct traffic_sample.
* src/output.c, src/report.c, src/stat.c: Update
Diffstat (limited to 'src/stat.c')
-rw-r--r-- | src/stat.c | 57 |
1 files changed, 29 insertions, 28 deletions
@@ -135,3 +135,4 @@ ovf_daily (struct traffic_history *th, struct traffic_record *tr, time_t now) void -update_stats (SD *sd, struct traffic_record *tr) +update_stats (struct monitor *mon, struct traffic_sample *sample, + struct traffic_record *tr) { @@ -142,3 +143,3 @@ update_stats (SD *sd, struct traffic_record *tr) - interval = sd->t - tr->last.time; + interval = sample->time - tr->last.time; if (interval == 0) @@ -148,4 +149,4 @@ update_stats (SD *sd, struct traffic_record *tr) } - inrate = (double) sd->in / interval; - outrate = (double) sd->out / interval; + inrate = (double) sample->in / interval; + outrate = (double) sample->out / interval; if (lastp) @@ -154,3 +155,3 @@ update_stats (SD *sd, struct traffic_record *tr) DAY_SAMPLE, - sd->t, + sample->time, tr->last.time, @@ -164,3 +165,3 @@ update_stats (SD *sd, struct traffic_record *tr) struct traffic_history th; - interval = sd->t - tr->last.time; + interval = sample->time - tr->last.time; th.inrate = inrate; @@ -169,5 +170,5 @@ update_stats (SD *sd, struct traffic_record *tr) } - tr->last.time = sd->t; - tr->last.in = sd->in; - tr->last.out = sd->out; + tr->last.time = sample->time; + tr->last.in = sample->in; + tr->last.out = sample->out; tr->last_rates.inrate = inrate; @@ -180,3 +181,3 @@ update_stats (SD *sd, struct traffic_record *tr) static void -compute_avg (struct avg_acc *avg, queue_t *q, struct last_sample *last) +compute_avg (struct avg_acc *avg, queue_t *q, struct traffic_sample *last) { @@ -197,7 +198,5 @@ compute_avg (struct avg_acc *avg, queue_t *q, struct last_sample *last) -#define hist_rec last_sample - static void _convert (queue_t *q, ovf_t ovf, - struct traffic_record *tr, struct hist_rec *hist, size_t count, + struct traffic_record *tr, struct traffic_sample *hist, size_t count, time_t sample_interval) @@ -205,3 +204,3 @@ _convert (queue_t *q, ovf_t ovf, size_t i; - struct hist_rec *hp; + struct traffic_sample *hp; @@ -252,3 +251,4 @@ _convert (queue_t *q, ovf_t ovf, static void -convert_yearly (struct traffic_record *tr, struct hist_rec *hp, size_t count) +convert_yearly (struct traffic_record *tr, struct traffic_sample *hp, + size_t count) { @@ -262,3 +262,4 @@ convert_yearly (struct traffic_record *tr, struct hist_rec *hp, size_t count) static void -convert_monthly (struct traffic_record *tr, struct hist_rec *hp, size_t count) +convert_monthly (struct traffic_record *tr, struct traffic_sample *hp, + size_t count) { @@ -274,3 +275,3 @@ convert_monthly (struct traffic_record *tr, struct hist_rec *hp, size_t count) static void -convert_weekly (struct traffic_record *tr, struct hist_rec *hp, size_t count) +convert_weekly (struct traffic_record *tr, struct traffic_sample *hp, size_t count) { @@ -286,3 +287,3 @@ convert_weekly (struct traffic_record *tr, struct hist_rec *hp, size_t count) static void -convert_daily (struct traffic_record *tr, struct hist_rec *hp, size_t count) +convert_daily (struct traffic_record *tr, struct traffic_sample *hp, size_t count) { @@ -296,4 +297,4 @@ convert_daily (struct traffic_record *tr, struct hist_rec *hp, size_t count) static void -convert_stats (SD *sd, struct hist_rec *last, - struct hist_rec *hp, size_t count) +convert_stats (struct monitor *mon, struct traffic_sample *last, + struct traffic_sample *hp, size_t count) { @@ -306,6 +307,6 @@ convert_stats (SD *sd, struct hist_rec *last, - read_db (sd, &trp); + read_db (mon, &trp); *trp = tr; trp->last = *last; - write_db (sd, trp); + write_db (mon, trp); free (trp); @@ -319,3 +320,3 @@ import_log (const char *name) struct obstack stk; - struct hist_rec last, hist, *hp; + struct traffic_sample last, hist, *hp; unsigned long inmax, outmax; @@ -389,3 +390,3 @@ import_log (const char *name) { - SD *sd; + struct monitor *mon; @@ -397,6 +398,6 @@ import_log (const char *name) - sd = find_router (base); - if (!sd) + mon = find_monitor (base); + if (!mon) { - logmsg (L_ERR, "cannot find router `%s'", base); + logmsg (L_ERR, "cannot find monitor `%s'", base); rc = 1; @@ -404,3 +405,3 @@ import_log (const char *name) else - convert_stats (sd, &last, hp, count); + convert_stats (mon, &last, hp, count); } |