summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a43a887)
raw | patch | inline | side by side (parent: a43a887)
author | octo <octo> | |
Wed, 14 Dec 2005 14:14:20 +0000 (14:14 +0000) | ||
committer | octo <octo> | |
Wed, 14 Dec 2005 14:14:20 +0000 (14:14 +0000) |
Added syslog-output to configfile.c
Changed `plugin_load' to take a `const' parameter
Changed `plugin_load' to take a `const' parameter
src/collectd.c | patch | blob | history | |
src/configfile.c | patch | blob | history | |
src/plugin.c | patch | blob | history | |
src/plugin.h | patch | blob | history |
diff --git a/src/collectd.c b/src/collectd.c
index 633d0230cdec080c7f5a924eba6e4e6fb44e112e..348623c091499f9fb46d8c42ced47d2bae3b7cf1 100644 (file)
--- a/src/collectd.c
+++ b/src/collectd.c
#include "multicast.h"
#include "plugin.h"
+#include "configfile.h"
#include "ping.h"
char *plugindir = NULL;
char *basedir = DATADIR;
+ char *configfile = NULL;
int daemonize = 1;
}
/*
- * Load plugins and change to output directory
- * Loading plugins is done first so relative paths work as expected..
+ * Read the config file. This will load any modules automagically.
*/
- if (plugin_load_all (plugindir) < 1)
+ plugin_set_dir (plugindir);
+
+ if (cf_read (configfile))
{
- fprintf (stderr, "Error: No plugins found.\n");
+ fprintf (stderr, "Error: Reading the config file failed!\n"
+ "Read the syslog for details.\n");
return (1);
}
+ /*
+ * Change directory. We do this _after_ reading the config and loading
+ * modules to relative paths work as expected.
+ */
if (change_basedir (basedir))
{
fprintf (stderr, "Error: Unable to change to directory `%s'.\n", basedir);
diff --git a/src/configfile.c b/src/configfile.c
index f93eda02fee007c6a47a559295488ccb030fed40..0d1569f9d0c83af6c0313e9c657c5b1cf7207fe7 100644 (file)
--- a/src/configfile.c
+++ b/src/configfile.c
#include "libconfig/libconfig.h"
+#include "plugin.h"
#include "configfile.h"
#include "utils_debug.h"
#define ERR_NEEDS_ARG "Section `%s' needs an argument.\n"
#define ERR_NEEDS_SECTION "`%s' can only be used within a section.\n"
+#ifdef HAVE_LIBRRD
+extern int operating_mode;
+#else
+static int operating_mode = MODE_LOCAL;
+#endif
+
typedef struct cf_callback
{
char *type;
return (LC_CBRET_ERROR);
}
- /*
- * TODO:
- * - Write wrapper around `plugin_load' to resolve path/filename
- * - Call this new, public function here
- */
- DBG ("Implement me, idiot!");
+ if (plugin_load (shortvar))
+ syslog (LOG_ERR, "plugin_load (%s): failed to load plugin", shortvar);
+ /* Return `okay' even if there was an error, because it's not a syntax
+ * problem.. */
return (LC_CBRET_OKAY);
}
if (lc_process_file ("collectd", filename, LC_CONF_APACHE))
{
- /* FIXME: Use syslog here */
- fprintf (stderr, "Error loading config file `%s': %s\n",
- filename, lc_geterrstr ());
+ syslog (LOG_ERR, "lc_process_file (%s): %s", filename, lc_geterrstr ());
return (-1);
}
diff --git a/src/plugin.c b/src/plugin.c
index d2e5f47cfea5365ae3ca418b7f160bb26bc7e3b1..87668d7b3d321218bc49114640dbe4cd4977b518 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
/*
* Returns the plugins with the type `type' or NULL if it's not found.
*/
-plugin_t *plugin_search (char *type)
+plugin_t *plugin_search (const char *type)
{
plugin_t *ret;
}
#define BUFSIZE 512
-int plugin_load (char *type)
+int plugin_load (const char *type)
{
DIR *dh;
char *dir;
while ((de = readdir (dh)) != NULL)
{
- if (strncmp (de->d_name, typename, typename_len))
+ if (strncasecmp (de->d_name, typename, typename_len))
continue;
if (snprintf (filename, BUFSIZE, "%s/%s", dir, de->d_name) >= BUFSIZE)
diff --git a/src/plugin.h b/src/plugin.h
index 6e363673474b6c20049cdb3f8bc6e70420a92d36..8749327ab8cc900b9c6030c4a64c5d213e922d7f 100644 (file)
--- a/src/plugin.h
+++ b/src/plugin.h
* NOTES
* No attempt is made to re-load an already loaded module.
*/
-int plugin_load (char *type);
+int plugin_load (const char *type);
int plugin_load_all (char *dir);
void plugin_init_all (void);