added btrfs filesystem monitoring; fixes #3095
Costa Tsaousis (ktsaou) committed
Dec 17, 2017 at 23:58 UTC
6d13fa0727febc0483b2e87ce5f13c12d48e7040
10 files changed
+582
-46
CMakeLists.txt
+1
-1
@@ -63,7 +63,7 @@ set(NETDATA_LINUX_FILES
63
src/proc_uptime.c
64
src/sys_kernel_mm_ksm.c
65
src/sys_fs_cgroup.c
66
- )
66
+ src/sys_fs_btrfs.c)
67
68
set(NETDATA_COMMON_FILES
69
src/adaptive_resortable_list.c
src/Makefile.am
+9
-8
@@ -79,16 +79,10 @@ netdata_SOURCES = \
79
plugin_checks.h \
80
plugin_idlejitter.c \
81
plugin_idlejitter.h \
82
- plugin_nfacct.c \
83
- plugin_nfacct.h \
84
- plugin_tc.c \
85
- plugin_tc.h \
82
plugins_d.c \
83
plugins_d.h \
84
popen.c \
85
popen.h \
90
- proc_self_mountinfo.c \
91
- proc_self_mountinfo.h \
86
procfile.c \
87
procfile.h \
88
registry.c \
@@ -133,8 +127,6 @@ netdata_SOURCES = \
127
statsd.h \
128
storage_number.c \
129
storage_number.h \
136
- sys_devices_system_edac_mc.c \
137
- sys_devices_system_node.c \
130
unit_test.c \
131
unit_test.h \
132
url.c \
@@ -179,10 +171,14 @@ else
171
netdata_SOURCES += \
172
ipc.c \
173
ipc.h \
174
+ plugin_nfacct.c \
175
+ plugin_nfacct.h \
176
plugin_proc.c \
177
plugin_proc.h \
178
plugin_proc_diskspace.c \
179
plugin_proc_diskspace.h \
180
+ plugin_tc.c \
181
+ plugin_tc.h \
182
proc_diskstats.c \
183
proc_interrupts.c \
184
proc_softirqs.c \
@@ -200,6 +196,8 @@ netdata_SOURCES += \
196
proc_net_softnet_stat.c \
197
proc_net_stat_conntrack.c \
198
proc_net_stat_synproxy.c \
199
+ proc_self_mountinfo.c \
200
+ proc_self_mountinfo.h \
201
zfs_common.c \
202
zfs_common.h \
203
proc_spl_kstat_zfs.c \
@@ -208,7 +206,10 @@ netdata_SOURCES += \
206
proc_vmstat.c \
207
proc_uptime.c \
208
sys_kernel_mm_ksm.c \
209
+ sys_devices_system_edac_mc.c \
210
+ sys_devices_system_node.c \
211
sys_fs_cgroup.c \
212
+ sys_fs_btrfs.c \
213
$(NULL)
214
endif
215
endif
src/plugin_proc.c
+3
@@ -54,6 +54,9 @@ static struct proc_module {
54
// ZFS metrics
55
{ .name = "/proc/spl/kstat/zfs/arcstats", .dim = "zfs_arcstats", .func = do_proc_spl_kstat_zfs_arcstats },
56
57
+ // BTRFS metrics
58
+ { .name = "/sys/fs/btrfs", .dim = "btrfs", .func = do_sys_fs_btrfs },
59
+
60
// IPC metrics
61
{ .name = "ipc", .dim = "ipc", .func = do_ipc },
62
src/plugin_proc.h
+1
@@ -26,6 +26,7 @@ extern int do_proc_uptime(int update_every, usec_t dt);
26
extern int do_proc_sys_devices_system_edac_mc(int update_every, usec_t dt);
27
extern int do_proc_sys_devices_system_node(int update_every, usec_t dt);
28
extern int do_proc_spl_kstat_zfs_arcstats(int update_every, usec_t dt);
29
+extern int do_sys_fs_btrfs(int update_every, usec_t dt);
30
extern int do_proc_net_sockstat(int update_every, usec_t dt);
31
extern int do_proc_net_sockstat6(int update_every, usec_t dt);
32
src/proc_net_rpc_nfs.c
+5
-5
@@ -288,7 +288,7 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) {
288
, "operations/s"
289
, "proc"
290
, "net/rpc/nfs"
291
- , 5007
291
+ , 2207
292
, update_every
293
, RRDSET_TYPE_STACKED
294
);
@@ -328,7 +328,7 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) {
328
, "calls/s"
329
, "proc"
330
, "net/rpc/nfs"
331
- , 5008
331
+ , 2208
332
, update_every
333
, RRDSET_TYPE_LINE
334
);
@@ -361,7 +361,7 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) {
361
, "calls/s"
362
, "proc"
363
, "net/rpc/nfs"
364
- , 5009
364
+ , 2209
365
, update_every
366
, RRDSET_TYPE_STACKED
367
);
@@ -394,7 +394,7 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) {
394
, "calls/s"
395
, "proc"
396
, "net/rpc/nfs"
397
- , 5010
397
+ , 2210
398
, update_every
399
, RRDSET_TYPE_STACKED
400
);
@@ -427,7 +427,7 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) {
427
, "calls/s"
428
, "proc"
429
, "net/rpc/nfs"
430
- , 5011
430
+ , 2211
431
, update_every
432
, RRDSET_TYPE_STACKED
433
);
src/proc_net_rpc_nfsd.c
+13
-13
@@ -517,7 +517,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
517
, "reads/s"
518
, "proc"
519
, "net/rpc/nfsd"
520
- , 5000
520
+ , 2100
521
, update_every
522
, RRDSET_TYPE_STACKED
523
);
@@ -555,7 +555,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
555
, "handles/s"
556
, "proc"
557
, "net/rpc/nfsd"
558
- , 5001
558
+ , 2101
559
, update_every
560
, RRDSET_TYPE_LINE
561
);
@@ -595,7 +595,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
595
, "kilobytes/s"
596
, "proc"
597
, "net/rpc/nfsd"
598
- , 5002
598
+ , 2102
599
, update_every
600
, RRDSET_TYPE_AREA
601
);
@@ -628,7 +628,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
628
, "threads"
629
, "proc"
630
, "net/rpc/nfsd"
631
- , 5003
631
+ , 2103
632
, update_every
633
, RRDSET_TYPE_LINE
634
);
@@ -656,7 +656,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
656
, "ops/s"
657
, "proc"
658
, "net/rpc/nfsd"
659
- , 5004
659
+ , 2104
660
, update_every
661
, RRDSET_TYPE_LINE
662
);
@@ -693,7 +693,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
693
, "percentage"
694
, "proc"
695
, "net/rpc/nfsd"
696
- , 5005
696
+ , 2105
697
, update_every
698
, RRDSET_TYPE_LINE
699
);
@@ -752,7 +752,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
752
, "percentage"
753
, "proc"
754
, "net/rpc/nfsd"
755
- , 5005
755
+ , 2105
756
, update_every
757
, RRDSET_TYPE_STACKED
758
);
@@ -806,7 +806,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
806
, "packets/s"
807
, "proc"
808
, "net/rpc/nfsd"
809
- , 5007
809
+ , 2107
810
, update_every
811
, RRDSET_TYPE_STACKED
812
);
@@ -845,7 +845,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
845
, "calls/s"
846
, "proc"
847
, "net/rpc/nfsd"
848
- , 5008
848
+ , 2108
849
, update_every
850
, RRDSET_TYPE_LINE
851
);
@@ -881,7 +881,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
881
, "calls/s"
882
, "proc"
883
, "net/rpc/nfsd"
884
- , 5009
884
+ , 2109
885
, update_every
886
, RRDSET_TYPE_STACKED
887
);
@@ -914,7 +914,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
914
, "calls/s"
915
, "proc"
916
, "net/rpc/nfsd"
917
- , 5010
917
+ , 2110
918
, update_every
919
, RRDSET_TYPE_STACKED
920
);
@@ -947,7 +947,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
947
, "calls/s"
948
, "proc"
949
, "net/rpc/nfsd"
950
- , 5011
950
+ , 2111
951
, update_every
952
, RRDSET_TYPE_STACKED
953
);
@@ -980,7 +980,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
980
, "operations/s"
981
, "proc"
982
, "net/rpc/nfsd"
983
- , 5012
983
+ , 2112
984
, update_every
985
, RRDSET_TYPE_STACKED
986
);
src/sys_fs_btrfs.c
new
+525
@@ -0,0 +1,525 @@
1
+#include "common.h"
2
+
3
+#define BTRFS_MAX_ID_LENGTH 50
4
+#define BTRFS_MAX_LABEL_LENGTH 200
5
+
6
+typedef struct btrfs_node {
7
+ int exists;
8
+
9
+ char id[BTRFS_MAX_ID_LENGTH + 1];
10
+ uint32_t hash;
11
+
12
+ char label[BTRFS_MAX_LABEL_LENGTH + 1];
13
+
14
+ unsigned long long int sectorsize;
15
+ unsigned long long int nodesize;
16
+ unsigned long long int quota_override;
17
+
18
+ #define declare_btrfs_allocation_section_field(SECTION, FIELD) \
19
+ char *allocation_ ## SECTION ## _ ## FIELD ## _filename; \
20
+ unsigned long long int allocation_ ## SECTION ## _ ## FIELD; \
21
+ RRDDIM *rd_allocation_ ## SECTION ## _ ## FIELD;
22
+
23
+ #define declare_btrfs_allocation_field(FIELD) \
24
+ char *allocation_ ## FIELD ## _filename; \
25
+ unsigned long long int allocation_ ## FIELD; \
26
+ RRDDIM *rd_allocation_ ## FIELD;
27
+
28
+ RRDSET *st_allocation_system;
29
+ declare_btrfs_allocation_section_field(system, total_bytes)
30
+ declare_btrfs_allocation_section_field(system, bytes_used)
31
+ declare_btrfs_allocation_section_field(system, disk_total)
32
+ declare_btrfs_allocation_section_field(system, disk_used)
33
+
34
+ RRDSET *st_allocation_data;
35
+ declare_btrfs_allocation_section_field(data, total_bytes)
36
+ declare_btrfs_allocation_section_field(data, bytes_used)
37
+ declare_btrfs_allocation_section_field(data, disk_total)
38
+ declare_btrfs_allocation_section_field(data, disk_used)
39
+
40
+ RRDSET *st_allocation_metadata;
41
+ declare_btrfs_allocation_section_field(metadata, total_bytes)
42
+ declare_btrfs_allocation_section_field(metadata, bytes_used)
43
+ declare_btrfs_allocation_section_field(metadata, disk_total)
44
+ declare_btrfs_allocation_section_field(metadata, disk_used)
45
+
46
+ RRDSET *st_allocation_global_rsv;
47
+ declare_btrfs_allocation_field(global_rsv_reserved)
48
+ declare_btrfs_allocation_field(global_rsv_size)
49
+
50
+ struct btrfs_node *next;
51
+} BTRFS_NODE;
52
+
53
+static BTRFS_NODE *nodes = NULL;
54
+
55
+static inline void btrfs_free_node(BTRFS_NODE *node) {
56
+ // info("BTRFS: destroying '%s'", node->id);
57
+
58
+ if(node->st_allocation_system)
59
+ rrdset_is_obsolete(node->st_allocation_system);
60
+
61
+ if(node->st_allocation_data)
62
+ rrdset_is_obsolete(node->st_allocation_data);
63
+
64
+ if(node->st_allocation_metadata)
65
+ rrdset_is_obsolete(node->st_allocation_metadata);
66
+
67
+ freez(node->allocation_system_bytes_used_filename);
68
+ freez(node->allocation_system_total_bytes_filename);
69
+
70
+ freez(node->allocation_data_bytes_used_filename);
71
+ freez(node->allocation_data_total_bytes_filename);
72
+
73
+ freez(node->allocation_metadata_bytes_used_filename);
74
+ freez(node->allocation_metadata_total_bytes_filename);
75
+
76
+ freez(node);
77
+}
78
+
79
+static inline int find_all_btrfs_pools(const char *path) {
80
+ static int logged_error = 0;
81
+ char filename[FILENAME_MAX + 1];
82
+
83
+ BTRFS_NODE *node;
84
+ for(node = nodes ; node ; node = node->next)
85
+ node->exists = 0;
86
+
87
+ DIR *dir = opendir(path);
88
+ if (!dir) {
89
+ if(!logged_error) {
90
+ error("BTRFS: Cannot open directory '%s'.", path);
91
+ logged_error = 1;
92
+ }
93
+ return 1;
94
+ }
95
+ logged_error = 0;
96
+
97
+ struct dirent *de = NULL;
98
+ while ((de = readdir(dir))) {
99
+ if(de->d_type != DT_DIR
100
+ || !strcmp(de->d_name, ".")
101
+ || !strcmp(de->d_name, "..")
102
+ || !strcmp(de->d_name, "features")
103
+ ) {
104
+ // info("BTRFS: ignoring '%s'", de->d_name);
105
+ continue;
106
+ }
107
+
108
+ uint32_t hash = simple_hash(de->d_name);
109
+
110
+ // search for it
111
+ for(node = nodes ; node ; node = node->next) {
112
+ if(hash == node->hash && !strcmp(de->d_name, node->id))
113
+ break;
114
+ }
115
+
116
+ // did we find it?
117
+ if(node) {
118
+ // info("BTRFS: already exists '%s'", de->d_name);
119
+ node->exists = 1;
120
+ break;
121
+ }
122
+
123
+ // info("BTRFS: adding '%s'", de->d_name);
124
+
125
+ // not found, create it
126
+ node = callocz(sizeof(BTRFS_NODE), 1);
127
+
128
+ strncpyz(node->id, de->d_name, BTRFS_MAX_ID_LENGTH);
129
+ node->hash = simple_hash(node->id);
130
+ node->exists = 1;
131
+
132
+ snprintfz(filename, FILENAME_MAX, "%s/%s/label", path, de->d_name);
133
+ if(read_file(filename, node->label, sizeof(node->label)) != 0) {
134
+ error("BTRFS: failed to read '%s'", filename);
135
+ btrfs_free_node(node);
136
+ continue;
137
+ }
138
+ if(!node->label[0])
139
+ strncpyz(node->label, node->id, BTRFS_MAX_LABEL_LENGTH);
140
+
141
+ snprintfz(filename, FILENAME_MAX, "%s/%s/sectorsize", path, de->d_name);
142
+ if(read_single_number_file(filename, &node->sectorsize) != 0) {
143
+ error("BTRFS: failed to read '%s'", filename);
144
+ btrfs_free_node(node);
145
+ continue;
146
+ }
147
+
148
+ snprintfz(filename, FILENAME_MAX, "%s/%s/nodesize", path, de->d_name);
149
+ if(read_single_number_file(filename, &node->nodesize) != 0) {
150
+ error("BTRFS: failed to read '%s'", filename);
151
+ btrfs_free_node(node);
152
+ continue;
153
+ }
154
+
155
+ snprintfz(filename, FILENAME_MAX, "%s/%s/quota_override", path, de->d_name);
156
+ if(read_single_number_file(filename, &node->quota_override) != 0) {
157
+ error("BTRFS: failed to read '%s'", filename);
158
+ btrfs_free_node(node);
159
+ continue;
160
+ }
161
+
162
+ // --------------------------------------------------------------------
163
+ // macros to simplify our life
164
+
165
+ #define init_btrfs_allocation_field(FIELD) {\
166
+ snprintfz(filename, FILENAME_MAX, "%s/%s/allocation/" #FIELD, path, de->d_name); \
167
+ if(read_single_number_file(filename, &node->allocation_ ## FIELD) != 0) {\
168
+ error("BTRFS: failed to read '%s'", filename);\
169
+ btrfs_free_node(node);\
170
+ continue;\
171
+ }\
172
+ if(!node->allocation_ ## FIELD ## _filename)\
173
+ node->allocation_ ## FIELD ## _filename = strdupz(filename);\
174
+ }
175
+
176
+ #define init_btrfs_allocation_section_field(SECTION, FIELD) {\
177
+ snprintfz(filename, FILENAME_MAX, "%s/%s/allocation/" #SECTION "/" #FIELD, path, de->d_name); \
178
+ if(read_single_number_file(filename, &node->allocation_ ## SECTION ## _ ## FIELD) != 0) {\
179
+ error("BTRFS: failed to read '%s'", filename);\
180
+ btrfs_free_node(node);\
181
+ continue;\
182
+ }\
183
+ if(!node->allocation_ ## SECTION ## _ ## FIELD ## _filename)\
184
+ node->allocation_ ## SECTION ## _ ## FIELD ## _filename = strdupz(filename);\
185
+ }
186
+
187
+ // --------------------------------------------------------------------
188
+ // allocation/data
189
+
190
+ init_btrfs_allocation_section_field(data, total_bytes);
191
+ init_btrfs_allocation_section_field(data, bytes_used);
192
+ init_btrfs_allocation_section_field(data, disk_total);
193
+ init_btrfs_allocation_section_field(data, disk_used);
194
+
195
+ // --------------------------------------------------------------------
196
+ // allocation/metadata
197
+
198
+ init_btrfs_allocation_section_field(metadata, total_bytes);
199
+ init_btrfs_allocation_section_field(metadata, bytes_used);
200
+ init_btrfs_allocation_section_field(metadata, disk_total);
201
+ init_btrfs_allocation_section_field(metadata, disk_used);
202
+
203
+
204
+ // --------------------------------------------------------------------
205
+ // allocation/system
206
+
207
+ init_btrfs_allocation_section_field(system, total_bytes);
208
+ init_btrfs_allocation_section_field(system, bytes_used);
209
+ init_btrfs_allocation_section_field(system, disk_total);
210
+ init_btrfs_allocation_section_field(system, disk_used);
211
+
212
+
213
+ // --------------------------------------------------------------------
214
+ // allocation/global_rsv
215
+
216
+ init_btrfs_allocation_field(global_rsv_size);
217
+ init_btrfs_allocation_field(global_rsv_reserved);
218
+
219
+
220
+ // --------------------------------------------------------------------
221
+ // link it
222
+
223
+ // info("BTRFS: linking '%s'", node->id);
224
+ node->next = nodes;
225
+ nodes = node;
226
+ }
227
+ closedir(dir);
228
+
229
+
230
+ // ------------------------------------------------------------------------
231
+ // cleanup
232
+
233
+ BTRFS_NODE *last = NULL;
234
+ node = nodes;
235
+
236
+ while(node) {
237
+ if(unlikely(!node->exists)) {
238
+ if(unlikely(nodes == node)) {
239
+ nodes = node->next;
240
+ btrfs_free_node(node);
241
+ node = nodes;
242
+ last = NULL;
243
+ }
244
+ else {
245
+ last->next = node->next;
246
+ btrfs_free_node(node);
247
+ node = last->next;
248
+ }
249
+
250
+ continue;
251
+ }
252
+
253
+ last = node;
254
+ node = node->next;
255
+ }
256
+
257
+ return 0;
258
+}
259
+
260
+int do_sys_fs_btrfs(int update_every, usec_t dt) {
261
+ static int initialized = 0, do_allocation_system = 1, do_allocation_data = 1, do_allocation_metadata = 1, do_allocation_global_rsv = 1;
262
+ static usec_t refresh_delta = 0, refresh_every = 60 * USEC_PER_SEC;
263
+ static char *btrfs_path = NULL;
264
+
265
+ (void)dt;
266
+
267
+ if(unlikely(!initialized)) {
268
+ initialized = 1;
269
+
270
+ char filename[FILENAME_MAX + 1];
271
+ snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/fs/btrfs");
272
+ btrfs_path = config_get("plugin:proc:/sys/fs/btrfs", "path to monitor", filename);
273
+
274
+ refresh_every = config_get_number("plugin:proc:/sys/fs/btrfs", "check for btrfs changes every", refresh_every / USEC_PER_SEC) * USEC_PER_SEC;
275
+ refresh_delta = refresh_every;
276
+
277
+ do_allocation_data = config_get_boolean_ondemand("plugin:proc:/sys/fs/btrfs", "data allocation", CONFIG_BOOLEAN_AUTO);
278
+ do_allocation_metadata = config_get_boolean_ondemand("plugin:proc:/sys/fs/btrfs", "metadata allocation", CONFIG_BOOLEAN_AUTO);
279
+ do_allocation_system = config_get_boolean_ondemand("plugin:proc:/sys/fs/btrfs", "system allocation", CONFIG_BOOLEAN_AUTO);
280
+ do_allocation_global_rsv = config_get_boolean_ondemand("plugin:proc:/sys/fs/btrfs", "global reserve", CONFIG_BOOLEAN_AUTO);
281
+ }
282
+
283
+ refresh_delta += dt;
284
+ if(refresh_delta >= refresh_every) {
285
+ refresh_delta = 0;
286
+ find_all_btrfs_pools(btrfs_path);
287
+ }
288
+
289
+ BTRFS_NODE *node;
290
+ for(node = nodes; node ; node = node->next) {
291
+ // --------------------------------------------------------------------
292
+ // allocation/system
293
+
294
+ #define collect_btrfs_allocation_field(FIELD) \
295
+ read_single_number_file(node->allocation_ ## FIELD ## _filename, &node->allocation_ ## FIELD)
296
+
297
+ #define collect_btrfs_allocation_section_field(SECTION, FIELD) \
298
+ read_single_number_file(node->allocation_ ## SECTION ## _ ## FIELD ## _filename, &node->allocation_ ## SECTION ## _ ## FIELD)
299
+
300
+ if(do_allocation_data != CONFIG_BOOLEAN_NO) {
301
+ if (collect_btrfs_allocation_section_field(data, total_bytes) != 0
302
+ || collect_btrfs_allocation_section_field(data, bytes_used) != 0
303
+ || collect_btrfs_allocation_section_field(data, disk_total) != 0
304
+ || collect_btrfs_allocation_section_field(data, disk_used) != 0) {
305
+ error("BTRFS: failed to collect allocation/data for '%s'", node->id);
306
+ // make it refresh btrfs at the next iteration
307
+ refresh_delta = refresh_every;
308
+ continue;
309
+ }
310
+ }
311
+
312
+ if(do_allocation_metadata != CONFIG_BOOLEAN_NO) {
313
+ if (collect_btrfs_allocation_section_field(metadata, total_bytes) != 0
314
+ || collect_btrfs_allocation_section_field(metadata, bytes_used) != 0
315
+ || collect_btrfs_allocation_section_field(metadata, disk_total) != 0
316
+ || collect_btrfs_allocation_section_field(metadata, disk_used) != 0) {
317
+ error("BTRFS: failed to collect allocation/metadata for '%s'", node->id);
318
+ // make it refresh btrfs at the next iteration
319
+ refresh_delta = refresh_every;
320
+ continue;
321
+ }
322
+ }
323
+
324
+ if(do_allocation_system != CONFIG_BOOLEAN_NO) {
325
+ if (collect_btrfs_allocation_section_field(system, total_bytes) != 0
326
+ || collect_btrfs_allocation_section_field(system, bytes_used) != 0
327
+ || collect_btrfs_allocation_section_field(system, disk_total) != 0
328
+ || collect_btrfs_allocation_section_field(system, disk_used) != 0) {
329
+ error("BTRFS: failed to collect allocation/system for '%s'", node->id);
330
+ // make it refresh btrfs at the next iteration
331
+ refresh_delta = refresh_every;
332
+ continue;
333
+ }
334
+ }
335
+
336
+ if(do_allocation_global_rsv != CONFIG_BOOLEAN_NO) {
337
+ if(collect_btrfs_allocation_field(global_rsv_reserved) != 0
338
+ || collect_btrfs_allocation_field(global_rsv_size) != 0) {
339
+ error("BTRFS: failed to collect global reserve for '%s'", node->id);
340
+ // make it refresh btrfs at the next iteration
341
+ refresh_delta = refresh_every;
342
+ continue;
343
+ }
344
+ }
345
+
346
+ // --------------------------------------------------------------------
347
+ // allocation/data
348
+
349
+ if(do_allocation_data == CONFIG_BOOLEAN_YES || (do_allocation_data == CONFIG_BOOLEAN_AUTO && (node->allocation_data_total_bytes || node->allocation_data_bytes_used))) {
350
+ do_allocation_data = CONFIG_BOOLEAN_YES;
351
+
352
+ if(unlikely(!node->st_allocation_data)) {
353
+ char id[RRD_ID_LENGTH_MAX + 1], name[RRD_ID_LENGTH_MAX + 1], title[200 + 1];
354
+
355
+ snprintf(id, RRD_ID_LENGTH_MAX, "data_bytes_%s", node->id);
356
+ snprintf(name, RRD_ID_LENGTH_MAX, "data_bytes_%s", node->label);
357
+ snprintf(title, 200, "BTRFS Data Allocation for %s", node->label);
358
+
359
+ netdata_fix_chart_id(id);
360
+ netdata_fix_chart_name(name);
361
+
362
+ node->st_allocation_data = rrdset_create_localhost(
363
+ "btrfs"
364
+ , id
365
+ , name
366
+ , node->label
367
+ , "btrfs.system_bytes"
368
+ , title
369
+ , "MB"
370
+ , "proc"
371
+ , "sys/fs/btrfs"
372
+ , 2300
373
+ , update_every
374
+ , RRDSET_TYPE_LINE
375
+ );
376
+
377
+ node->rd_allocation_data_total_bytes = rrddim_add(node->st_allocation_data, "total", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
378
+ node->rd_allocation_data_bytes_used = rrddim_add(node->st_allocation_data, "used", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
379
+ node->rd_allocation_data_disk_total = rrddim_add(node->st_allocation_data, "disk_total", "disk total", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
380
+ node->rd_allocation_data_disk_used = rrddim_add(node->st_allocation_data, "disk_used", "disk used", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
381
+ }
382
+ else rrdset_next(node->st_allocation_data);
383
+
384
+ rrddim_set_by_pointer(node->st_allocation_data, node->rd_allocation_data_total_bytes, node->allocation_data_total_bytes);
385
+ rrddim_set_by_pointer(node->st_allocation_data, node->rd_allocation_data_bytes_used, node->allocation_data_bytes_used);
386
+ rrddim_set_by_pointer(node->st_allocation_data, node->rd_allocation_data_disk_total, node->allocation_data_disk_total);
387
+ rrddim_set_by_pointer(node->st_allocation_data, node->rd_allocation_data_disk_used, node->allocation_data_disk_used);
388
+ rrdset_done(node->st_allocation_data);
389
+ }
390
+
391
+ // --------------------------------------------------------------------
392
+ // allocation/system
393
+
394
+ if(do_allocation_system == CONFIG_BOOLEAN_YES || (do_allocation_system == CONFIG_BOOLEAN_AUTO && (node->allocation_system_total_bytes || node->allocation_system_bytes_used))) {
395
+ do_allocation_system = CONFIG_BOOLEAN_YES;
396
+
397
+ if(unlikely(!node->st_allocation_system)) {
398
+ char id[RRD_ID_LENGTH_MAX + 1], name[RRD_ID_LENGTH_MAX + 1], title[200 + 1];
399
+
400
+ snprintf(id, RRD_ID_LENGTH_MAX, "system_bytes_%s", node->id);
401
+ snprintf(name, RRD_ID_LENGTH_MAX, "system_bytes_%s", node->label);
402
+ snprintf(title, 200, "BTRFS System Allocation for %s", node->label);
403
+
404
+ netdata_fix_chart_id(id);
405
+ netdata_fix_chart_name(name);
406
+
407
+ node->st_allocation_system = rrdset_create_localhost(
408
+ "btrfs"
409
+ , id
410
+ , name
411
+ , node->label
412
+ , "btrfs.system_bytes"
413
+ , title
414
+ , "MB"
415
+ , "proc"
416
+ , "sys/fs/btrfs"
417
+ , 2301
418
+ , update_every
419
+ , RRDSET_TYPE_LINE
420
+ );
421
+
422
+ node->rd_allocation_system_total_bytes = rrddim_add(node->st_allocation_system, "total", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
423
+ node->rd_allocation_system_bytes_used = rrddim_add(node->st_allocation_system, "used", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
424
+ node->rd_allocation_system_disk_total = rrddim_add(node->st_allocation_system, "disk_total", "disk total", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
425
+ node->rd_allocation_system_disk_used = rrddim_add(node->st_allocation_system, "disk_used", "disk used", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
426
+ }
427
+ else rrdset_next(node->st_allocation_system);
428
+
429
+ rrddim_set_by_pointer(node->st_allocation_system, node->rd_allocation_system_total_bytes, node->allocation_system_total_bytes);
430
+ rrddim_set_by_pointer(node->st_allocation_system, node->rd_allocation_system_bytes_used, node->allocation_system_bytes_used);
431
+ rrddim_set_by_pointer(node->st_allocation_system, node->rd_allocation_system_disk_total, node->allocation_system_disk_total);
432
+ rrddim_set_by_pointer(node->st_allocation_system, node->rd_allocation_system_disk_used, node->allocation_system_disk_used);
433
+ rrdset_done(node->st_allocation_system);
434
+ }
435
+
436
+ // --------------------------------------------------------------------
437
+ // allocation/metadata
438
+
439
+ if(do_allocation_metadata == CONFIG_BOOLEAN_YES || (do_allocation_metadata == CONFIG_BOOLEAN_AUTO && (node->allocation_metadata_total_bytes || node->allocation_metadata_bytes_used))) {
440
+ do_allocation_metadata = CONFIG_BOOLEAN_YES;
441
+
442
+ if(unlikely(!node->st_allocation_metadata)) {
443
+ char id[RRD_ID_LENGTH_MAX + 1], name[RRD_ID_LENGTH_MAX + 1], title[200 + 1];
444
+
445
+ snprintf(id, RRD_ID_LENGTH_MAX, "metadata_bytes_%s", node->id);
446
+ snprintf(name, RRD_ID_LENGTH_MAX, "metadata_bytes_%s", node->label);
447
+ snprintf(title, 200, "BTRFS Metadata Allocation for %s", node->label);
448
+
449
+ netdata_fix_chart_id(id);
450
+ netdata_fix_chart_name(name);
451
+
452
+ node->st_allocation_metadata = rrdset_create_localhost(
453
+ "btrfs"
454
+ , id
455
+ , name
456
+ , node->label
457
+ , "btrfs.system_bytes"
458
+ , title
459
+ , "MB"
460
+ , "proc"
461
+ , "sys/fs/btrfs"
462
+ , 2302
463
+ , update_every
464
+ , RRDSET_TYPE_LINE
465
+ );
466
+
467
+ node->rd_allocation_metadata_total_bytes = rrddim_add(node->st_allocation_metadata, "total", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
468
+ node->rd_allocation_metadata_bytes_used = rrddim_add(node->st_allocation_metadata, "used", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
469
+ node->rd_allocation_metadata_disk_total = rrddim_add(node->st_allocation_metadata, "disk_total", "disk total", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
470
+ node->rd_allocation_metadata_disk_used = rrddim_add(node->st_allocation_metadata, "disk_used", "disk used", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
471
+ }
472
+ else rrdset_next(node->st_allocation_metadata);
473
+
474
+ rrddim_set_by_pointer(node->st_allocation_metadata, node->rd_allocation_metadata_total_bytes, node->allocation_metadata_total_bytes);
475
+ rrddim_set_by_pointer(node->st_allocation_metadata, node->rd_allocation_metadata_bytes_used, node->allocation_metadata_bytes_used);
476
+ rrddim_set_by_pointer(node->st_allocation_metadata, node->rd_allocation_metadata_disk_total, node->allocation_metadata_disk_total);
477
+ rrddim_set_by_pointer(node->st_allocation_metadata, node->rd_allocation_metadata_disk_used, node->allocation_metadata_disk_used);
478
+ rrdset_done(node->st_allocation_metadata);
479
+ }
480
+
481
+
482
+ // --------------------------------------------------------------------
483
+ // allocation/global_rsv
484
+
485
+ if(do_allocation_global_rsv == CONFIG_BOOLEAN_YES || (do_allocation_global_rsv == CONFIG_BOOLEAN_AUTO && (node->allocation_global_rsv_size || node->allocation_global_rsv_reserved))) {
486
+ do_allocation_global_rsv = CONFIG_BOOLEAN_YES;
487
+
488
+ if(unlikely(!node->st_allocation_global_rsv)) {
489
+ char id[RRD_ID_LENGTH_MAX + 1], name[RRD_ID_LENGTH_MAX + 1], title[200 + 1];
490
+
491
+ snprintf(id, RRD_ID_LENGTH_MAX, "global_reserve_%s", node->id);
492
+ snprintf(name, RRD_ID_LENGTH_MAX, "global_reserve_%s", node->label);
493
+ snprintf(title, 200, "BTRFS Global Reserve for %s", node->label);
494
+
495
+ netdata_fix_chart_id(id);
496
+ netdata_fix_chart_name(name);
497
+
498
+ node->st_allocation_global_rsv = rrdset_create_localhost(
499
+ "btrfs"
500
+ , id
501
+ , name
502
+ , node->label
503
+ , "btrfs.system_bytes"
504
+ , title
505
+ , "MB"
506
+ , "proc"
507
+ , "sys/fs/btrfs"
508
+ , 2302
509
+ , update_every
510
+ , RRDSET_TYPE_LINE
511
+ );
512
+ node->rd_allocation_global_rsv_size = rrddim_add(node->st_allocation_global_rsv, "size", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
513
+ node->rd_allocation_global_rsv_reserved = rrddim_add(node->st_allocation_global_rsv, "reserved", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
514
+ }
515
+ else rrdset_next(node->st_allocation_global_rsv);
516
+
517
+ rrddim_set_by_pointer(node->st_allocation_global_rsv, node->rd_allocation_global_rsv_size, node->allocation_global_rsv_size);
518
+ rrddim_set_by_pointer(node->st_allocation_global_rsv, node->rd_allocation_global_rsv_reserved, node->allocation_global_rsv_reserved);
519
+ rrdset_done(node->st_allocation_global_rsv);
520
+ }
521
+ }
522
+
523
+ return 0;
524
+}
525
+
src/zfs_common.c
+18
-18
@@ -48,7 +48,7 @@ void generate_charts_arcstats(const char *plugin, int update_every) {
48
, "MB"
49
, plugin
50
, "zfs"
51
- , 2000
51
+ , 2500
52
, update_every
53
, RRDSET_TYPE_AREA
54
);
@@ -86,7 +86,7 @@ void generate_charts_arcstats(const char *plugin, int update_every) {
86
, "MB"
87
, plugin
88
, "zfs"
89
- , 2000
89
+ , 2500
90
, update_every
91
, RRDSET_TYPE_AREA
92
);
@@ -123,7 +123,7 @@ void generate_charts_arcstats(const char *plugin, int update_every) {
123
, "reads/s"
124
, plugin
125
, "zfs"
126
- , 2010
126
+ , 2510
127
, update_every
128
, RRDSET_TYPE_AREA
129
);
@@ -168,7 +168,7 @@ void generate_charts_arcstats(const char *plugin, int update_every) {
168
, "kilobytes/s"
169
, plugin
170
, "zfs"
171
- , 2200
171
+ , 2700
172
, update_every
173
, RRDSET_TYPE_AREA
174
);
@@ -202,7 +202,7 @@ void generate_charts_arcstats(const char *plugin, int update_every) {
202
, "percentage"
203
, plugin
204
, "zfs"
205
- , 2020
205
+ , 2520
206
, update_every
207
, RRDSET_TYPE_STACKED
208
);
@@ -236,7 +236,7 @@ void generate_charts_arcstats(const char *plugin, int update_every) {
236
, "percentage"
237
, plugin
238
, "zfs"
239
- , 2030
239
+ , 2530
240
, update_every
241
, RRDSET_TYPE_STACKED
242
);
@@ -270,7 +270,7 @@ void generate_charts_arcstats(const char *plugin, int update_every) {
270
, "percentage"
271
, plugin
272
, "zfs"
273
- , 2040
273
+ , 2540
274
, update_every
275
, RRDSET_TYPE_STACKED
276
);
@@ -304,7 +304,7 @@ void generate_charts_arcstats(const char *plugin, int update_every) {
304
, "percentage"
305
, plugin
306
, "zfs"
307
- , 2050
307
+ , 2550
308
, update_every
309
, RRDSET_TYPE_STACKED
310
);
@@ -338,7 +338,7 @@ void generate_charts_arcstats(const char *plugin, int update_every) {
338
, "percentage"
339
, plugin
340
, "zfs"
341
- , 2060
341
+ , 2560
342
, update_every
343
, RRDSET_TYPE_STACKED
344
);
@@ -374,7 +374,7 @@ void generate_charts_arcstats(const char *plugin, int update_every) {
374
, "hits/s"
375
, plugin
376
, "zfs"
377
- , 2100
377
+ , 2600
378
, update_every
379
, RRDSET_TYPE_AREA
380
);
@@ -433,7 +433,7 @@ void generate_charts_arc_summary(const char *plugin, int update_every) {
433
, "percentage"
434
, plugin
435
, "zfs"
436
- , 2020
436
+ , 2520
437
, update_every
438
, RRDSET_TYPE_STACKED
439
);
@@ -472,7 +472,7 @@ void generate_charts_arc_summary(const char *plugin, int update_every) {
472
, "operations/s"
473
, plugin
474
, "zfs"
475
- , 2023
475
+ , 2523
476
, update_every
477
, RRDSET_TYPE_LINE
478
);
@@ -518,7 +518,7 @@ void generate_charts_arc_summary(const char *plugin, int update_every) {
518
, "operations/s"
519
, plugin
520
, "zfs"
521
- , 2022
521
+ , 2522
522
, update_every
523
, RRDSET_TYPE_LINE
524
);
@@ -556,7 +556,7 @@ void generate_charts_arc_summary(const char *plugin, int update_every) {
556
, "percentage"
557
, plugin
558
, "zfs"
559
- , 2019
559
+ , 2519
560
, update_every
561
, RRDSET_TYPE_STACKED
562
);
@@ -590,7 +590,7 @@ void generate_charts_arc_summary(const char *plugin, int update_every) {
590
, "percentage"
591
, plugin
592
, "zfs"
593
- , 2031
593
+ , 2531
594
, update_every
595
, RRDSET_TYPE_STACKED
596
);
@@ -624,7 +624,7 @@ void generate_charts_arc_summary(const char *plugin, int update_every) {
624
, "percentage"
625
, plugin
626
, "zfs"
627
- , 2032
627
+ , 2532
628
, update_every
629
, RRDSET_TYPE_STACKED
630
);
@@ -658,7 +658,7 @@ void generate_charts_arc_summary(const char *plugin, int update_every) {
658
, "elements"
659
, plugin
660
, "zfs"
661
- , 2300
661
+ , 2800
662
, update_every
663
, RRDSET_TYPE_LINE
664
);
@@ -692,7 +692,7 @@ void generate_charts_arc_summary(const char *plugin, int update_every) {
692
, "chains"
693
, plugin
694
, "zfs"
695
- , 2310
695
+ , 2810
696
, update_every
697
, RRDSET_TYPE_LINE
698
);
web/dashboard_info.js
+6
@@ -121,6 +121,12 @@ netdataDashboard.menu = {
121
info: 'Performance metrics of the ZFS filesystem. The following charts visualize all metrics reported by <a href="https://github.com/zfsonlinux/zfs/blob/master/cmd/arcstat/arcstat.py" target="_blank">arcstat.py</a> and <a href="https://github.com/zfsonlinux/zfs/blob/master/cmd/arc_summary/arc_summary.py" target="_blank">arc_summary.py</a>.'
122
},
123
124
+ 'btrfs': {
125
+ title: 'BTRFS filesystem',
126
+ icon: '<i class="fas fa-folder-open"></i>',
127
+ info: 'Utilization metrics of the BTRFS filesystem.'
128
+ },
129
+
130
'apps': {
131
title: 'Applications',
132
icon: '<i class="fas fa-heartbeat"></i>',
web/index.html
+1
-1
@@ -4274,7 +4274,7 @@
4274
});
4275
4276
NETDATA.requiredJs.push({
4277
- url: NETDATA.serverStatic + 'dashboard_info.js?v20171208-1',
4277
+ url: NETDATA.serverStatic + 'dashboard_info.js?v20171217-1',
4278
async: false,
4279
isAlreadyLoaded: function() { return false; }
4280
});