1 #ifndef NETDATA_HEALTH_H
2 #define NETDATA_HEALTH_H
4 extern int rrdvar_compare(void *a, void *b);
10 * There are 4 scopes: local (chart), context, host and global variables
12 * Standard global variables:
15 * Standard host variables:
18 * Standard context variables:
21 * Standard local variables:
23 * $last_collected_value
28 #define RRDVAR_TYPE_CALCULATED 1
29 #define RRDVAR_TYPE_TIME_T 2
30 #define RRDVAR_TYPE_COLLECTED 3
31 #define RRDVAR_TYPE_TOTAL 4
33 // the variables as stored in the variables indexes
34 // there are 3 indexes:
35 // 1. at each chart (RRDSET.variables_root_index)
36 // 2. at each context (RRDCONTEXT.variables_root_index)
37 // 3. at each host (RRDHOST.variables_root_index)
38 typedef struct rrdvar {
50 // variables linked to charts
51 // We link variables to point to the values that are already
52 // calculated / processed by the normal data collection process
53 // This means, there will be no speed penalty for using
55 typedef struct rrdsetvar {
56 char *fullid; // chart type.chart id.variable
59 char *fullname; // chart type.chart name.variable
60 uint32_t hash_fullname;
62 char *variable; // variable
63 uint32_t hash_variable;
76 struct rrdset *rrdset;
78 struct rrdsetvar *next;
82 // variables linked to individual dimensions
83 // We link variables to point the values that are already
84 // calculated / processed by the normal data collection process
85 // This means, there will be no speed penalty for using
87 typedef struct rrddimvar {
91 char *id; // dimension id
94 char *name; // dimension name
97 char *fullidid; // chart type.chart id.dimension id
98 uint32_t hash_fullidid;
100 char *fullidname; // chart type.chart id.dimension name
101 uint32_t hash_fullidname;
103 char *fullnameid; // chart type.chart name.dimension id
104 uint32_t hash_fullnameid;
106 char *fullnamename; // chart type.chart name.dimension name
107 uint32_t hash_fullnamename;
118 RRDVAR *context_name;
120 RRDVAR *context_fullidid;
121 RRDVAR *context_fullidname;
122 RRDVAR *context_fullnameid;
123 RRDVAR *context_fullnamename;
125 RRDVAR *host_fullidid;
126 RRDVAR *host_fullidname;
127 RRDVAR *host_fullnameid;
128 RRDVAR *host_fullnamename;
130 struct rrddim *rrddim;
132 struct rrddimvar *next;
135 // calculated variables (defined in health configuration)
136 // These aggregate time-series data at fixed intervals
137 // (defined in their update_every member below)
138 // These increase the overhead of netdata.
140 // These calculations are allocated and linked (->next)
142 // Then are also linked to RRDSET (of course only when the
143 // chart is found, via ->rrdset_next and ->rrdset_prev).
144 // This double-linked list is maintained sorted at all times
145 // having as RRDSET.calculations the RRDCALC to be processed
147 typedef struct rrdcalc {
153 char *chart; // the chart id this should be linked to
156 char *source; // the source of this calculation
158 char *dimensions; // the chart dimensions
160 int group; // grouping method: average, max, etc.
161 int before; // ending point in time-series
162 int after; // starting point in time-series
163 uint32_t options; // calculation options
164 int update_every; // update frequency for the calculation
169 EVAL_EXPRESSION *calculation;
170 EVAL_EXPRESSION *warning;
171 EVAL_EXPRESSION *critical;
173 calculated_number value;
175 calculated_number green;
176 calculated_number red;
182 struct rrdset *rrdset;
183 struct rrdcalc *rrdset_next;
184 struct rrdcalc *rrdset_prev;
186 struct rrdcalc *next;
189 #define RRDCALC_HAS_CALCULATION(rc) ((rc)->after)
192 // these are to be applied to charts found dynamically
193 // based on their context.
194 typedef struct rrdcalctemplate {
201 uint32_t hash_context;
203 char *source; // the source of this template
207 int group; // grouping method: average, max, etc.
208 int before; // ending point in time-series
209 int after; // starting point in time-series
210 uint32_t options; // calculation options
211 int update_every; // update frequency for the calculation
213 EVAL_EXPRESSION *calculation;
214 EVAL_EXPRESSION *warning;
215 EVAL_EXPRESSION *critical;
217 calculated_number green;
218 calculated_number red;
220 struct rrdcalctemplate *next;
223 #define RRDCALCTEMPLATE_HAS_CALCULATION(rt) ((rt)->after)
228 extern void rrdsetvar_rename_all(RRDSET *st);
229 extern RRDSETVAR *rrdsetvar_create(RRDSET *st, const char *variable, int type, void *value, uint32_t options);
230 extern void rrdsetvar_free(RRDSETVAR *rs);
232 extern void rrddimvar_rename_all(RRDDIM *rd);
233 extern RRDDIMVAR *rrddimvar_create(RRDDIM *rd, int type, const char *prefix, const char *suffix, void *value, uint32_t options);
234 extern void rrddimvar_free(RRDDIMVAR *rs);
236 extern void rrdsetcalc_link_matching(RRDSET *st);
237 extern void rrdsetcalc_unlink(RRDCALC *rc);
238 extern void rrdcalctemplate_link_matching(RRDSET *st);
240 extern void health_init(void);
242 #endif //NETDATA_HEALTH_H