From: Florian Forster Date: Wed, 25 Jun 2008 12:00:44 +0000 (+0200) Subject: src/rrd_{fetch,graph,update}.c: Use the `RRDCACHED_ADDRESS' environment variable.. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=dbc110514529603f430259064a0bdc067a11b9f5;p=rrdtool.git src/rrd_{fetch,graph,update}.c: Use the `RRDCACHED_ADDRESS' environment variable.. ..as default daemon address. --- diff --git a/src/rrd_client.h b/src/rrd_client.h index 003c4e4..895ff92 100644 --- a/src/rrd_client.h +++ b/src/rrd_client.h @@ -24,6 +24,7 @@ #define RRDCACHED_DEFAULT_ADDRESS "unix:/tmp/rrdd.sock" #define RRDCACHED_DEFAULT_PORT "42217" +#define ENV_RRDCACHED_ADDRESS "RRDCACHED_ADDRESS" int rrdc_connect (const char *addr); int rrdc_disconnect (void); diff --git a/src/rrd_fetch.c b/src/rrd_fetch.c index c745f06..26c3324 100644 --- a/src/rrd_fetch.c +++ b/src/rrd_fetch.c @@ -166,6 +166,22 @@ int rrd_fetch( return -1; } + if (daemon == NULL) + { + char *temp; + + temp = getenv (ENV_RRDCACHED_ADDRESS); + if (temp != NULL) + { + daemon = strdup (temp); + if (daemon == NULL) + { + rrd_set_error("strdup failed."); + return (-1); + } + } + } + cf = argv[optind + 1]; if (rrd_fetch_r(argv[optind], cf, start, end, step, daemon, ds_cnt, diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 1e597d1..7dfb9ce 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -4222,6 +4222,26 @@ void rrd_graph_options( rrd_set_error("unknown option '%s'", argv[optind - 1]); return; } + } /* while (1) */ + + if (im->use_rrdcached == 0) + { + char *temp; + + temp = getenv (ENV_RRDCACHED_ADDRESS); + if (temp != NULL) + { + int status; + + status = rrdc_connect (temp); + if (status != 0) + { + rrd_set_error ("rrdc_connect(%s) failed with status %i.", + temp, status); + return; + } + im->use_rrdcached = 1; + } } if (im->logarithmic && im->minval <= 0) { diff --git a/src/rrd_update.c b/src/rrd_update.c index 2602a82..da68270 100644 --- a/src/rrd_update.c +++ b/src/rrd_update.c @@ -430,6 +430,22 @@ int rrd_update( goto out; } + if ((tmplt == NULL) && (daemon == NULL)) + { + char *temp; + + temp = getenv (ENV_RRDCACHED_ADDRESS); + if (temp != NULL) + { + daemon = strdup (temp); + if (daemon == NULL) + { + rrd_set_error("strdup failed."); + goto out; + } + } + } + if (daemon != NULL) { int status;