/**
* collectd - src/configfile.c
- * Copyright (C) 2005,2006 Florian octo Forster
+ * Copyright (C) 2005-2008 Florian octo Forster
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
#include "common.h"
#include "plugin.h"
#include "configfile.h"
+#include "types_list.h"
+#include "utils_threshold.h"
#define ESCAPE_NULL(str) ((str) == NULL ? "(null)" : (str))
/*
* Prototypes of callback functions
*/
+static int dispatch_value_typesdb (const oconfig_item_t *ci);
static int dispatch_value_plugindir (const oconfig_item_t *ci);
static int dispatch_value_loadplugin (const oconfig_item_t *ci);
static cf_value_map_t cf_value_map[] =
{
+ {"TypesDB", dispatch_value_typesdb},
{"PluginDir", dispatch_value_plugindir},
{"LoadPlugin", dispatch_value_loadplugin}
};
{"Hostname", NULL, NULL},
{"FQDNLookup", NULL, "false"},
{"Interval", NULL, "10"},
- {"ReadThreads", NULL, "5"},
- {"TypesDB", NULL, PLUGINDIR"/types.db"} /* FIXME: Configure path */
+ {"ReadThreads", NULL, "5"}
};
static int cf_global_options_num = STATIC_ARRAY_LEN (cf_global_options);
+static int cf_default_typesdb = 1;
+
/*
* Functions to handle register/unregister, search, and other plugin related
* stuff
if ((cf_cb = cf_search (type)) == NULL)
{
- WARNING ("Plugin `%s' did not register a callback.", type);
+ WARNING ("Found a configuration for the `%s' plugin, but "
+ "the plugin isn't loaded or didn't register "
+ "a configuration callback.", type);
return (-1);
}
return (-1);
} /* int dispatch_global_option */
+static int dispatch_value_typesdb (const oconfig_item_t *ci)
+{
+ int i = 0;
+
+ assert (strcasecmp (ci->key, "TypesDB") == 0);
+
+ cf_default_typesdb = 0;
+
+ if (ci->values_num < 1)
+ return (-1);
+
+ for (i = 0; i < ci->values_num; ++i)
+ {
+ if (OCONFIG_TYPE_STRING != ci->values[i].type)
+ continue;
+
+ read_types_list (ci->values[i].value.string);
+ }
+ return (0);
+} /* int dispatch_value_typesdb */
+
static int dispatch_value_plugindir (const oconfig_item_t *ci)
{
assert (strcasecmp (ci->key, "PluginDir") == 0);
{
if (strcasecmp (ci->key, "Plugin") == 0)
return (dispatch_block_plugin (ci));
+ else if (strcasecmp (ci->key, "Threshold") == 0)
+ return (ut_config (ci));
return (0);
}
dispatch_block (conf->children + i);
}
+ if (cf_default_typesdb)
+ read_types_list (PLUGINDIR"/types.db"); /* FIXME: Configure path */
return (0);
} /* int cf_read */