aboutsummaryrefslogtreecommitdiff
path: root/src/graph.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-04-29 18:11:56 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2009-04-29 18:11:56 +0300
commit5a1f674eecba607ffa328484ca34c598690ff8d2 (patch)
tree5dcda78e8352461d2ee7fdc29c64a265024cb219 /src/graph.c
parent20d7f1d7e051c6b021a3f5d088985a74c3370b29 (diff)
downloadtagr-5a1f674eecba607ffa328484ca34c598690ff8d2.tar.gz
tagr-5a1f674eecba607ffa328484ca34c598690ff8d2.tar.bz2
Fix locking issues. Improve stream interface.
* gnulib.modules: Add c-type, c-strcase, crypto/md5, xgetdomainname, xgethostname. * src/Makefile.am (tagr_SOURCES): Add apop.c, udb.c, xhostname.c * src/graph.c (draw_graph): Rename `now' to `start'. * src/main.c (hostname, rebuild_last_option): New globals. (main): Init hostname. * src/output.c (update_output): Change semantics of the last parameter. * src/readconfig.c (cb_facility): Use c_strcasecmp. (tagr_kw): New keywords: hostname, udb-file, lock-count, lock-timeout, idle-timeout. * src/report.c: Fix locking issues. (update_monitor): Change semantics of the last parameter. (rebuild): Likewise. * src/server.c: Rewrite stream interface. * src/tagr.h (TAGR_ARG_UNUSED, TAGR_PRINTFLIKE): New macros. (lock_retry_count_option, lock_retry_timeout_option) (stream_idle_timeout, hostname): New declarations. (TAGR_UPD_FORCE, TAGR_UPD_LASTTIME): New defines. (trim_crlf, tagr_local_hostnamem tagr_auth_init, tagr_auth) (tagr_udb_name) (udb_get_passwordudb_free_password): New declarations. * TODO: Update
Diffstat (limited to 'src/graph.c')
-rw-r--r--src/graph.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/graph.c b/src/graph.c
index 1197a7d..02e0586 100644
--- a/src/graph.c
+++ b/src/graph.c
@@ -73,7 +73,7 @@ draw_vtext (gdImagePtr graph, int color, const char *text)
int
draw_graph (FILE *fp,
struct monitor *mon,
- queue_t *dataq, const struct avg_acc *avg, time_t now,
+ queue_t *dataq, const struct avg_acc *avg, time_t start,
int xstep, unsigned long xmax,
int growright,
struct grid_class *xgrid, struct grid_class *ygrid)
@@ -90,7 +90,6 @@ draw_graph (FILE *fp,
int full_ysize = graph_ysize + graph_v_margin[0] + graph_v_margin[1];
grid_t grid;
unsigned long ymax = mon->max_rate;
- time_t start;
yscale = (double) graph_ysize / ymax;
xscale = (double) graph_xsize / xmax;
@@ -143,13 +142,13 @@ draw_graph (FILE *fp,
n = queue_count (dataq);
/* Incoming traffic */
- for (i = n - 1, start = 0; i > 0; i--)
+ for (i = n - 1; i > 0; i--)
{
struct traffic_history th, tnext;
scale_sample (mon, queue_get_ptr (dataq, i), &th);
- if (start == 0)
- start = th.time;
+ if (th.time > start)
+ continue;
scale_sample (mon, queue_get_ptr (dataq, i - 1), &tnext);
if (start - tnext.time > xmax)
break;
@@ -172,13 +171,13 @@ draw_graph (FILE *fp,
/* Outgoing traffic */
gdImageSetBrush (graph, brush_out);
- for (i = n - 1, start = 0; i > 0; i--)
+ for (i = n - 1; i > 0; i--)
{
struct traffic_history th, tnext;
scale_sample (mon, queue_get_ptr (dataq, i), &th);
- if (start == 0)
- start = th.time;
+ if (th.time > start)
+ continue;
scale_sample (mon, queue_get_ptr (dataq, i - 1), &tnext);
if (start - tnext.time > xmax)
break;
@@ -245,7 +244,7 @@ draw_graph (FILE *fp,
grid_destroy (grid);
}
- grid = grid_create (xgrid, dataq, 0, xmax, &now);
+ grid = grid_create (xgrid, dataq, 0, xmax, &start);
if (grid)
{
unsigned long i;

Return to:

Send suggestions and report system problems to the System administrator.