The "TypesDB" config option now accepts more than one filename. Each file will
be read in the specified order. If no filename has been given, the default
file will _not_ be read (I doubt this is a useful feature but it's imho the
most reasonable behavior).
This may, for example, be used to specify an additional file containing custom
data-set definitions. See the thread "Thought about exec and types.db" on the
mailing-list ([1]).
[1] http://mailman.verplant.org/pipermail/collectd/2008-January/001450.html
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
#include "plugin.h"
#include "configfile.h"
#include "plugin.h"
#include "configfile.h"
plugin_init_all ();
return (0);
plugin_init_all ();
return (0);
Path to the plugins (shared objects) of collectd.
Path to the plugins (shared objects) of collectd.
-=item B<TypesDB> I<File>
+=item B<TypesDB> I<File> [I<File> ...]
-Set the file that contains the data-set descriptions.
+Set one or more files that contain the data-set descriptions.
=item B<Interval> I<Seconds>
=item B<Interval> I<Seconds>
#include "common.h"
#include "plugin.h"
#include "configfile.h"
#include "common.h"
#include "plugin.h"
#include "configfile.h"
#include "utils_threshold.h"
#define ESCAPE_NULL(str) ((str) == NULL ? "(null)" : (str))
#include "utils_threshold.h"
#define ESCAPE_NULL(str) ((str) == NULL ? "(null)" : (str))
/*
* Prototypes of callback functions
*/
/*
* 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 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[] =
{
static cf_value_map_t cf_value_map[] =
{
+ {"TypesDB", dispatch_value_typesdb},
{"PluginDir", dispatch_value_plugindir},
{"LoadPlugin", dispatch_value_loadplugin}
};
{"PluginDir", dispatch_value_plugindir},
{"LoadPlugin", dispatch_value_loadplugin}
};
{"Hostname", NULL, NULL},
{"FQDNLookup", NULL, "false"},
{"Interval", NULL, "10"},
{"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_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
/*
* Functions to handle register/unregister, search, and other plugin related
* stuff
return (-1);
} /* int dispatch_global_option */
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);
static int dispatch_value_plugindir (const oconfig_item_t *ci)
{
assert (strcasecmp (ci->key, "PluginDir") == 0);
dispatch_block (conf->children + i);
}
dispatch_block (conf->children + i);
}
+ if (cf_default_typesdb)
+ read_types_list (PLUGINDIR"/types.db"); /* FIXME: Configure path */
return (0);
} /* int cf_read */
return (0);
} /* int cf_read */
} /* while (fgets) */
} /* void parse_file */
} /* while (fgets) */
} /* void parse_file */
-int read_types_list (void)
+int read_types_list (const char *file)
- file = global_option_get ("TypesDB");
- {
- ERROR ("global_option_get (\"TypesDB\") returned NULL.");
fh = fopen (file, "r");
if (fh == NULL)
fh = fopen (file, "r");
if (fh == NULL)
* Florian octo Forster <octo at verplant.org>
**/
* Florian octo Forster <octo at verplant.org>
**/
-int read_types_list (void);
+int read_types_list (const char *file);
#endif /* TYPES_LIST_H */
#endif /* TYPES_LIST_H */