187fe22effeaea372292e0e16d2779b241badbdf
[collectd.git] / src / filter_chain.h
1 /**
2  * collectd - src/filter_chain.h
3  * Copyright (C) 2008,2009  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; only version 2 of the License is applicable.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
17  *
18  * Authors:
19  *   Florian octo Forster <octo at verplant.org>
20  **/
21
22 #ifndef FILTER_CHAIN_H
23 #define FILTER_CHAIN_H 1
24
25 #include "collectd.h"
26 #include "plugin.h"
27
28 #define FC_MATCH_NO_MATCH  0
29 #define FC_MATCH_MATCHES   1
30
31 #define FC_TARGET_CONTINUE 0
32 #define FC_TARGET_STOP     1
33 #define FC_TARGET_RETURN   2
34
35 /*
36  * Match functions
37  */
38 struct match_proc_s
39 {
40   int (*create) (const oconfig_item_t *ci, void **user_data);
41   int (*destroy) (void **user_data);
42   int (*match) (const data_set_t *ds, const value_list_t *vl,
43       notification_meta_t **meta, void **user_data);
44 };
45 typedef struct match_proc_s match_proc_t;
46
47 int fc_register_match (const char *name, match_proc_t proc);
48
49 /*
50  * Target functions
51  */
52 struct target_proc_s
53 {
54   int (*create) (const oconfig_item_t *ci, void **user_data);
55   int (*destroy) (void **user_data);
56   int (*invoke) (const data_set_t *ds, value_list_t *vl,
57       notification_meta_t **meta, void **user_data);
58 };
59 typedef struct target_proc_s target_proc_t;
60
61 struct fc_chain_s;
62 typedef struct fc_chain_s fc_chain_t;
63
64 int fc_register_target (const char *name, target_proc_t proc);
65
66 /*
67  * TODO: Chain management
68  */
69 #if 0
70 int fc_chain_add (const char *chain_name,
71     const char *target_name, int target_argc, char **target_argv);
72 int fc_chain_delete (const char *chain_name);
73 #endif
74
75 /*
76  * TODO: Rule management
77  */
78 #if 0
79 int fc_rule_add (const char *chain_name, int position,
80     int match_num, const char **match_name, int *match_argc, char ***match_argv,
81     const char *target_name, int target_argc, char **target_argv);
82 int fc_rule_delete (const char *chain_name, int position);
83 #endif
84
85 /*
86  * Processing function
87  */
88 fc_chain_t *fc_chain_get_by_name (const char *chain_name);
89
90 int fc_process_chain (const data_set_t *ds, value_list_t *vl,
91     fc_chain_t *chain);
92
93 int fc_default_action (const data_set_t *ds, value_list_t *vl);
94
95 /* 
96  * Shortcut for global configuration
97  */
98 int fc_configure (const oconfig_item_t *ci);
99
100 #endif /* FILTER_CHAIN_H */
101 /* vim: set sw=2 sts=2 et : */