]> arthur.barton.de Git - netdata.git/blob - src/health.h
health configuration variables are checked for invalid characters
[netdata.git] / src / health.h
1 #ifndef NETDATA_HEALTH_H
2 #define NETDATA_HEALTH_H
3
4 extern int health_enabled;
5
6 extern int rrdvar_compare(void *a, void *b);
7
8 #define RRDVAR_TYPE_CALCULATED 1
9 #define RRDVAR_TYPE_TIME_T     2
10 #define RRDVAR_TYPE_COLLECTED  3
11 #define RRDVAR_TYPE_TOTAL      4
12
13 // the variables as stored in the variables indexes
14 // there are 3 indexes:
15 // 1. at each chart   (RRDSET.variables_root_index)
16 // 2. at each context (RRDCONTEXT.variables_root_index)
17 // 3. at each host    (RRDHOST.variables_root_index)
18 typedef struct rrdvar {
19     avl avl;
20
21     char *name;
22     uint32_t hash;
23
24     int type;
25     void *value;
26
27     time_t last_updated;
28 } RRDVAR;
29
30 // variables linked to charts
31 // We link variables to point to the values that are already
32 // calculated / processed by the normal data collection process
33 // This means, there will be no speed penalty for using
34 // these variables
35 typedef struct rrdsetvar {
36     char *fullid;               // chart type.chart id.variable
37     uint32_t hash_fullid;
38
39     char *fullname;             // chart type.chart name.variable
40     uint32_t hash_fullname;
41
42     char *variable;             // variable
43     uint32_t hash_variable;
44
45     int type;
46     void *value;
47
48     uint32_t options;
49
50     RRDVAR *local;
51     RRDVAR *context;
52     RRDVAR *host;
53     RRDVAR *context_name;
54     RRDVAR *host_name;
55
56     struct rrdset *rrdset;
57
58     struct rrdsetvar *next;
59 } RRDSETVAR;
60
61
62 // variables linked to individual dimensions
63 // We link variables to point the values that are already
64 // calculated / processed by the normal data collection process
65 // This means, there will be no speed penalty for using
66 // these variables
67 typedef struct rrddimvar {
68     char *prefix;
69     char *suffix;
70
71     char *id;                   // dimension id
72     uint32_t hash;
73
74     char *name;                 // dimension name
75     uint32_t hash_name;
76
77     char *fullidid;             // chart type.chart id.dimension id
78     uint32_t hash_fullidid;
79
80     char *fullidname;           // chart type.chart id.dimension name
81     uint32_t hash_fullidname;
82
83     char *fullnameid;           // chart type.chart name.dimension id
84     uint32_t hash_fullnameid;
85
86     char *fullnamename;         // chart type.chart name.dimension name
87     uint32_t hash_fullnamename;
88
89     int type;
90     void *value;
91
92     uint32_t options;
93
94     RRDVAR *local_id;
95     RRDVAR *local_name;
96
97     RRDVAR *context_id;
98     RRDVAR *context_name;
99
100     RRDVAR *context_fullidid;
101     RRDVAR *context_fullidname;
102     RRDVAR *context_fullnameid;
103     RRDVAR *context_fullnamename;
104
105     RRDVAR *host_fullidid;
106     RRDVAR *host_fullidname;
107     RRDVAR *host_fullnameid;
108     RRDVAR *host_fullnamename;
109
110     struct rrddim *rrddim;
111
112     struct rrddimvar *next;
113 } RRDDIMVAR;
114
115 // calculated variables (defined in health configuration)
116 // These aggregate time-series data at fixed intervals
117 // (defined in their update_every member below)
118 // These increase the overhead of netdata.
119 //
120 // These calculations are allocated and linked (->next)
121 // under RRDHOST.
122 // Then are also linked to RRDSET (of course only when the
123 // chart is found, via ->rrdset_next and ->rrdset_prev).
124 // This double-linked list is maintained sorted at all times
125 // having as RRDSET.calculations the RRDCALC to be processed
126 // next.
127 typedef struct rrdcalc {
128     char *name;
129     uint32_t hash;
130
131     char *exec;
132
133     char *chart;        // the chart id this should be linked to
134     uint32_t hash_chart;
135
136     char *source;       // the source of this calculation
137
138     char *dimensions;   // the chart dimensions
139
140     int group;          // grouping method: average, max, etc.
141     int before;         // ending point in time-series
142     int after;          // starting point in time-series
143     uint32_t options;   // calculation options
144     int update_every;   // update frequency for the calculation
145
146     time_t last_updated;
147     time_t next_update;
148
149     EVAL_EXPRESSION *calculation;
150     EVAL_EXPRESSION *warning;
151     EVAL_EXPRESSION *critical;
152
153     calculated_number value;
154
155     calculated_number green;
156     calculated_number red;
157
158     RRDVAR *local;
159     RRDVAR *context;
160     RRDVAR *host;
161
162     struct rrdset *rrdset;
163     struct rrdcalc *rrdset_next;
164     struct rrdcalc *rrdset_prev;
165
166     struct rrdcalc *next;
167 } RRDCALC;
168
169 #define RRDCALC_HAS_CALCULATION(rc) ((rc)->after)
170
171 // RRDCALCTEMPLATE
172 // these are to be applied to charts found dynamically
173 // based on their context.
174 typedef struct rrdcalctemplate {
175     char *name;
176     uint32_t hash_name;
177
178     char *exec;
179
180     char *context;
181     uint32_t hash_context;
182
183     char *source;       // the source of this template
184
185     char *dimensions;
186
187     int group;          // grouping method: average, max, etc.
188     int before;         // ending point in time-series
189     int after;          // starting point in time-series
190     uint32_t options;   // calculation options
191     int update_every;   // update frequency for the calculation
192
193     EVAL_EXPRESSION *calculation;
194     EVAL_EXPRESSION *warning;
195     EVAL_EXPRESSION *critical;
196
197     calculated_number green;
198     calculated_number red;
199
200     struct rrdcalctemplate *next;
201 } RRDCALCTEMPLATE;
202
203 #define RRDCALCTEMPLATE_HAS_CALCULATION(rt) ((rt)->after)
204
205
206 #include "rrd.h"
207
208 extern void rrdsetvar_rename_all(RRDSET *st);
209 extern RRDSETVAR *rrdsetvar_create(RRDSET *st, const char *variable, int type, void *value, uint32_t options);
210 extern void rrdsetvar_free(RRDSETVAR *rs);
211
212 extern void rrddimvar_rename_all(RRDDIM *rd);
213 extern RRDDIMVAR *rrddimvar_create(RRDDIM *rd, int type, const char *prefix, const char *suffix, void *value, uint32_t options);
214 extern void rrddimvar_free(RRDDIMVAR *rs);
215
216 extern void rrdsetcalc_link_matching(RRDSET *st);
217 extern void rrdsetcalc_unlink(RRDCALC *rc);
218 extern void rrdcalctemplate_link_matching(RRDSET *st);
219
220 extern void health_init(void);
221
222 #endif //NETDATA_HEALTH_H