allow alarm templates to match patterns of chart families; fixes #1571
Costa Tsaousis (ktsaou) committed
Jan 15, 2017 at 18:16 UTC
a9025e3dd67343e4bdad306f244c650b1d1b44e5
8 files changed
+100
-120
src/health.c
+18
-6
@@ -1400,7 +1400,8 @@ void rrdcalctemplate_link_matching(RRDSET *st) {
1400
RRDCALCTEMPLATE *rt;
1401
1402
for(rt = st->rrdhost->templates; rt ; rt = rt->next) {
1403
- if(rt->hash_context == st->hash_context && !strcmp(rt->context, st->context)) {
1403
+ if(rt->hash_context == st->hash_context && !strcmp(rt->context, st->context)
1404
+ && (!rt->family_pattern || simple_pattern_matches(rt->family_pattern, st->family))) {
1405
RRDCALC *rc = rrdcalc_create(st->rrdhost, rt, st->id);
1406
if(unlikely(!rc))
1407
error("Health tried to create alarm from template '%s', but it failed", rt->name);
@@ -1436,6 +1437,9 @@ static inline void rrdcalctemplate_free(RRDHOST *host, RRDCALCTEMPLATE *rt) {
1437
expression_free(rt->warning);
1438
expression_free(rt->critical);
1439
1440
+ freez(rt->family_match);
1441
+ simple_pattern_free(rt->family_pattern);
1442
+
1443
freez(rt->name);
1444
freez(rt->exec);
1445
freez(rt->recipient);
@@ -1455,6 +1459,7 @@ static inline void rrdcalctemplate_free(RRDHOST *host, RRDCALCTEMPLATE *rt) {
1459
#define HEALTH_ALARM_KEY "alarm"
1460
#define HEALTH_TEMPLATE_KEY "template"
1461
#define HEALTH_ON_KEY "on"
1462
+#define HEALTH_FAMILIES_KEY "families"
1463
#define HEALTH_LOOKUP_KEY "lookup"
1464
#define HEALTH_CALC_KEY "calc"
1465
#define HEALTH_EVERY_KEY "every"
@@ -1825,13 +1830,14 @@ static inline void strip_quotes(char *s) {
1830
int health_readfile(const char *path, const char *filename) {
1831
debug(D_HEALTH, "Health configuration reading file '%s/%s'", path, filename);
1832
1828
- static uint32_t hash_alarm = 0, hash_template = 0, hash_on = 0, hash_calc = 0, hash_green = 0, hash_red = 0, hash_warn = 0, hash_crit = 0, hash_exec = 0, hash_every = 0, hash_lookup = 0, hash_units = 0, hash_info = 0, hash_recipient = 0, hash_delay = 0;
1833
+ static uint32_t hash_alarm = 0, hash_template = 0, hash_on = 0, hash_families = 0, hash_calc = 0, hash_green = 0, hash_red = 0, hash_warn = 0, hash_crit = 0, hash_exec = 0, hash_every = 0, hash_lookup = 0, hash_units = 0, hash_info = 0, hash_recipient = 0, hash_delay = 0;
1834
char buffer[HEALTH_CONF_MAX_LINE + 1];
1835
1836
if(unlikely(!hash_alarm)) {
1837
hash_alarm = simple_uhash(HEALTH_ALARM_KEY);
1838
hash_template = simple_uhash(HEALTH_TEMPLATE_KEY);
1839
hash_on = simple_uhash(HEALTH_ON_KEY);
1840
+ hash_families = simple_uhash(HEALTH_FAMILIES_KEY);
1841
hash_calc = simple_uhash(HEALTH_CALC_KEY);
1842
hash_lookup = simple_uhash(HEALTH_LOOKUP_KEY);
1843
hash_green = simple_uhash(HEALTH_GREEN_KEY);
@@ -1951,7 +1957,7 @@ int health_readfile(const char *path, const char *filename) {
1957
if(rc->chart) {
1958
if(strcmp(rc->chart, value))
1959
error("Health configuration at line %zu of file '%s/%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1954
- line, path, filename, rc->name, key, rc->chart, value, value);
1960
+ line, path, filename, rc->name, key, rc->chart, value, value);
1961
1962
freez(rc->chart);
1963
}
@@ -2066,17 +2072,23 @@ int health_readfile(const char *path, const char *filename) {
2072
if(rt->context) {
2073
if(strcmp(rt->context, value))
2074
error("Health configuration at line %zu of file '%s/%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
2069
- line, path, filename, rt->name, key, rt->context, value, value);
2075
+ line, path, filename, rt->name, key, rt->context, value, value);
2076
2077
freez(rt->context);
2078
}
2079
rt->context = tabs2spaces(strdupz(value));
2080
rt->hash_context = simple_hash(rt->context);
2081
}
2082
+ else if(hash == hash_families && !strcasecmp(key, HEALTH_FAMILIES_KEY)) {
2083
+ freez(rt->family_match);
2084
+ simple_pattern_free(rt->family_pattern);
2085
+
2086
+ rt->family_match = tabs2spaces(strdupz(value));
2087
+ rt->family_pattern = simple_pattern_create(rt->family_match, SIMPLE_PATTERN_EXACT);
2088
+ }
2089
else if(hash == hash_lookup && !strcasecmp(key, HEALTH_LOOKUP_KEY)) {
2090
health_parse_db_lookup(line, path, filename, value, &rt->group, &rt->after, &rt->before,
2078
- &rt->update_every,
2079
- &rt->options, &rt->dimensions);
2091
+ &rt->update_every, &rt->options, &rt->dimensions);
2092
}
2093
else if(hash == hash_every && !strcasecmp(key, HEALTH_EVERY_KEY)) {
2094
if(!health_parse_duration(value, &rt->update_every))
src/health.h
+3
@@ -232,6 +232,9 @@ typedef struct rrdcalctemplate {
232
char *context;
233
uint32_t hash_context;
234
235
+ char *family_match;
236
+ SIMPLE_PATTERN *family_pattern;
237
+
238
char *source; // the source of this alarm
239
char *units; // the units of the alarm
240
char *info; // a short description of the alarm
src/main.c
+4
-3
@@ -478,9 +478,10 @@ int main(int argc, char **argv)
478
const char *heystack = argv[optind];
479
const char *needle = argv[optind + 1];
480
481
- NETDATA_SIMPLE_PATTERN *p = netdata_simple_pattern_list_create(heystack, NETDATA_SIMPLE_PATTERN_MODE_EXACT);
482
- int ret = netdata_simple_pattern_list_matches(p, needle);
483
- netdata_simple_pattern_free(p);
481
+ SIMPLE_PATTERN *p = simple_pattern_create(heystack
482
+ , SIMPLE_PATTERN_EXACT);
483
+ int ret = simple_pattern_matches(p, needle);
484
+ simple_pattern_free(p);
485
486
if(ret) {
487
fprintf(stdout, "RESULT: MATCHED - pattern '%s' matches '%s'\n", heystack, needle);
src/plugin_proc_diskspace.c
+5
-5
@@ -32,23 +32,23 @@ static inline void do_disk_space_stats(struct mountinfo *mi, int update_every) {
32
const char *disk = mi->persistent_id;
33
34
static DICTIONARY *mount_points = NULL;
35
- static NETDATA_SIMPLE_PATTERN *excluded_mountpoints = NULL;
35
+ static SIMPLE_PATTERN *excluded_mountpoints = NULL;
36
int do_space, do_inodes;
37
38
if(unlikely(!mount_points)) {
39
const char *s;
40
- NETDATA_SIMPLE_PREFIX_MODE mode = NETDATA_SIMPLE_PATTERN_MODE_EXACT;
40
+ SIMPLE_PREFIX_MODE mode = SIMPLE_PATTERN_EXACT;
41
42
if(config_exists("plugin:proc:/proc/diskstats", "exclude space metrics on paths") && !config_exists("plugin:proc:diskspace", "exclude space metrics on paths")) {
43
// the config exists in the old section
44
s = config_get("plugin:proc:/proc/diskstats", "exclude space metrics on paths", DELAULT_EXLUDED_PATHS);
45
- mode = NETDATA_SIMPLE_PATTERN_MODE_PREFIX;
45
+ mode = SIMPLE_PATTERN_PREFIX;
46
}
47
else
48
s = config_get("plugin:proc:diskspace", "exclude space metrics on paths", DELAULT_EXLUDED_PATHS);
49
50
mount_points = dictionary_create(DICTIONARY_FLAG_SINGLE_THREADED);
51
- excluded_mountpoints = netdata_simple_pattern_list_create(s, mode);
51
+ excluded_mountpoints = simple_pattern_create(s, mode);
52
}
53
54
struct mount_point_metadata *m = dictionary_get(mount_points, mi->mount_point);
@@ -59,7 +59,7 @@ static inline void do_disk_space_stats(struct mountinfo *mi, int update_every) {
59
int def_space = config_get_boolean_ondemand("plugin:proc:diskspace", "space usage for all disks", CONFIG_ONDEMAND_ONDEMAND);
60
int def_inodes = config_get_boolean_ondemand("plugin:proc:diskspace", "inodes usage for all disks", CONFIG_ONDEMAND_ONDEMAND);
61
62
- if(unlikely(netdata_simple_pattern_list_matches(excluded_mountpoints, mi->mount_point))) {
62
+ if(unlikely(simple_pattern_matches(excluded_mountpoints, mi->mount_point))) {
63
def_space = CONFIG_ONDEMAND_NO;
64
def_inodes = CONFIG_ONDEMAND_NO;
65
}
src/proc_net_dev.c
+5
-3
@@ -112,7 +112,7 @@ static struct netdev *get_netdev(const char *name) {
112
int do_proc_net_dev(int update_every, usec_t dt) {
113
(void)dt;
114
115
- static NETDATA_SIMPLE_PATTERN *disabled_list = NULL;
115
+ static SIMPLE_PATTERN *disabled_list = NULL;
116
static procfile *ff = NULL;
117
static int enable_new_interfaces = -1;
118
static int do_bandwidth = -1, do_packets = -1, do_errors = -1, do_drops = -1, do_fifo = -1, do_compressed = -1, do_events = -1;
@@ -128,7 +128,9 @@ int do_proc_net_dev(int update_every, usec_t dt) {
128
do_compressed = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "compressed packets for all interfaces", CONFIG_ONDEMAND_ONDEMAND);
129
do_events = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "frames, collisions, carrier counters for all interfaces", CONFIG_ONDEMAND_ONDEMAND);
130
131
- disabled_list = netdata_simple_pattern_list_create(config_get("plugin:proc:/proc/net/dev", "disable by default interfaces matching", "lo fireqos* *-ifb"), NETDATA_SIMPLE_PATTERN_MODE_EXACT);
131
+ disabled_list = simple_pattern_create(
132
+ config_get("plugin:proc:/proc/net/dev", "disable by default interfaces matching", "lo fireqos* *-ifb")
133
+ , SIMPLE_PATTERN_EXACT);
134
}
135
136
if(unlikely(!ff)) {
@@ -157,7 +159,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
159
d->enabled = enable_new_interfaces;
160
161
if(d->enabled)
160
- d->enabled = !netdata_simple_pattern_list_matches(disabled_list, d->name);
162
+ d->enabled = !simple_pattern_matches(disabled_list, d->name);
163
164
char var_name[512 + 1];
165
snprintfz(var_name, 512, "plugin:proc:/proc/net/dev:%s", d->name);
src/simple_pattern.c
+17
-62
@@ -4,7 +4,7 @@ struct simple_pattern {
4
const char *match;
5
size_t len;
6
7
- NETDATA_SIMPLE_PREFIX_MODE mode;
7
+ SIMPLE_PREFIX_MODE mode;
8
char negative;
9
10
struct simple_pattern *child;
@@ -12,13 +12,8 @@ struct simple_pattern {
12
struct simple_pattern *next;
13
};
14
15
-static inline struct simple_pattern *parse_pattern(const char *str, NETDATA_SIMPLE_PREFIX_MODE default_mode) {
16
- /*
17
- * DEBUG
18
- info(">>>> PARSE: '%s'", str);
19
- */
20
-
21
- NETDATA_SIMPLE_PREFIX_MODE mode;
15
+static inline struct simple_pattern *parse_pattern(const char *str, SIMPLE_PREFIX_MODE default_mode) {
16
+ SIMPLE_PREFIX_MODE mode;
17
struct simple_pattern *child = NULL;
18
19
char *buf = strdupz(str);
@@ -43,15 +38,15 @@ static inline struct simple_pattern *parse_pattern(const char *str, NETDATA_SIMP
38
if(len >= 2 && *s == '*' && s[len - 1] == '*') {
39
s[len - 1] = '\0';
40
s++;
46
- mode = NETDATA_SIMPLE_PATTERN_MODE_SUBSTRING;
41
+ mode = SIMPLE_PATTERN_SUBSTRING;
42
}
43
else if(len >= 1 && *s == '*') {
44
s++;
50
- mode = NETDATA_SIMPLE_PATTERN_MODE_SUFFIX;
45
+ mode = SIMPLE_PATTERN_SUFFIX;
46
}
47
else if(len >= 1 && s[len - 1] == '*') {
48
s[len - 1] = '\0';
54
- mode = NETDATA_SIMPLE_PATTERN_MODE_PREFIX;
49
+ mode = SIMPLE_PATTERN_PREFIX;
50
}
51
else
52
mode = default_mode;
@@ -64,30 +59,17 @@ static inline struct simple_pattern *parse_pattern(const char *str, NETDATA_SIMP
59
m->mode = mode;
60
}
61
else {
67
- m->mode = NETDATA_SIMPLE_PATTERN_MODE_SUBSTRING;
62
+ m->mode = SIMPLE_PATTERN_SUBSTRING;
63
}
64
65
m->child = child;
66
67
freez(buf);
68
74
- /*
75
- * DEBUG
76
- info("PATTERN '%s' is composed by", str);
77
- struct simple_pattern *p;
78
- for(p = m; p ; p = p->child)
79
- info(">>>> COMPONENT: '%s%s%s' (len %zu type %u)",
80
- (p->mode == NETDATA_SIMPLE_PATTERN_MODE_SUFFIX || p->mode == NETDATA_SIMPLE_PATTERN_MODE_SUBSTRING)?"*":"",
81
- p->match,
82
- (p->mode == NETDATA_SIMPLE_PATTERN_MODE_PREFIX || p->mode == NETDATA_SIMPLE_PATTERN_MODE_SUBSTRING)?"*":"",
83
- p->len,
84
- p->mode);
85
- */
86
-
69
return m;
70
}
71
90
-NETDATA_SIMPLE_PATTERN *netdata_simple_pattern_list_create(const char *list, NETDATA_SIMPLE_PREFIX_MODE default_mode) {
72
+SIMPLE_PATTERN *simple_pattern_create(const char *list, SIMPLE_PREFIX_MODE default_mode) {
73
struct simple_pattern *root = NULL, *last = NULL;
74
75
if(unlikely(!list || !*list)) return root;
@@ -141,25 +123,15 @@ NETDATA_SIMPLE_PATTERN *netdata_simple_pattern_list_create(const char *list, NET
123
}
124
125
freez(buf);
144
- return (NETDATA_SIMPLE_PATTERN *)root;
126
+ return (SIMPLE_PATTERN *)root;
127
}
128
129
static inline int match_pattern(struct simple_pattern *m, const char *str, size_t len) {
148
- /*
149
- * DEBUG
150
- *
151
- info("CHECK string '%s' (len %zu) with pattern '%s%s%s' (len %zu type %u)", str, len,
152
- (m->mode == NETDATA_SIMPLE_PATTERN_MODE_SUFFIX || m->mode == NETDATA_SIMPLE_PATTERN_MODE_SUBSTRING)?"*":"",
153
- m->match,
154
- (m->mode == NETDATA_SIMPLE_PATTERN_MODE_PREFIX || m->mode == NETDATA_SIMPLE_PATTERN_MODE_SUBSTRING)?"*":"",
155
- m->len, m->mode);
156
- */
157
-
130
char *s;
131
132
if(m->len <= len) {
133
switch(m->mode) {
162
- case NETDATA_SIMPLE_PATTERN_MODE_SUBSTRING:
134
+ case SIMPLE_PATTERN_SUBSTRING:
135
if(!m->len) return 1;
136
if((s = strstr(str, m->match))) {
137
if(!m->child) return 1;
@@ -167,21 +139,21 @@ static inline int match_pattern(struct simple_pattern *m, const char *str, size_
139
}
140
break;
141
170
- case NETDATA_SIMPLE_PATTERN_MODE_PREFIX:
142
+ case SIMPLE_PATTERN_PREFIX:
143
if(unlikely(strncmp(str, m->match, m->len) == 0)) {
144
if(!m->child) return 1;
145
return match_pattern(m->child, &str[m->len], len - m->len);
146
}
147
break;
148
177
- case NETDATA_SIMPLE_PATTERN_MODE_SUFFIX:
149
+ case SIMPLE_PATTERN_SUFFIX:
150
if(unlikely(strcmp(&str[len - m->len], m->match) == 0)) {
151
if(!m->child) return 1;
152
return 0;
153
}
154
break;
155
184
- case NETDATA_SIMPLE_PATTERN_MODE_EXACT:
156
+ case SIMPLE_PATTERN_EXACT:
157
default:
158
if(unlikely(strcmp(str, m->match) == 0)) {
159
if(!m->child) return 1;
@@ -194,7 +166,7 @@ static inline int match_pattern(struct simple_pattern *m, const char *str, size_
166
return 0;
167
}
168
197
-int netdata_simple_pattern_list_matches(NETDATA_SIMPLE_PATTERN *list, const char *str) {
169
+int simple_pattern_matches(SIMPLE_PATTERN *list, const char *str) {
170
struct simple_pattern *m, *root = (struct simple_pattern *)list;
171
172
if(unlikely(!root)) return 0;
@@ -202,25 +174,6 @@ int netdata_simple_pattern_list_matches(NETDATA_SIMPLE_PATTERN *list, const char
174
size_t len = strlen(str);
175
for(m = root; m ; m = m->next)
176
if(match_pattern(m, str, len)) {
205
- /*
206
- * DEBUG
207
- *
208
- info("MATCHED string '%s' (len %zu) with pattern '%s%s%s' (len %zu type %u)", str, len,
209
- (m->mode == NETDATA_SIMPLE_PATTERN_MODE_SUFFIX || m->mode == NETDATA_SIMPLE_PATTERN_MODE_SUBSTRING)?"*":"",
210
- m->match,
211
- (m->mode == NETDATA_SIMPLE_PATTERN_MODE_PREFIX || m->mode == NETDATA_SIMPLE_PATTERN_MODE_SUBSTRING)?"*":"",
212
- m->len, m->mode);
213
-
214
- struct simple_pattern *p;
215
- for(p = m; p ; p = p->child)
216
- info(">>>> MATCHED COMPONENT: '%s%s%s' (len %zu type %u)",
217
- (p->mode == NETDATA_SIMPLE_PATTERN_MODE_SUFFIX || p->mode == NETDATA_SIMPLE_PATTERN_MODE_SUBSTRING)?"*":"",
218
- p->match,
219
- (p->mode == NETDATA_SIMPLE_PATTERN_MODE_PREFIX || p->mode == NETDATA_SIMPLE_PATTERN_MODE_SUBSTRING)?"*":"",
220
- p->len,
221
- p->mode);
222
- */
223
-
177
if(m->negative) return 0;
178
return 1;
179
}
@@ -237,6 +190,8 @@ static inline void free_pattern(struct simple_pattern *m) {
190
freez(m);
191
}
192
240
-void netdata_simple_pattern_free(NETDATA_SIMPLE_PATTERN *list) {
193
+void simple_pattern_free(SIMPLE_PATTERN *list) {
194
+ if(!list) return;
195
+
196
free_pattern(((struct simple_pattern *)list)->next);
197
}
src/simple_pattern.h
+18
-9
@@ -2,15 +2,24 @@
2
#define NETDATA_SIMPLE_PATTERN_H
3
4
typedef enum {
5
- NETDATA_SIMPLE_PATTERN_MODE_EXACT,
6
- NETDATA_SIMPLE_PATTERN_MODE_PREFIX,
7
- NETDATA_SIMPLE_PATTERN_MODE_SUFFIX,
8
- NETDATA_SIMPLE_PATTERN_MODE_SUBSTRING
9
-} NETDATA_SIMPLE_PREFIX_MODE;
5
+ SIMPLE_PATTERN_EXACT,
6
+ SIMPLE_PATTERN_PREFIX,
7
+ SIMPLE_PATTERN_SUFFIX,
8
+ SIMPLE_PATTERN_SUBSTRING
9
+} SIMPLE_PREFIX_MODE;
10
11
-typedef void NETDATA_SIMPLE_PATTERN;
12
-extern NETDATA_SIMPLE_PATTERN *netdata_simple_pattern_list_create(const char *list, NETDATA_SIMPLE_PREFIX_MODE default_mode);
13
-extern int netdata_simple_pattern_list_matches(NETDATA_SIMPLE_PATTERN *list, const char *str);
14
-extern void netdata_simple_pattern_free(NETDATA_SIMPLE_PATTERN *list);
11
+typedef void SIMPLE_PATTERN;
12
+
13
+// create a simple_pattern from the string given
14
+// default_mode is used in cases where EXACT matches, without an asterisk,
15
+// should be considered PREFIX matches.
16
+extern SIMPLE_PATTERN *simple_pattern_create(const char *list, SIMPLE_PREFIX_MODE default_mode);
17
+
18
+// test if string str is matched from the pattern
19
+extern int simple_pattern_matches(SIMPLE_PATTERN *list, const char *str);
20
+
21
+// free a simple_pattern that was created with simple_pattern_create()
22
+// list can be NULL, in which case, this does nothing.
23
+extern void simple_pattern_free(SIMPLE_PATTERN *list);
24
25
#endif //NETDATA_SIMPLE_PATTERN_H
src/sys_fs_cgroup.c
+30
-32
@@ -22,10 +22,10 @@ static int cgroup_root_count = 0;
22
static int cgroup_root_max = 500;
23
static int cgroup_max_depth = 0;
24
25
-static NETDATA_SIMPLE_PATTERN *disabled_cgroups_patterns = NULL;
26
-static NETDATA_SIMPLE_PATTERN *disabled_cgroup_paths = NULL;
27
-static NETDATA_SIMPLE_PATTERN *disabled_cgroup_renames = NULL;
28
-static NETDATA_SIMPLE_PATTERN *systemd_services_cgroups = NULL;
25
+static SIMPLE_PATTERN *disabled_cgroups_patterns = NULL;
26
+static SIMPLE_PATTERN *disabled_cgroup_paths = NULL;
27
+static SIMPLE_PATTERN *disabled_cgroup_renames = NULL;
28
+static SIMPLE_PATTERN *systemd_services_cgroups = NULL;
29
30
static char *cgroups_rename_script = PLUGINS_DIR "/cgroup-name.sh";
31
@@ -93,9 +93,8 @@ void read_cgroup_plugin_configuration() {
93
94
cgroup_enable_new_cgroups_detected_at_runtime = config_get_boolean("plugin:cgroups", "enable new cgroups detected at run time", cgroup_enable_new_cgroups_detected_at_runtime);
95
96
- disabled_cgroups_patterns = netdata_simple_pattern_list_create(
97
- config_get("plugin:cgroups", "disable by default cgroups matching",
98
- " *.mount "
96
+ disabled_cgroups_patterns = simple_pattern_create(
97
+ config_get("plugin:cgroups", "disable by default cgroups matching", " *.mount "
98
" *.partition "
99
" *.service "
100
" *.slice "
@@ -115,23 +114,22 @@ void read_cgroup_plugin_configuration() {
114
" /systemd "
115
" /user "
116
" /user.slice "
118
- ), NETDATA_SIMPLE_PATTERN_MODE_EXACT);
119
-
120
- disabled_cgroup_paths = netdata_simple_pattern_list_create(
121
- config_get("plugin:cgroups", "do not search for cgroups in paths matching",
122
- " *-qemu " // #345
123
- " /init.scope "
124
- " /system "
125
- " /systemd "
126
- " /user "
127
- " /user.slice "
128
- ), NETDATA_SIMPLE_PATTERN_MODE_EXACT);
117
+ ), SIMPLE_PATTERN_EXACT);
118
+
119
+ disabled_cgroup_paths = simple_pattern_create(
120
+ config_get("plugin:cgroups", "do not search for cgroups in paths matching"
121
+ , " *-qemu " // #345
122
+ " /init.scope "
123
+ " /system "
124
+ " /systemd "
125
+ " /user "
126
+ " /user.slice "
127
+ ), SIMPLE_PATTERN_EXACT);
128
129
cgroups_rename_script = config_get("plugin:cgroups", "script to get cgroup names", cgroups_rename_script);
130
132
- disabled_cgroup_renames = netdata_simple_pattern_list_create(
133
- config_get("plugin:cgroups", "do not run script to rename cgroups matching",
134
- " / "
131
+ disabled_cgroup_renames = simple_pattern_create(
132
+ config_get("plugin:cgroups", "do not run script to rename cgroups matching", " / "
133
" *.mount "
134
" *.partition "
135
" *.scope "
@@ -139,13 +137,13 @@ void read_cgroup_plugin_configuration() {
137
" *.slice "
138
" *.swap "
139
" *.user "
142
- ), NETDATA_SIMPLE_PATTERN_MODE_EXACT);
140
+ ), SIMPLE_PATTERN_EXACT);
141
142
if(cgroup_enable_systemd_services)
145
- systemd_services_cgroups = netdata_simple_pattern_list_create(
146
- config_get("plugin:cgroups", "cgroups to match as systemd services",
147
- " !/system.slice/*/*.service /system.slice/*.service "
148
- ), NETDATA_SIMPLE_PATTERN_MODE_EXACT);
143
+ systemd_services_cgroups = simple_pattern_create(
144
+ config_get("plugin:cgroups", "cgroups to match as systemd services"
145
+ , " !/system.slice/*/*.service /system.slice/*.service "
146
+ ), SIMPLE_PATTERN_EXACT);
147
148
mountinfo_free(root);
149
}
@@ -776,7 +774,7 @@ struct cgroup *cgroup_add(const char *id) {
774
return NULL;
775
}
776
779
- int def = netdata_simple_pattern_list_matches(disabled_cgroups_patterns, id)?0:cgroup_enable_new_cgroups_detected_at_runtime;
777
+ int def = simple_pattern_matches(disabled_cgroups_patterns, id)?0:cgroup_enable_new_cgroups_detected_at_runtime;
778
struct cgroup *cg = callocz(1, sizeof(struct cgroup));
779
780
cg->id = strdupz(id);
@@ -799,8 +797,8 @@ struct cgroup *cgroup_add(const char *id) {
797
cgroup_root_count++;
798
799
// fix the chart_id and title by calling the external script
802
- if(!netdata_simple_pattern_list_matches(disabled_cgroup_renames, cg->id) &&
803
- !netdata_simple_pattern_list_matches(disabled_cgroup_renames, cg->chart_id)) {
800
+ if(!simple_pattern_matches(disabled_cgroup_renames, cg->id) &&
801
+ !simple_pattern_matches(disabled_cgroup_renames, cg->chart_id)) {
802
803
cgroup_get_chart_name(cg);
804
@@ -813,8 +811,8 @@ struct cgroup *cgroup_add(const char *id) {
811
812
// check if this cgroup should be a systemd service
813
if(cgroup_enable_systemd_services) {
816
- if(netdata_simple_pattern_list_matches(systemd_services_cgroups, cg->id) ||
817
- netdata_simple_pattern_list_matches(systemd_services_cgroups, cg->chart_id)) {
814
+ if(simple_pattern_matches(systemd_services_cgroups, cg->id) ||
815
+ simple_pattern_matches(systemd_services_cgroups, cg->chart_id)) {
816
debug(D_CGROUP, "cgroup '%s' with chart id '%s' (title: '%s') matches systemd services cgroups", cg->id, cg->chart_id, cg->chart_title);
817
818
char buffer[CGROUP_CHARTID_LINE_MAX + 1];
@@ -1001,7 +999,7 @@ int find_dir_in_subdirs(const char *base, const char *this, void (*callback)(con
999
1000
// do not decent in directories we are not interested
1001
int def = 1;
1004
- if(netdata_simple_pattern_list_matches(disabled_cgroup_paths, r))
1002
+ if(simple_pattern_matches(disabled_cgroup_paths, r))
1003
def = 0;
1004
1005
// we check for this option here