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