1 #ifndef NETDATA_HEALTH_H
2 #define NETDATA_HEALTH_H
4 extern int health_enabled;
6 extern int rrdvar_compare(void *a, void *b);
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
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 {
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
35 typedef struct rrdsetvar {
36 char *fullid; // chart type.chart id.variable
39 char *fullname; // chart type.chart name.variable
40 uint32_t hash_fullname;
42 char *variable; // variable
43 uint32_t hash_variable;
56 struct rrdset *rrdset;
58 struct rrdsetvar *next;
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
67 typedef struct rrddimvar {
71 char *id; // dimension id
74 char *name; // dimension name
77 char *fullidid; // chart type.chart id.dimension id
78 uint32_t hash_fullidid;
80 char *fullidname; // chart type.chart id.dimension name
81 uint32_t hash_fullidname;
83 char *fullnameid; // chart type.chart name.dimension id
84 uint32_t hash_fullnameid;
86 char *fullnamename; // chart type.chart name.dimension name
87 uint32_t hash_fullnamename;
100 RRDVAR *context_fullidid;
101 RRDVAR *context_fullidname;
102 RRDVAR *context_fullnameid;
103 RRDVAR *context_fullnamename;
105 RRDVAR *host_fullidid;
106 RRDVAR *host_fullidname;
107 RRDVAR *host_fullnameid;
108 RRDVAR *host_fullnamename;
110 struct rrddim *rrddim;
112 struct rrddimvar *next;
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.
120 // These calculations are allocated and linked (->next)
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
127 typedef struct rrdcalc {
133 char *chart; // the chart id this should be linked to
136 char *source; // the source of this calculation
138 char *dimensions; // the chart dimensions
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
149 EVAL_EXPRESSION *calculation;
150 EVAL_EXPRESSION *warning;
151 EVAL_EXPRESSION *critical;
153 calculated_number value;
155 calculated_number green;
156 calculated_number red;
162 struct rrdset *rrdset;
163 struct rrdcalc *rrdset_next;
164 struct rrdcalc *rrdset_prev;
166 struct rrdcalc *next;
169 #define RRDCALC_HAS_CALCULATION(rc) ((rc)->after)
172 // these are to be applied to charts found dynamically
173 // based on their context.
174 typedef struct rrdcalctemplate {
181 uint32_t hash_context;
183 char *source; // the source of this template
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
193 EVAL_EXPRESSION *calculation;
194 EVAL_EXPRESSION *warning;
195 EVAL_EXPRESSION *critical;
197 calculated_number green;
198 calculated_number red;
200 struct rrdcalctemplate *next;
203 #define RRDCALCTEMPLATE_HAS_CALCULATION(rt) ((rt)->after)
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);
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);
216 extern void rrdsetcalc_link_matching(RRDSET *st);
217 extern void rrdsetcalc_unlink(RRDCALC *rc);
218 extern void rrdcalctemplate_link_matching(RRDSET *st);
220 extern void health_init(void);
222 #endif //NETDATA_HEALTH_H