summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2006-08-05 23:49:12 +0000
committerStef Walter <stef@memberwebs.com>2006-08-05 23:49:12 +0000
commit00bea63466b04190bd48bf7c984f303a92fbb8f5 (patch)
treecd8483c9a3e4441e03f64da0887483492b821006
parent97466aa63d3bf01880cdb9b7fba3f735930ac13a (diff)
Added support for RRD files not in the standard places. See #54
-rw-r--r--ChangeLog1
-rw-r--r--daemon/config.c20
-rw-r--r--tools/rrdbot-create.c22
3 files changed, 39 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 0a0093d..1b6a8cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
0.4
- Reduced memory usage of SNMP requests
- Added asynchronous DNS resolver
+ - Added support for RRD files not in the normal places
0.3
- Initial public release
diff --git a/daemon/config.c b/daemon/config.c
index 3e7c534..a47b5f2 100644
--- a/daemon/config.c
+++ b/daemon/config.c
@@ -58,6 +58,7 @@
typedef struct _config_ctx
{
const char* confname;
+ const char* rrdname;
uint interval;
uint timeout;
rb_item* items;
@@ -68,6 +69,8 @@ config_ctx;
* STRINGS
*/
+#define CONFIG_GENERAL "general"
+#define CONFIG_RRD "rrd"
#define CONFIG_POLL "poll"
#define CONFIG_INTERVAL "interval"
#define CONFIG_TIMEOUT "timeout"
@@ -141,8 +144,12 @@ config_done(config_ctx* ctx)
ctx->timeout = g_state.timeout;
/* And a nice key for lookups */
- snprintf(key, sizeof(key), "%d-%d:%s/%s.rrd", ctx->timeout,
- ctx->interval, g_state.rrddir, ctx->confname);
+ if(ctx->rrdname)
+ snprintf(key, sizeof(key), "%d-%d:%s", ctx->timeout, ctx->interval,
+ ctx->rrdname);
+ else
+ snprintf(key, sizeof(key), "%d-%d:%s/%s.rrd", ctx->timeout,
+ ctx->interval, g_state.rrddir, ctx->confname);
key[sizeof(key) - 1] = 0;
/* See if we have one of these pollers already */
@@ -294,6 +301,15 @@ config_value(const char* header, const char* name, char* value,
{
char* suffix;
+ if(strcmp(header, CONFIG_GENERAL) == 0)
+ {
+ if(strcmp(name, CONFIG_RRD) == 0)
+ ctx->rrdname = value;
+
+ /* Ignore other [general] options */
+ return;
+ }
+
if(strcmp(header, CONFIG_POLL) != 0)
return;
diff --git a/tools/rrdbot-create.c b/tools/rrdbot-create.c
index c75b95f..f3699a1 100644
--- a/tools/rrdbot-create.c
+++ b/tools/rrdbot-create.c
@@ -55,6 +55,7 @@
#define DEFAULT_WORK "/var/db/rrdbot"
#define CONFIG_CREATE "create"
+#define CONFIG_GENERAL "general"
#define CONFIG_POLL "poll"
#define CONFIG_INTERVAL "interval"
#define CONFIG_ARCHIVE "archive"
@@ -62,6 +63,7 @@
#define CONFIG_MIN "min"
#define CONFIG_MAX "max"
#define CONFIG_CF "cf"
+#define CONFIG_RRD "rrd"
#define VAL_UNKNOWN "U"
#define VAL_ABSOLUTE "ABSOLUTE"
@@ -125,6 +127,7 @@ typedef struct _create_ctx
{
const char* workdir;
const char* confname;
+ const char* rrdname;
uint interval;
const char *cf;
int create;
@@ -439,8 +442,13 @@ check_create_file(create_ctx* ctx)
if(!ctx->create)
return;
- snprintf(rrd, sizeof(rrd), "%s/%s.rrd", ctx->workdir, ctx->confname);
- rrd[sizeof(rrd) - 1] = 0;
+ if(ctx->rrdname)
+ strlcpy(rrd, ctx->rrdname, sizeof(rrd));
+ else
+ {
+ snprintf(rrd, sizeof(rrd), "%s/%s.rrd", ctx->workdir, ctx->confname);
+ rrd[sizeof(rrd) - 1] = 0;
+ }
/* Make sure it exists */
if(access(rrd, F_OK) == 0)
@@ -603,6 +611,16 @@ cfg_value(const char* filename, const char* header, const char* name,
return 0;
}
+ if(strcmp(header, CONFIG_GENERAL) == 0)
+ {
+ /* rrd option */
+ if(strcmp(name, CONFIG_RRD) == 0)
+ ctx->rrdname = value;
+
+ /* Ignore other options */
+ return 0;
+ }
+
/* The rest is in the [create] section */
if(strcmp(header, CONFIG_CREATE) != 0)
return 0;