Parser cleanup (#13782)
* Remove end, set disable and flush actions * Remove begin action * Remove label action * Remove overwrite action * Remove chart action * Remove dimension action * Remove label action (part 2) * Remove variable action Co-authored-by: vkalintiris <vasilis@netdata.cloud>
Stelios Fragkakis committed
Oct 10, 2022 at 15:27 UTC
360e57d47bc29d0f0362c74493e4e3d932ea147e
8 files changed
+120
-342
collectors/plugins.d/pluginsd_parser.c
+116
-238
@@ -4,192 +4,7 @@
4
5
#define LOG_FUNCTIONS false
6
7
-/*
8
- * This is the action defined for the FLUSH command
9
- */
10
-PARSER_RC pluginsd_set_action(void *user, RRDSET *st, RRDDIM *rd, long long int value)
11
-{
12
- UNUSED(user);
13
-
14
- rrddim_set_by_pointer(st, rd, value);
15
- return PARSER_RC_OK;
16
-}
17
-
18
-PARSER_RC pluginsd_flush_action(void *user, RRDSET *st)
19
-{
20
- UNUSED(user);
21
- UNUSED(st);
22
- return PARSER_RC_OK;
23
-}
24
-
25
-PARSER_RC pluginsd_begin_action(void *user, RRDSET *st, usec_t microseconds, int trust_durations)
26
-{
27
- UNUSED(user);
28
- if (likely(st->counter_done)) {
29
- if (likely(microseconds)) {
30
- if (trust_durations)
31
- rrdset_next_usec_unfiltered(st, microseconds);
32
- else
33
- rrdset_next_usec(st, microseconds);
34
- } else
35
- rrdset_next(st);
36
- }
37
- return PARSER_RC_OK;
38
-}
39
-
40
-
41
-PARSER_RC pluginsd_end_action(void *user, RRDSET *st)
42
-{
43
- UNUSED(user);
44
-
45
- rrdset_done(st);
46
- return PARSER_RC_OK;
47
-}
48
-
49
-PARSER_RC pluginsd_chart_action(void *user, char *type, char *id, char *name, char *family, char *context, char *title, char *units, char *plugin,
50
- char *module, int priority, int update_every, RRDSET_TYPE chart_type, char *options)
51
-{
52
- RRDSET *st = NULL;
53
- RRDHOST *host = ((PARSER_USER_OBJECT *) user)->host;
54
-
55
- st = rrdset_create(
56
- host, type, id, name, family, context, title, units,
57
- plugin, module, priority, update_every,
58
- chart_type);
59
-
60
- if (options && *options) {
61
- if (strstr(options, "obsolete"))
62
- rrdset_is_obsolete(st);
63
- else
64
- rrdset_isnot_obsolete(st);
65
-
66
- if (strstr(options, "detail"))
67
- rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
68
- else
69
- rrdset_flag_clear(st, RRDSET_FLAG_DETAIL);
70
-
71
- if (strstr(options, "hidden"))
72
- rrdset_flag_set(st, RRDSET_FLAG_HIDDEN);
73
- else
74
- rrdset_flag_clear(st, RRDSET_FLAG_HIDDEN);
75
-
76
- if (strstr(options, "store_first"))
77
- rrdset_flag_set(st, RRDSET_FLAG_STORE_FIRST);
78
- else
79
- rrdset_flag_clear(st, RRDSET_FLAG_STORE_FIRST);
80
- } else {
81
- rrdset_isnot_obsolete(st);
82
- rrdset_flag_clear(st, RRDSET_FLAG_DETAIL);
83
- rrdset_flag_clear(st, RRDSET_FLAG_STORE_FIRST);
84
- }
85
- ((PARSER_USER_OBJECT *)user)->st = st;
86
-
87
- return PARSER_RC_OK;
88
-}
89
-
90
-
91
-PARSER_RC pluginsd_disable_action(void *user)
92
-{
93
- UNUSED(user);
94
-
95
- info("called DISABLE. Disabling it.");
96
- ((PARSER_USER_OBJECT *) user)->enabled = 0;
97
- return PARSER_RC_ERROR;
98
-}
99
-
100
-
101
-PARSER_RC pluginsd_variable_action(void *user, RRDHOST *host, RRDSET *st, char *name, int global, NETDATA_DOUBLE value)
102
-{
103
- UNUSED(user);
104
-
105
- if (global) {
106
- const RRDVAR_ACQUIRED *rva = rrdvar_custom_host_variable_add_and_acquire(host, name);
107
- if (rva) {
108
- rrdvar_custom_host_variable_set(host, rva, value);
109
- rrdvar_custom_host_variable_release(host, rva);
110
- }
111
- else
112
- error("cannot find/create HOST VARIABLE '%s' on host '%s'", name, rrdhost_hostname(host));
113
- } else {
114
- const RRDSETVAR_ACQUIRED *rsa = rrdsetvar_custom_chart_variable_add_and_acquire(st, name);
115
- if (rsa) {
116
- rrdsetvar_custom_chart_variable_set(st, rsa, value);
117
- rrdsetvar_custom_chart_variable_release(st, rsa);
118
- }
119
- else
120
- error("cannot find/create CHART VARIABLE '%s' on host '%s', chart '%s'", name, rrdhost_hostname(host), rrdset_id(st));
121
- }
122
- return PARSER_RC_OK;
123
-}
124
-
125
-
126
-
127
-PARSER_RC pluginsd_dimension_action(void *user, RRDSET *st, char *id, char *name, char *algorithm, long multiplier, long divisor, char *options,
128
- RRD_ALGORITHM algorithm_type)
129
-{
130
- UNUSED(user);
131
- UNUSED(algorithm);
132
-
133
- RRDDIM *rd = rrddim_add(st, id, name, multiplier, divisor, algorithm_type);
134
- int unhide_dimension = 1;
135
-
136
- rrddim_option_clear(rd, RRDDIM_OPTION_DONT_DETECT_RESETS_OR_OVERFLOWS);
137
- if (options && *options) {
138
- if (strstr(options, "obsolete") != NULL)
139
- rrddim_is_obsolete(st, rd);
140
- else
141
- rrddim_isnot_obsolete(st, rd);
142
-
143
- unhide_dimension = !strstr(options, "hidden");
144
-
145
- if (strstr(options, "noreset") != NULL)
146
- rrddim_option_set(rd, RRDDIM_OPTION_DONT_DETECT_RESETS_OR_OVERFLOWS);
147
- if (strstr(options, "nooverflow") != NULL)
148
- rrddim_option_set(rd, RRDDIM_OPTION_DONT_DETECT_RESETS_OR_OVERFLOWS);
149
- } else
150
- rrddim_isnot_obsolete(st, rd);
151
-
152
- if (likely(unhide_dimension)) {
153
- rrddim_option_clear(rd, RRDDIM_OPTION_HIDDEN);
154
- if (rrddim_flag_check(rd, RRDDIM_FLAG_META_HIDDEN)) {
155
- (void)sql_set_dimension_option(&rd->metric_uuid, NULL);
156
- rrddim_flag_clear(rd, RRDDIM_FLAG_META_HIDDEN);
157
- }
158
- } else {
159
- rrddim_option_set(rd, RRDDIM_OPTION_HIDDEN);
160
- if (!rrddim_flag_check(rd, RRDDIM_FLAG_META_HIDDEN)) {
161
- (void)sql_set_dimension_option(&rd->metric_uuid, "hidden");
162
- rrddim_flag_set(rd, RRDDIM_FLAG_META_HIDDEN);
163
- }
164
- }
165
- return PARSER_RC_OK;
166
-}
167
-
168
-PARSER_RC pluginsd_label_action(void *user, char *key, char *value, RRDLABEL_SRC source)
169
-{
170
-
171
- if(unlikely(!((PARSER_USER_OBJECT *) user)->new_host_labels))
172
- ((PARSER_USER_OBJECT *) user)->new_host_labels = rrdlabels_create();
173
-
174
- rrdlabels_add(((PARSER_USER_OBJECT *)user)->new_host_labels, key, value, source);
175
-
176
- return PARSER_RC_OK;
177
-}
178
-
179
-PARSER_RC pluginsd_overwrite_action(void *user, RRDHOST *host, DICTIONARY *new_host_labels)
180
-{
181
- UNUSED(user);
182
-
183
- if(!host->rrdlabels)
184
- host->rrdlabels = rrdlabels_create();
185
-
186
- rrdlabels_migrate_to_these(host->rrdlabels, new_host_labels);
187
- sql_store_host_labels(host);
188
-
189
- return PARSER_RC_OK;
190
-}
191
-
192
-PARSER_RC pluginsd_set(char **words, void *user, PLUGINSD_ACTION *plugins_action)
7
+PARSER_RC pluginsd_set(char **words, void *user, PLUGINSD_ACTION *plugins_action __maybe_unused)
8
{
9
char *dimension = words[1];
10
char *value = words[2];
@@ -222,12 +37,8 @@ PARSER_RC pluginsd_set(char **words, void *user, PLUGINSD_ACTION *plugins_actio
37
"requested a SET to dimension with id '%s' on stats '%s' (%s) on host '%s', which does not exist. Disabling it.",
38
dimension, rrdset_name(st), rrdset_id(st), rrdhost_hostname(st->rrdhost));
39
goto disable;
225
- } else {
226
- if (plugins_action->set_action) {
227
- return plugins_action->set_action(
228
- user, st, rd, strtoll(value, NULL, 0));
229
- }
230
- }
40
+ } else
41
+ rrddim_set_by_pointer(st, rd, strtoll(value, NULL, 0));
42
}
43
return PARSER_RC_OK;
44
@@ -236,7 +47,7 @@ disable:
47
return PARSER_RC_ERROR;
48
}
49
239
-PARSER_RC pluginsd_begin(char **words, void *user, PLUGINSD_ACTION *plugins_action)
50
+PARSER_RC pluginsd_begin(char **words, void *user, PLUGINSD_ACTION *plugins_action __maybe_unused)
51
{
52
char *id = words[1];
53
char *microseconds_txt = words[2];
@@ -260,17 +71,23 @@ PARSER_RC pluginsd_begin(char **words, void *user, PLUGINSD_ACTION *plugins_act
71
if (microseconds_txt && *microseconds_txt)
72
microseconds = str2ull(microseconds_txt);
73
263
- if (plugins_action->begin_action) {
264
- return plugins_action->begin_action(user, st, microseconds,
265
- ((PARSER_USER_OBJECT *)user)->trust_durations);
74
+ if (likely(st->counter_done)) {
75
+ if (likely(microseconds)) {
76
+ if (((PARSER_USER_OBJECT *)user)->trust_durations)
77
+ rrdset_next_usec_unfiltered(st, microseconds);
78
+ else
79
+ rrdset_next_usec(st, microseconds);
80
+ } else
81
+ rrdset_next(st);
82
}
83
+
84
return PARSER_RC_OK;
85
disable:
86
((PARSER_USER_OBJECT *)user)->enabled = 0;
87
return PARSER_RC_ERROR;
88
}
89
273
-PARSER_RC pluginsd_end(char **words, void *user, PLUGINSD_ACTION *plugins_action)
90
+PARSER_RC pluginsd_end(char **words, void *user, PLUGINSD_ACTION *plugins_action __maybe_unused)
91
{
92
UNUSED(words);
93
RRDSET *st = ((PARSER_USER_OBJECT *) user)->st;
@@ -287,13 +104,11 @@ PARSER_RC pluginsd_end(char **words, void *user, PLUGINSD_ACTION *plugins_actio
104
105
((PARSER_USER_OBJECT *) user)->st = NULL;
106
((PARSER_USER_OBJECT *) user)->count++;
290
- if (plugins_action->end_action) {
291
- return plugins_action->end_action(user, st);
292
- }
107
+ rrdset_done(st);
108
return PARSER_RC_OK;
109
}
110
296
-PARSER_RC pluginsd_chart(char **words, void *user, PLUGINSD_ACTION *plugins_action)
111
+PARSER_RC pluginsd_chart(char **words, void *user, PLUGINSD_ACTION *plugins_action __maybe_unused)
112
{
113
RRDHOST *host = ((PARSER_USER_OBJECT *) user)->host;
114
if (unlikely(!host && !((PARSER_USER_OBJECT *) user)->host_exists)) {
@@ -314,8 +129,6 @@ PARSER_RC pluginsd_chart(char **words, void *user, PLUGINSD_ACTION *plugins_act
129
char *plugin = words[11];
130
char *module = words[12];
131
317
- int have_action = ((plugins_action->chart_action) != NULL);
318
-
132
// parse the id from type
133
char *id = NULL;
134
if (likely(type && (id = strchr(type, '.')))) {
@@ -379,17 +192,47 @@ PARSER_RC pluginsd_chart(char **words, void *user, PLUGINSD_ACTION *plugins_act
192
type, id, name ? name : "", family ? family : "", context ? context : "", rrdset_type_name(chart_type),
193
priority, update_every);
194
382
- if (have_action) {
383
- return plugins_action->chart_action(
384
- user, type, id, name, family, context, title, units,
385
- (plugin && *plugin) ? plugin : ((PARSER_USER_OBJECT *)user)->cd->filename, module, priority, update_every,
386
- chart_type, options);
195
+ RRDSET *st = NULL;
196
+
197
+ st = rrdset_create(
198
+ host, type, id, name, family, context, title, units,
199
+ (plugin && *plugin) ? plugin : ((PARSER_USER_OBJECT *)user)->cd->filename,
200
+ module, priority, update_every,
201
+ chart_type);
202
+
203
+ if (likely(st)) {
204
+ if (options && *options) {
205
+ if (strstr(options, "obsolete"))
206
+ rrdset_is_obsolete(st);
207
+ else
208
+ rrdset_isnot_obsolete(st);
209
+
210
+ if (strstr(options, "detail"))
211
+ rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
212
+ else
213
+ rrdset_flag_clear(st, RRDSET_FLAG_DETAIL);
214
+
215
+ if (strstr(options, "hidden"))
216
+ rrdset_flag_set(st, RRDSET_FLAG_HIDDEN);
217
+ else
218
+ rrdset_flag_clear(st, RRDSET_FLAG_HIDDEN);
219
+
220
+ if (strstr(options, "store_first"))
221
+ rrdset_flag_set(st, RRDSET_FLAG_STORE_FIRST);
222
+ else
223
+ rrdset_flag_clear(st, RRDSET_FLAG_STORE_FIRST);
224
+ } else {
225
+ rrdset_isnot_obsolete(st);
226
+ rrdset_flag_clear(st, RRDSET_FLAG_DETAIL);
227
+ rrdset_flag_clear(st, RRDSET_FLAG_STORE_FIRST);
228
+ }
229
}
230
+ ((PARSER_USER_OBJECT *)user)->st = st;
231
232
return PARSER_RC_OK;
233
}
234
392
-PARSER_RC pluginsd_dimension(char **words, void *user, PLUGINSD_ACTION *plugins_action)
235
+PARSER_RC pluginsd_dimension(char **words, void *user, PLUGINSD_ACTION *plugins_action __maybe_unused)
236
{
237
char *id = words[1];
238
char *name = words[2];
@@ -441,10 +284,37 @@ PARSER_RC pluginsd_dimension(char **words, void *user, PLUGINSD_ACTION *plugins
284
rrdset_id(st), id, name ? name : "", rrd_algorithm_name(rrd_algorithm_id(algorithm)), multiplier, divisor,
285
options ? options : "");
286
444
- if (plugins_action->dimension_action) {
445
- return plugins_action->dimension_action(
446
- user, st, id, name, algorithm,
447
- multiplier, divisor, (options && *options)?options:NULL, rrd_algorithm_id(algorithm));
287
+ RRDDIM *rd = rrddim_add(st, id, name, multiplier, divisor, rrd_algorithm_id(algorithm));
288
+ int unhide_dimension = 1;
289
+
290
+ rrddim_option_clear(rd, RRDDIM_OPTION_DONT_DETECT_RESETS_OR_OVERFLOWS);
291
+ if (options && *options) {
292
+ if (strstr(options, "obsolete") != NULL)
293
+ rrddim_is_obsolete(st, rd);
294
+ else
295
+ rrddim_isnot_obsolete(st, rd);
296
+
297
+ unhide_dimension = !strstr(options, "hidden");
298
+
299
+ if (strstr(options, "noreset") != NULL)
300
+ rrddim_option_set(rd, RRDDIM_OPTION_DONT_DETECT_RESETS_OR_OVERFLOWS);
301
+ if (strstr(options, "nooverflow") != NULL)
302
+ rrddim_option_set(rd, RRDDIM_OPTION_DONT_DETECT_RESETS_OR_OVERFLOWS);
303
+ } else
304
+ rrddim_isnot_obsolete(st, rd);
305
+
306
+ if (likely(unhide_dimension)) {
307
+ rrddim_option_clear(rd, RRDDIM_OPTION_HIDDEN);
308
+ if (rrddim_flag_check(rd, RRDDIM_FLAG_META_HIDDEN)) {
309
+ (void)sql_set_dimension_option(&rd->metric_uuid, NULL);
310
+ rrddim_flag_clear(rd, RRDDIM_FLAG_META_HIDDEN);
311
+ }
312
+ } else {
313
+ rrddim_option_set(rd, RRDDIM_OPTION_HIDDEN);
314
+ if (!rrddim_flag_check(rd, RRDDIM_FLAG_META_HIDDEN)) {
315
+ (void)sql_set_dimension_option(&rd->metric_uuid, "hidden");
316
+ rrddim_flag_set(rd, RRDDIM_FLAG_META_HIDDEN);
317
+ }
318
}
319
320
return PARSER_RC_OK;
@@ -695,7 +565,7 @@ PARSER_RC pluginsd_function_result_begin(char **words, void *user, PLUGINSD_ACTI
565
566
// ----------------------------------------------------------------------------
567
698
-PARSER_RC pluginsd_variable(char **words, void *user, PLUGINSD_ACTION *plugins_action)
568
+PARSER_RC pluginsd_variable(char **words, void *user, PLUGINSD_ACTION *plugins_action __maybe_unused)
569
{
570
char *name = words[1];
571
char *value = words[2];
@@ -751,37 +621,47 @@ PARSER_RC pluginsd_variable(char **words, void *user, PLUGINSD_ACTION *plugins_
621
endptr);
622
}
623
754
- if (plugins_action->variable_action) {
755
- return plugins_action->variable_action(user, host, st, name, global, v);
624
+ if (global) {
625
+ const RRDVAR_ACQUIRED *rva = rrdvar_custom_host_variable_add_and_acquire(host, name);
626
+ if (rva) {
627
+ rrdvar_custom_host_variable_set(host, rva, v);
628
+ rrdvar_custom_host_variable_release(host, rva);
629
+ }
630
+ else
631
+ error("cannot find/create HOST VARIABLE '%s' on host '%s'", name, rrdhost_hostname(host));
632
+ } else {
633
+ const RRDSETVAR_ACQUIRED *rsa = rrdsetvar_custom_chart_variable_add_and_acquire(st, name);
634
+ if (rsa) {
635
+ rrdsetvar_custom_chart_variable_set(st, rsa, v);
636
+ rrdsetvar_custom_chart_variable_release(st, rsa);
637
+ }
638
+ else
639
+ error("cannot find/create CHART VARIABLE '%s' on host '%s', chart '%s'", name, rrdhost_hostname(host), rrdset_id(st));
640
}
641
642
+
643
return PARSER_RC_OK;
644
}
645
761
-PARSER_RC pluginsd_flush(char **words, void *user, PLUGINSD_ACTION *plugins_action)
646
+PARSER_RC pluginsd_flush(char **words, void *user, PLUGINSD_ACTION *plugins_action __maybe_unused)
647
{
648
UNUSED(words);
649
debug(D_PLUGINSD, "requested a FLUSH");
765
- RRDSET *st = ((PARSER_USER_OBJECT *) user)->st;
650
((PARSER_USER_OBJECT *) user)->st = NULL;
767
- if (plugins_action->flush_action) {
768
- return plugins_action->flush_action(user, st);
769
- }
651
return PARSER_RC_OK;
652
}
653
773
-PARSER_RC pluginsd_disable(char **words, void *user, PLUGINSD_ACTION *plugins_action)
654
+PARSER_RC pluginsd_disable(char **words, void *user, PLUGINSD_ACTION *plugins_action __maybe_unused)
655
{
656
UNUSED(user);
657
UNUSED(words);
658
778
- if (plugins_action->disable_action) {
779
- return plugins_action->disable_action(user);
780
- }
659
+ info("called DISABLE. Disabling it.");
660
+ ((PARSER_USER_OBJECT *) user)->enabled = 0;
661
return PARSER_RC_ERROR;
662
}
663
784
-PARSER_RC pluginsd_label(char **words, void *user, PLUGINSD_ACTION *plugins_action)
664
+PARSER_RC pluginsd_label(char **words, void *user, PLUGINSD_ACTION *plugins_action __maybe_unused)
665
{
666
char *store;
667
@@ -812,34 +692,32 @@ PARSER_RC pluginsd_label(char **words, void *user, PLUGINSD_ACTION *plugins_act
692
}
693
}
694
815
- if (plugins_action->label_action) {
816
- PARSER_RC rc = plugins_action->label_action(user, words[1], store, strtol(words[2], NULL, 10));
817
- if (store != words[3])
818
- freez(store);
819
- return rc;
820
- }
695
+ if(unlikely(!((PARSER_USER_OBJECT *) user)->new_host_labels))
696
+ ((PARSER_USER_OBJECT *) user)->new_host_labels = rrdlabels_create();
697
+
698
+ rrdlabels_add(((PARSER_USER_OBJECT *)user)->new_host_labels, words[1], store, strtol(words[2], NULL, 10));
699
700
if (store != words[3])
701
freez(store);
702
return PARSER_RC_OK;
703
}
704
827
-PARSER_RC pluginsd_overwrite(char **words, void *user, PLUGINSD_ACTION *plugins_action)
705
+PARSER_RC pluginsd_overwrite(char **words, void *user, PLUGINSD_ACTION *plugins_action __maybe_unused)
706
{
707
UNUSED(words);
708
709
RRDHOST *host = ((PARSER_USER_OBJECT *) user)->host;
710
debug(D_PLUGINSD, "requested to OVERWRITE host labels");
711
834
- PARSER_RC rc = PARSER_RC_OK;
712
+ if(!host->rrdlabels)
713
+ host->rrdlabels = rrdlabels_create();
714
836
- if (plugins_action->overwrite_action)
837
- rc = plugins_action->overwrite_action(user, host, ((PARSER_USER_OBJECT *)user)->new_host_labels);
715
+ rrdlabels_migrate_to_these(host->rrdlabels, (DICTIONARY *) (((PARSER_USER_OBJECT *)user)->new_host_labels));
716
+ sql_store_host_labels(host);
717
718
rrdlabels_destroy(((PARSER_USER_OBJECT *)user)->new_host_labels);
719
((PARSER_USER_OBJECT *)user)->new_host_labels = NULL;
841
-
842
- return rc;
720
+ return PARSER_RC_OK;
721
}
722
723
collectors/plugins.d/pluginsd_parser.h
+1
-15
@@ -22,22 +22,8 @@ typedef struct parser_user_object {
22
void *private; // the user can set this for private use
23
} PARSER_USER_OBJECT;
24
25
-PARSER_RC pluginsd_set_action(void *user, RRDSET *st, RRDDIM *rd, long long int value);
26
-PARSER_RC pluginsd_flush_action(void *user, RRDSET *st);
27
-PARSER_RC pluginsd_begin_action(void *user, RRDSET *st, usec_t microseconds, int trust_durations);
28
-PARSER_RC pluginsd_end_action(void *user, RRDSET *st);
29
-PARSER_RC pluginsd_chart_action(void *user, char *type, char *id, char *name, char *family, char *context,
30
- char *title, char *units, char *plugin, char *module, int priority,
31
- int update_every, RRDSET_TYPE chart_type, char *options);
32
-PARSER_RC pluginsd_disable_action(void *user);
33
-PARSER_RC pluginsd_variable_action(void *user, RRDHOST *host, RRDSET *st, char *name, int global, NETDATA_DOUBLE value);
34
-PARSER_RC pluginsd_dimension_action(void *user, RRDSET *st, char *id, char *name, char *algorithm,
35
- long multiplier, long divisor, char *options, RRD_ALGORITHM algorithm_type);
36
-PARSER_RC pluginsd_label_action(void *user, char *key, char *value, RRDLABEL_SRC source);
37
-PARSER_RC pluginsd_overwrite_action(void *user, RRDHOST *host, DICTIONARY *new_host_labels);
38
-
25
PARSER_RC pluginsd_function(char **words, void *user, PLUGINSD_ACTION *plugins_action);
26
PARSER_RC pluginsd_function_result_begin(char **words, void *user, PLUGINSD_ACTION *plugins_action);
27
void inflight_functions_init(PARSER *parser);
28
43
-#endif //NETDATA_PLUGINSD_PARSER_H
29
+#endif //NETDATA_PLUGINSD_PARSER_H
\ No newline at end of file
database/engine/metadata_log/logfile.c
-2
@@ -388,8 +388,6 @@ static int scan_metalog_files(struct metalog_instance *ctx)
388
parser_add_keyword(parser, PLUGINSD_KEYWORD_GUID, pluginsd_guid);
389
parser_add_keyword(parser, PLUGINSD_KEYWORD_CONTEXT, pluginsd_context);
390
parser_add_keyword(parser, PLUGINSD_KEYWORD_TOMBSTONE, pluginsd_tombstone);
391
- parser->plugins_action->dimension_action = &metalog_pluginsd_dimension_action;
392
- parser->plugins_action->chart_action = &metalog_pluginsd_chart_action;
391
parser->plugins_action->guid_action = &metalog_pluginsd_guid_action;
392
parser->plugins_action->context_action = &metalog_pluginsd_context_action;
393
parser->plugins_action->tombstone_action = &metalog_pluginsd_tombstone_action;
database/engine/metadata_log/metalogpluginsd.c
-51
@@ -44,57 +44,6 @@ PARSER_RC metalog_pluginsd_host_action(
44
return PARSER_RC_OK;
45
}
46
47
-PARSER_RC metalog_pluginsd_chart_action(void *user, char *type, char *id, char *name, char *family, char *context,
48
- char *title, char *units, char *plugin, char *module, int priority,
49
- int update_every, RRDSET_TYPE chart_type, char *options)
50
-{
51
- UNUSED(options);
52
-
53
- struct metalog_pluginsd_state *state = ((PARSER_USER_OBJECT *)user)->private;
54
- RRDHOST *host = ((PARSER_USER_OBJECT *) user)->host;
55
-
56
- if (unlikely(uuid_is_null(state->host_uuid))) {
57
- debug(D_METADATALOG, "Ignoring chart belonging to missing or ignored host.");
58
- return PARSER_RC_OK;
59
- }
60
- uuid_copy(state->chart_uuid, state->uuid);
61
- uuid_clear(state->uuid); /* Consume UUID */
62
- (void) sql_store_chart(&state->chart_uuid, &state->host_uuid,
63
- type, id, name, family, context, title, units,
64
- plugin, module, priority, update_every,
65
- chart_type, RRD_MEMORY_MODE_DBENGINE, host ? host->rrd_history_entries : 1);
66
- ((PARSER_USER_OBJECT *)user)->st_exists = 1;
67
-
68
- return PARSER_RC_OK;
69
-}
70
-
71
-PARSER_RC metalog_pluginsd_dimension_action(void *user, RRDSET *st, char *id, char *name, char *algorithm,
72
- long multiplier, long divisor, char *options, RRD_ALGORITHM algorithm_type)
73
-{
74
- struct metalog_pluginsd_state *state = ((PARSER_USER_OBJECT *)user)->private;
75
- UNUSED(user);
76
- UNUSED(options);
77
- UNUSED(algorithm);
78
- UNUSED(st);
79
-
80
- if (unlikely(uuid_is_null(state->chart_uuid))) {
81
- debug(D_METADATALOG, "Ignoring dimension belonging to missing or ignored chart.");
82
- info("Ignoring dimension belonging to missing or ignored chart.");
83
- return PARSER_RC_OK;
84
- }
85
-
86
- if (unlikely(uuid_is_null(state->uuid))) {
87
- debug(D_METADATALOG, "Ignoring dimension without unknown UUID");
88
- info("Ignoring dimension without unknown UUID");
89
- return PARSER_RC_OK;
90
- }
91
-
92
- (void) sql_store_dimension(&state->uuid, &state->chart_uuid, id, name, multiplier, divisor, algorithm_type);
93
- uuid_clear(state->uuid); /* Consume UUID */
94
-
95
- return PARSER_RC_OK;
96
-}
97
-
47
PARSER_RC metalog_pluginsd_guid_action(void *user, uuid_t *uuid)
48
{
49
struct metalog_pluginsd_state *state = ((PARSER_USER_OBJECT *)user)->private;
database/engine/metadata_log/metalogpluginsd.h
+2
-6
@@ -17,13 +17,9 @@ struct metalog_pluginsd_state {
17
};
18
19
void metalog_pluginsd_state_init(struct metalog_pluginsd_state *state, struct metalog_instance *ctx);
20
-
21
-PARSER_RC metalog_pluginsd_chart_action(void *user, char *type, char *id, char *name, char *family,
22
- char *context, char *title, char *units, char *plugin, char *module,
23
- int priority, int update_every, RRDSET_TYPE chart_type, char *options);
20
PARSER_RC metalog_pluginsd_dimension_action(void *user, RRDSET *st, char *id, char *name, char *algorithm,
25
- long multiplier, long divisor, char *options,
26
- RRD_ALGORITHM algorithm_type);
21
+ long multiplier, long divisor, char *options,
22
+ RRD_ALGORITHM algorithm_type);
23
PARSER_RC metalog_pluginsd_guid_action(void *user, uuid_t *uuid);
24
PARSER_RC metalog_pluginsd_context_action(void *user, uuid_t *uuid);
25
PARSER_RC metalog_pluginsd_tombstone_action(void *user, uuid_t *uuid);
parser/parser.c
-13
@@ -66,19 +66,6 @@ PARSER *parser_init(RRDHOST *host, void *user, void *input, void *output, PARSER
66
//parser_add_keyword(parser, PLUGINSD_KEYWORD_GAPS_REQUEST, pluginsd_gaps_request);
67
}
68
69
- if(unlikely(!(flags & PARSER_NO_ACTION_INIT))) {
70
- parser->plugins_action->begin_action = &pluginsd_begin_action;
71
- parser->plugins_action->flush_action = &pluginsd_flush_action;
72
- parser->plugins_action->end_action = &pluginsd_end_action;
73
- parser->plugins_action->disable_action = &pluginsd_disable_action;
74
- parser->plugins_action->variable_action = &pluginsd_variable_action;
75
- parser->plugins_action->dimension_action = &pluginsd_dimension_action;
76
- parser->plugins_action->label_action = &pluginsd_label_action;
77
- parser->plugins_action->overwrite_action = &pluginsd_overwrite_action;
78
- parser->plugins_action->chart_action = &pluginsd_chart_action;
79
- parser->plugins_action->set_action = &pluginsd_set_action;
80
- }
81
-
69
return parser;
70
}
71
parser/parser.h
-16
@@ -17,22 +17,6 @@ typedef enum parser_rc {
17
} PARSER_RC;
18
19
typedef struct pluginsd_action {
20
- PARSER_RC (*set_action)(void *user, RRDSET *st, RRDDIM *rd, long long int value);
21
- PARSER_RC (*begin_action)(void *user, RRDSET *st, usec_t microseconds, int trust_durations);
22
- PARSER_RC (*end_action)(void *user, RRDSET *st);
23
- PARSER_RC (*chart_action)
24
- (void *user, char *type, char *id, char *name, char *family, char *context, char *title, char *units, char *plugin,
25
- char *module, int priority, int update_every, RRDSET_TYPE chart_type, char *options);
26
- PARSER_RC (*dimension_action)
27
- (void *user, RRDSET *st, char *id, char *name, char *algorithm, long multiplier, long divisor, char *options,
28
- RRD_ALGORITHM algorithm_type);
29
-
30
- PARSER_RC (*flush_action)(void *user, RRDSET *st);
31
- PARSER_RC (*disable_action)(void *user);
32
- PARSER_RC (*variable_action)(void *user, RRDHOST *host, RRDSET *st, char *name, int global, NETDATA_DOUBLE value);
33
- PARSER_RC (*label_action)(void *user, char *key, char *value, RRDLABEL_SRC source);
34
- PARSER_RC (*overwrite_action)(void *user, RRDHOST *host, DICTIONARY *new_labels);
35
-
20
PARSER_RC (*guid_action)(void *user, uuid_t *uuid);
21
PARSER_RC (*context_action)(void *user, uuid_t *uuid);
22
PARSER_RC (*tombstone_action)(void *user, uuid_t *uuid);
streaming/receiver.c
+1
-1
@@ -306,7 +306,7 @@ static int receiver_read(struct receiver_state *r, FILE *fp) {
306
internal_error(true, "read_stream() failed (1).");
307
return 1;
308
}
309
-
309
+
310
worker_set_metric(WORKER_RECEIVER_JOB_BYTES_READ, ret);
311
312
if (!is_compressed_data(r->read_buffer, ret)) {