Merge branch 'collectd-5.7' into collectd-5.8
[collectd.git] / src / daemon / filter_chain.h
1 /**
2  * collectd - src/filter_chain.h
3  * Copyright (C) 2008,2009  Florian octo Forster
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  *
23  * Authors:
24  *   Florian octo Forster <octo at collectd.org>
25  **/
26
27 #ifndef FILTER_CHAIN_H
28 #define FILTER_CHAIN_H 1
29
30 #include "collectd.h"
31
32 #include "plugin.h"
33
34 #define FC_MATCH_NO_MATCH 0
35 #define FC_MATCH_MATCHES 1
36
37 #define FC_TARGET_CONTINUE 0
38 #define FC_TARGET_STOP 1
39 #define FC_TARGET_RETURN 2
40
41 /*
42  * Match functions
43  */
44 struct match_proc_s {
45   int (*create)(const oconfig_item_t *ci, void **user_data);
46   int (*destroy)(void **user_data);
47   int (*match)(const data_set_t *ds, const value_list_t *vl,
48                notification_meta_t **meta, void **user_data);
49 };
50 typedef struct match_proc_s match_proc_t;
51
52 int fc_register_match(const char *name, match_proc_t proc);
53
54 /*
55  * Target functions
56  */
57 struct target_proc_s {
58   int (*create)(const oconfig_item_t *ci, void **user_data);
59   int (*destroy)(void **user_data);
60   int (*invoke)(const data_set_t *ds, value_list_t *vl,
61                 notification_meta_t **meta, void **user_data);
62 };
63 typedef struct target_proc_s target_proc_t;
64
65 struct fc_chain_s;
66 typedef struct fc_chain_s fc_chain_t;
67
68 int fc_register_target(const char *name, target_proc_t proc);
69
70 /*
71  * TODO: Chain management
72  */
73 #if 0
74 int fc_chain_add (const char *chain_name,
75     const char *target_name, int target_argc, char **target_argv);
76 int fc_chain_delete (const char *chain_name);
77 #endif
78
79 /*
80  * TODO: Rule management
81  */
82 #if 0
83 int fc_rule_add (const char *chain_name, int position,
84     int match_num, const char **match_name, int *match_argc, char ***match_argv,
85     const char *target_name, int target_argc, char **target_argv);
86 int fc_rule_delete (const char *chain_name, int position);
87 #endif
88
89 /*
90  * Processing function
91  */
92 fc_chain_t *fc_chain_get_by_name(const char *chain_name);
93
94 int fc_process_chain(const data_set_t *ds, value_list_t *vl, fc_chain_t *chain);
95
96 int fc_default_action(const data_set_t *ds, value_list_t *vl);
97
98 /*
99  * Shortcut for global configuration
100  */
101 int fc_configure(const oconfig_item_t *ci);
102
103 #endif /* FILTER_CHAIN_H */