e1303c76f2a5a86ccec668902a57db03e65fb597
1 /**
2 * collectd - src/plugin.h
3 * Copyright (C) 2005,2006 Florian octo Forster
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Authors:
20 * Florian octo Forster <octo at verplant.org>
21 **/
23 #ifndef PLUGIN_H
24 #define PLUGIN_H
26 /*
27 * NAME
28 * plugin_set_dir
29 *
30 * DESCRIPTION
31 * Sets the current `plugindir'
32 *
33 * ARGUMENTS
34 * `dir' Path to the plugin directory
35 *
36 * NOTES
37 * If `dir' is NULL the compiled in default `PLUGINDIR' is used.
38 */
39 void plugin_set_dir (const char *dir);
41 /*
42 * NAME
43 * plugin_count
44 *
45 * DESCRIPTION
46 * trivial
47 *
48 * RETURN VALUE
49 * The number of currently loaded plugins
50 */
51 int plugin_count (void);
53 /*
54 * NAME
55 * plugin_exists
56 *
57 * DESCRIPTION
58 * trivial
59 *
60 * ARGUMENTS
61 * `type' Name of the plugin.
62 *
63 * RETURN VALUE
64 * Returns non-zero if a plugin with the name $type is found and zero
65 * otherwise.
66 */
67 int plugin_exists (char *type);
69 /*
70 * NAME
71 * plugin_load
72 *
73 * DESCRIPTION
74 * Searches the current `plugindir' (see `plugin_set_dir') for the plugin
75 * named $type and loads it. Afterwards the plugin's `module_register'
76 * function is called, which then calls `plugin_register' to register callback
77 * functions.
78 *
79 * ARGUMENTS
80 * `type' Name of the plugin to load.
81 *
82 * RETURN VALUE
83 * Returns zero upon success, a value greater than zero if no plugin was found
84 * and a value below zero if an error occurs.
85 *
86 * NOTES
87 * No attempt is made to re-load an already loaded module.
88 */
89 int plugin_load (const char *type);
91 int plugin_load_all (char *dir);
92 void plugin_init_all (void);
93 void plugin_read_all (void);
95 void plugin_register (char *type,
96 void (*init) (void),
97 void (*read) (void),
98 void (*write) (char *, char *, char *));
100 /*
101 * NAME
102 * plugin_write
103 *
104 * DESCRIPTION
105 * Searches the plugin for `type' in the plugin-list. If found, and a `write'
106 * function is registered, it's called. If either the plugin is not found or
107 * the plugin doesn't provide a `write' function this function will return
108 * without further notice.
109 *
110 * ARGUMENTS
111 * `host' Host(name) from which the data originates.
112 * `type' Name of the plugin.
113 * `inst' Instance (passed to the plugin's `write' function.
114 * `val' Values for the RRD files. Also passed to the plugin.
115 */
116 void plugin_write (char *host, char *type, char *inst, char *val);
118 void plugin_submit (char *type, char *inst, char *val);
120 #endif /* PLUGIN_H */