Add ZFS TRIM statistics
Vladimir Kobal committed
Oct 17, 2017 at 15:48 UTC
80fad66cb5f2fd4b8e90ab1e78929a441ca243e3
3 files changed
+88
src/freebsd_kstat_zfs.c
+86
@@ -3,7 +3,9 @@
3
4
struct arcstats arcstats = { 0 };
5
6
+// --------------------------------------------------------------------------------------------------------------------
7
// kstat.zfs.misc.arcstats
8
+
9
int do_kstat_zfs_misc_arcstats(int update_every, usec_t dt) {
10
(void)dt;
11
@@ -208,5 +210,89 @@ int do_kstat_zfs_misc_arcstats(int update_every, usec_t dt) {
210
generate_charts_arcstats("freebsd", update_every);
211
generate_charts_arc_summary("freebsd", update_every);
212
213
+ return 0;
214
+}
215
+
216
+// --------------------------------------------------------------------------------------------------------------------
217
+// kstat.zfs.misc.zio_trim
218
+
219
+int do_kstat_zfs_misc_zio_trim(int update_every, usec_t dt) {
220
+ (void)dt;
221
+ static int mib_bytes[5] = {0, 0, 0, 0, 0}, mib_success[5] = {0, 0, 0, 0, 0},
222
+ mib_failed[5] = {0, 0, 0, 0, 0}, mib_unsupported[5] = {0, 0, 0, 0, 0};
223
+ uint64_t bytes, success, failed, unsupported;
224
+
225
+ if (unlikely(GETSYSCTL_SIMPLE("kstat.zfs.misc.zio_trim.bytes", mib_bytes, bytes) ||
226
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.zio_trim.success", mib_success, success) ||
227
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.zio_trim.failed", mib_failed, failed) ||
228
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.zio_trim.unsupported", mib_unsupported, unsupported))) {
229
+ error("DISABLED: zfs.trim_bytes chart");
230
+ error("DISABLED: zfs.trim_success chart");
231
+ error("DISABLED: kstat.zfs.misc.zio_trim module");
232
+ return 1;
233
+ } else {
234
+
235
+ // --------------------------------------------------------------------
236
+
237
+ static RRDSET *st_bytes = NULL;
238
+ static RRDDIM *rd_bytes = NULL;
239
+
240
+ if (unlikely(!st_bytes)) {
241
+ st_bytes = rrdset_create_localhost(
242
+ "zfs",
243
+ "trim_bytes",
244
+ NULL,
245
+ "trim",
246
+ NULL,
247
+ "Successfully TRIMmed bytes",
248
+ "bytes",
249
+ "freebsd",
250
+ "zfs",
251
+ 2320,
252
+ update_every,
253
+ RRDSET_TYPE_LINE
254
+ );
255
+
256
+ rd_bytes = rrddim_add(st_bytes, "TRIMmed", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
257
+ }
258
+ else rrdset_next(st_bytes);
259
+
260
+ rrddim_set_by_pointer(st_bytes, rd_bytes, bytes);
261
+ rrdset_done(st_bytes);
262
+
263
+ // --------------------------------------------------------------------
264
+
265
+ static RRDSET *st_requests = NULL;
266
+ static RRDDIM *rd_successful = NULL, *rd_failed = NULL, *rd_unsupported = NULL;
267
+
268
+ if (unlikely(!st_requests)) {
269
+ st_requests = rrdset_create_localhost(
270
+ "zfs",
271
+ "trim_requests",
272
+ NULL,
273
+ "trim",
274
+ NULL,
275
+ "TRIM requests",
276
+ "requests",
277
+ "freebsd",
278
+ "zfs",
279
+ 2321,
280
+ update_every,
281
+ RRDSET_TYPE_STACKED
282
+ );
283
+
284
+ rd_successful = rrddim_add(st_requests, "successful", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
285
+ rd_failed = rrddim_add(st_requests, "failed", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
286
+ rd_unsupported = rrddim_add(st_requests, "unsupported", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
287
+ }
288
+ else rrdset_next(st_requests);
289
+
290
+ rrddim_set_by_pointer(st_requests, rd_successful, success);
291
+ rrddim_set_by_pointer(st_requests, rd_failed, failed);
292
+ rrddim_set_by_pointer(st_requests, rd_unsupported, unsupported);
293
+ rrdset_done(st_requests);
294
+
295
+ }
296
+
297
return 0;
298
}
\ No newline at end of file
src/plugin_freebsd.c
+1
@@ -57,6 +57,7 @@ static struct freebsd_module {
57
58
// ZFS metrics
59
{ .name = "kstat.zfs.misc.arcstats", .dim = "arcstats", .enabled = 1, .func = do_kstat_zfs_misc_arcstats },
60
+ { .name = "kstat.zfs.misc.zio_trim", .dim = "trim", .enabled = 1, .func = do_kstat_zfs_misc_zio_trim },
61
62
// ipfw metrics
63
{ .name = "ipfw", .dim = "ipfw", .enabled = 1, .func = do_ipfw },
src/plugin_freebsd.h
+1
@@ -44,6 +44,7 @@ extern int do_getifaddrs(int update_every, usec_t dt);
44
extern int do_getmntinfo(int update_every, usec_t dt);
45
extern int do_kern_devstat(int update_every, usec_t dt);
46
extern int do_kstat_zfs_misc_arcstats(int update_every, usec_t dt);
47
+extern int do_kstat_zfs_misc_zio_trim(int update_every, usec_t dt);
48
extern int do_ipfw(int update_every, usec_t dt);
49
50
#define GETSYSCTL_MIB(name, mib) getsysctl_mib(name, mib, sizeof(mib)/sizeof(int))