projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updated all copyright-entries in header files.
[collectd.git]
/
src
/
plugin.c
diff --git
a/src/plugin.c
b/src/plugin.c
index
87668d7
..
570b6a2
100644
(file)
--- a/
src/plugin.c
+++ b/
src/plugin.c
@@
-1,6
+1,6
@@
/**
* collectd - src/plugin.c
/**
* collectd - src/plugin.c
- * Copyright (C) 2005 Florian octo Forster
+ * Copyright (C) 2005
,2006
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
*
* 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
@@
-25,7
+25,8
@@
#include <ltdl.h>
#include "plugin.h"
#include <ltdl.h>
#include "plugin.h"
-#include "multicast.h"
+#include "network.h"
+#include "utils_debug.h"
typedef struct plugin
{
typedef struct plugin
{
@@
-38,9
+39,7
@@
typedef struct plugin
static plugin_t *first_plugin = NULL;
static plugin_t *first_plugin = NULL;
-#ifdef HAVE_LIBRRD
extern int operating_mode;
extern int operating_mode;
-#endif
static char *plugindir = NULL;
static char *plugindir = NULL;
@@
-52,7
+51,7
@@
char *plugin_get_dir (void)
return (plugindir);
}
return (plugindir);
}
-void plugin_set_dir (char *dir)
+void plugin_set_dir (c
onst c
har *dir)
{
if (plugindir != NULL)
free (plugindir);
{
if (plugindir != NULL)
free (plugindir);
@@
-116,11
+115,19
@@
int plugin_load_file (char *file)
lt_dlhandle dlh;
void (*reg_handle) (void);
lt_dlhandle dlh;
void (*reg_handle) (void);
+ DBG ("file = %s", file);
+
lt_dlinit ();
lt_dlerror (); /* clear errors */
if ((dlh = lt_dlopen (file)) == NULL)
lt_dlinit ();
lt_dlerror (); /* clear errors */
if ((dlh = lt_dlopen (file)) == NULL)
+ {
+ const char *error = lt_dlerror ();
+
+ syslog (LOG_ERR, "lt_dlopen failed: %s", error);
+ DBG ("lt_dlopen failed: %s", error);
return (1);
return (1);
+ }
if ((reg_handle = lt_dlsym (dlh, "module_register")) == NULL)
{
if ((reg_handle = lt_dlsym (dlh, "module_register")) == NULL)
{
@@
-147,6
+154,8
@@
int plugin_load (const char *type)
struct stat statbuf;
struct dirent *de;
struct stat statbuf;
struct dirent *de;
+ DBG ("type = %s", type);
+
dir = plugin_get_dir ();
ret = 1;
dir = plugin_get_dir ();
ret = 1;
@@
-289,6
+298,12
@@
void plugin_register (char *type,
if (plugin_search (type) != NULL)
return;
if (plugin_search (type) != NULL)
return;
+#ifdef HAVE_LIBRRD
+ if (operating_mode != MODE_SERVER)
+#endif
+ if ((init != NULL) && (read == NULL))
+ syslog (LOG_NOTICE, "Plugin `%s' doesn't provide a read function.", type);
+
if ((p = (plugin_t *) malloc (sizeof (plugin_t))) == NULL)
return;
if ((p = (plugin_t *) malloc (sizeof (plugin_t))) == NULL)
return;
@@
-310,7
+325,6
@@
void plugin_register (char *type,
* Send received data back to the plugin/module which will append DS
* definitions and pass it on to ``rrd_update_file''.
*/
* Send received data back to the plugin/module which will append DS
* definitions and pass it on to ``rrd_update_file''.
*/
-#ifdef HAVE_LIBRRD
void plugin_write (char *host, char *type, char *inst, char *val)
{
plugin_t *p;
void plugin_write (char *host, char *type, char *inst, char *val)
{
plugin_t *p;
@@
-323,23
+337,16
@@
void plugin_write (char *host, char *type, char *inst, char *val)
(*p->write) (host, inst, val);
}
(*p->write) (host, inst, val);
}
-#endif /* HAVE_LIBRRD */
/*
* Receive data from the plugin/module and get it somehow to ``plugin_write'':
/*
* Receive data from the plugin/module and get it somehow to ``plugin_write'':
- * Either using ``
multicast
_send'' (when in network/client mode) or call it
+ * Either using ``
network
_send'' (when in network/client mode) or call it
* directly (in local mode).
*/
void plugin_submit (char *type, char *inst, char *val)
{
* directly (in local mode).
*/
void plugin_submit (char *type, char *inst, char *val)
{
-#ifdef HAVE_LIBRRD
- if (operating_mode == MODE_LOCAL)
+ if (operating_mode == MODE_CLIENT)
+ network_send (type, inst, val);
+ else
plugin_write (NULL, type, inst, val);
plugin_write (NULL, type, inst, val);
- else if (operating_mode == MODE_CLIENT)
- multicast_send (type, inst, val);
- else /* operating_mode == MODE_SERVER */
- syslog (LOG_ERR, "WTF is the server doing in ``plugin_submit''?!?\n");
-#else
- multicast_send (type, inst, val);
-#endif
}
}