]> arthur.barton.de Git - netdata.git/blob - src/health.h
chart and dimensions variables linked to 3 indexes: local, context and host variables
[netdata.git] / src / health.h
1 #ifndef NETDATA_HEALTH_H
2 #define NETDATA_HEALTH_H
3
4 extern int rrdvar_compare(void *a, void *b);
5
6 /*
7  * RRDVAR
8  * a variable
9  *
10  * There are 4 scopes: local (chart), context, host and global variables
11  *
12  * Standard global variables:
13  *  $now
14  *
15  * Standard host variables:
16  *  - none -
17  *
18  * Standard context variables:
19  *  - none -
20  *
21  * Standard local variables:
22  *  $last_updated
23  *  $last_collected_value
24  *  $last_value
25  *
26  */
27
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
32
33 // the variables as stored in the variables indexes
34 typedef struct rrdvar {
35     avl avl;
36
37     char *name;
38     uint32_t hash;
39
40     int type;
41     void *value;
42
43     time_t last_updated;
44 } RRDVAR;
45
46 // variables linked to charts
47 typedef struct rrdsetvar {
48     char *fullid;               // chart type.chart id.variable
49     uint32_t hash_fullid;
50
51     char *fullname;             // chart type.chart name.variable
52     uint32_t hash_fullname;
53
54     char *variable;             // variable
55     uint32_t hash_variable;
56
57     int type;
58     void *value;
59
60     uint32_t options;
61
62     RRDVAR *local;
63     RRDVAR *context;
64     RRDVAR *host;
65     RRDVAR *context_name;
66     RRDVAR *host_name;
67
68     struct rrdset *rrdset;
69
70     struct rrdsetvar *next;
71 } RRDSETVAR;
72
73
74 // variables linked to dimensions
75 typedef struct rrddimvar {
76     char *prefix;
77     char *suffix;
78
79     char *id;                   // dimension id
80     uint32_t hash;
81
82     char *name;                 // dimension name
83     uint32_t hash_name;
84
85     char *fullidid;             // chart type.chart id.dimension id
86     uint32_t hash_fullidid;
87
88     char *fullidname;           // chart type.chart id.dimension name
89     uint32_t hash_fullidname;
90
91     char *fullnameid;           // chart type.chart name.dimension id
92     uint32_t hash_fullnameid;
93
94     char *fullnamename;         // chart type.chart name.dimension name
95     uint32_t hash_fullnamename;
96
97     int type;
98     void *value;
99
100     uint32_t options;
101
102     RRDVAR *local_id;
103     RRDVAR *local_name;
104
105     RRDVAR *context_fullidid;
106     RRDVAR *context_fullidname;
107     RRDVAR *context_fullnameid;
108     RRDVAR *context_fullnamename;
109
110     RRDVAR *host_fullidid;
111     RRDVAR *host_fullidname;
112     RRDVAR *host_fullnameid;
113     RRDVAR *host_fullnamename;
114
115     struct rrddim *rrddim;
116
117     struct rrddimvar *next;
118 } RRDDIMVAR;
119
120 typedef struct rrdcalc {
121     avl avl;
122
123     int group;          // grouping method: average, max, etc.
124     int before;         // ending point in time-series
125     int after;          // starting point in time-series
126     int update_every;   // update frequency for the calculation
127
128     const char *name;
129     calculated_number value;
130
131     RRDVAR *local;
132     RRDVAR *context;
133     RRDVAR *host;
134
135     struct rrdcalc *next;
136     struct rrdcalc *prev;
137 } RRDCALC;
138
139 #include "rrd.h"
140
141 extern void rrdsetvar_rename_all(RRDSET *st);
142 extern RRDSETVAR *rrdsetvar_create(RRDSET *st, const char *variable, int type, void *value, uint32_t options);
143 extern void rrdsetvar_free(RRDSETVAR *rs);
144
145 extern void rrddimvar_rename_all(RRDDIM *rd);
146 extern RRDDIMVAR *rrddimvar_create(RRDDIM *rd, int type, const char *prefix, const char *suffix, void *value, uint32_t options);
147 extern void rrddimvar_free(RRDDIMVAR *rs);
148
149 #endif //NETDATA_HEALTH_H