Change source files structure for ZFS stats
Vladimir Kobal committed
Apr 8, 2017 at 15:26 UTC
83fc9f5bb5e5214f3673e31d9c2e5d528ba5d689
6 files changed
+1005
-984
CMakeLists.txt
+3
@@ -32,6 +32,9 @@ set(NETDATA_SOURCE_FILES
32
src/freebsd_getmntinfo.c
33
src/freebsd_getifaddrs.c
34
src/freebsd_devstat.c
35
+ src/zfs_common.c
36
+ src/zfs_common.h
37
+ src/freebsd_kstat_zfs.c
38
src/global_statistics.c
39
src/global_statistics.h
40
src/health.c
src/Makefile.am
+5
-1
@@ -149,7 +149,9 @@ netdata_SOURCES += \
149
freebsd_getmntinfo.c \
150
freebsd_getifaddrs.c \
151
freebsd_devstat.c \
152
- proc_spl_kstat_zfs.c \
152
+ zfs_common.c \
153
+ zfs_common.h \
154
+ freebsd_kstat_zfs.c \
155
$(NULL)
156
else
157
if MACOS
@@ -182,6 +184,8 @@ netdata_SOURCES += \
184
proc_net_softnet_stat.c \
185
proc_net_stat_conntrack.c \
186
proc_net_stat_synproxy.c \
187
+ zfs_common.c \
188
+ zfs_common.h \
189
proc_spl_kstat_zfs.c \
190
proc_stat.c \
191
proc_sys_kernel_random_entropy_avail.c \
src/freebsd_kstat_zfs.c
new
+210
@@ -0,0 +1,210 @@
1
+#include "common.h"
2
+#include "zfs_common.h"
3
+
4
+// kstat.zfs.misc.arcstats
5
+int do_kstat_zfs_misc_arcstats(int update_every, usec_t dt) {
6
+ (void)dt;
7
+
8
+ unsigned long long l2_size;
9
+ size_t uint64_t_size = sizeof(uint64_t);
10
+ static struct mibs {
11
+ int hits[5];
12
+ int misses[5];
13
+ int demand_data_hits[5];
14
+ int demand_data_misses[5];
15
+ int demand_metadata_hits[5];
16
+ int demand_metadata_misses[5];
17
+ int prefetch_data_hits[5];
18
+ int prefetch_data_misses[5];
19
+ int prefetch_metadata_hits[5];
20
+ int prefetch_metadata_misses[5];
21
+ int mru_hits[5];
22
+ int mru_ghost_hits[5];
23
+ int mfu_hits[5];
24
+ int mfu_ghost_hits[5];
25
+ int deleted[5];
26
+ int mutex_miss[5];
27
+ int evict_skip[5];
28
+ int evict_not_enough[5];
29
+ int evict_l2_cached[5];
30
+ int evict_l2_eligible[5];
31
+ int evict_l2_ineligible[5];
32
+ int evict_l2_skip[5];
33
+ int hash_elements[5];
34
+ int hash_elements_max[5];
35
+ int hash_collisions[5];
36
+ int hash_chains[5];
37
+ int hash_chain_max[5];
38
+ int p[5];
39
+ int c[5];
40
+ int c_min[5];
41
+ int c_max[5];
42
+ int size[5];
43
+ int hdr_size[5];
44
+ int data_size[5];
45
+ int metadata_size[5];
46
+ int other_size[5];
47
+ int anon_size[5];
48
+ int anon_evictable_data[5];
49
+ int anon_evictable_metadata[5];
50
+ int mru_size[5];
51
+ int mru_evictable_data[5];
52
+ int mru_evictable_metadata[5];
53
+ int mru_ghost_size[5];
54
+ int mru_ghost_evictable_data[5];
55
+ int mru_ghost_evictable_metadata[5];
56
+ int mfu_size[5];
57
+ int mfu_evictable_data[5];
58
+ int mfu_evictable_metadata[5];
59
+ int mfu_ghost_size[5];
60
+ int mfu_ghost_evictable_data[5];
61
+ int mfu_ghost_evictable_metadata[5];
62
+ int l2_hits[5];
63
+ int l2_misses[5];
64
+ int l2_feeds[5];
65
+ int l2_rw_clash[5];
66
+ int l2_read_bytes[5];
67
+ int l2_write_bytes[5];
68
+ int l2_writes_sent[5];
69
+ int l2_writes_done[5];
70
+ int l2_writes_error[5];
71
+ int l2_writes_lock_retry[5];
72
+ int l2_evict_lock_retry[5];
73
+ int l2_evict_reading[5];
74
+ int l2_evict_l1cached[5];
75
+ int l2_free_on_write[5];
76
+ int l2_cdata_free_on_write[5];
77
+ int l2_abort_lowmem[5];
78
+ int l2_cksum_bad[5];
79
+ int l2_io_error[5];
80
+ int l2_size[5];
81
+ int l2_asize[5];
82
+ int l2_hdr_size[5];
83
+ int l2_compress_successes[5];
84
+ int l2_compress_zeros[5];
85
+ int l2_compress_failures[5];
86
+ int memory_throttle_count[5];
87
+ int duplicate_buffers[5];
88
+ int duplicate_buffers_size[5];
89
+ int duplicate_reads[5];
90
+ int memory_direct_count[5];
91
+ int memory_indirect_count[5];
92
+ int arc_no_grow[5];
93
+ int arc_tempreserve[5];
94
+ int arc_loaned_bytes[5];
95
+ int arc_prune[5];
96
+ int arc_meta_used[5];
97
+ int arc_meta_limit[5];
98
+ int arc_meta_max[5];
99
+ int arc_meta_min[5];
100
+ int arc_need_free[5];
101
+ int arc_sys_free[5];
102
+ } mibs;
103
+
104
+ l2exist = -1;
105
+
106
+ if(unlikely(sysctlbyname("kstat.zfs.misc.arcstats.l2_size", &l2_size, &uint64_t_size, NULL, 0)))
107
+ return 0;
108
+
109
+ if(likely(l2_size))
110
+ l2exist = 1;
111
+ else
112
+ l2exist = 0;
113
+
114
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.hits", mibs.hits, arcstats.hits);
115
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.misses", mibs.misses, arcstats.misses);
116
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.demand_data_hits", mibs.demand_data_hits, arcstats.demand_data_hits);
117
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.demand_data_misses", mibs.demand_data_misses, arcstats.demand_data_misses);
118
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.demand_metadata_hits", mibs.demand_metadata_hits, arcstats.demand_metadata_hits);
119
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.demand_metadata_misses", mibs.demand_metadata_misses, arcstats.demand_metadata_misses);
120
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.prefetch_data_hits", mibs.prefetch_data_hits, arcstats.prefetch_data_hits);
121
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.prefetch_data_misses", mibs.prefetch_data_misses, arcstats.prefetch_data_misses);
122
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.prefetch_metadata_hits", mibs.prefetch_metadata_hits, arcstats.prefetch_metadata_hits);
123
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.prefetch_metadata_misses", mibs.prefetch_metadata_misses, arcstats.prefetch_metadata_misses);
124
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mru_hits", mibs.mru_hits, arcstats.mru_hits);
125
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mru_ghost_hits", mibs.mru_ghost_hits, arcstats.mru_ghost_hits);
126
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mfu_hits", mibs.mfu_hits, arcstats.mfu_hits);
127
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mfu_ghost_hits", mibs.mfu_ghost_hits, arcstats.mfu_ghost_hits);
128
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.deleted", mibs.deleted, arcstats.deleted);
129
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mutex_miss", mibs.mutex_miss, arcstats.mutex_miss);
130
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.evict_skip", mibs.evict_skip, arcstats.evict_skip);
131
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.evict_not_enough", mibs.evict_not_enough, arcstats.evict_not_enough);
132
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.evict_l2_cached", mibs.evict_l2_cached, arcstats.evict_l2_cached);
133
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.evict_l2_eligible", mibs.evict_l2_eligible, arcstats.evict_l2_eligible);
134
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.evict_l2_ineligible", mibs.evict_l2_ineligible, arcstats.evict_l2_ineligible);
135
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.evict_l2_skip", mibs.evict_l2_skip, arcstats.evict_l2_skip);
136
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.hash_elements", mibs.hash_elements, arcstats.hash_elements);
137
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.hash_elements_max", mibs.hash_elements_max, arcstats.hash_elements_max);
138
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.hash_collisions", mibs.hash_collisions, arcstats.hash_collisions);
139
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.hash_chains", mibs.hash_chains, arcstats.hash_chains);
140
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.hash_chain_max", mibs.hash_chain_max, arcstats.hash_chain_max);
141
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.p", mibs.p, arcstats.p);
142
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.c", mibs.c, arcstats.c);
143
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.c_min", mibs.c_min, arcstats.c_min);
144
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.c_max", mibs.c_max, arcstats.c_max);
145
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.size", mibs.size, arcstats.size);
146
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.hdr_size", mibs.hdr_size, arcstats.hdr_size);
147
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.data_size", mibs.data_size, arcstats.data_size);
148
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.metadata_size", mibs.metadata_size, arcstats.metadata_size);
149
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.other_size", mibs.other_size, arcstats.other_size);
150
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.anon_size", mibs.anon_size, arcstats.anon_size);
151
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.anon_evictable_data", mibs.anon_evictable_data, arcstats.anon_evictable_data);
152
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.anon_evictable_metadata", mibs.anon_evictable_metadata, arcstats.anon_evictable_metadata);
153
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mru_size", mibs.mru_size, arcstats.mru_size);
154
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mru_evictable_data", mibs.mru_evictable_data, arcstats.mru_evictable_data);
155
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mru_evictable_metadata", mibs.mru_evictable_metadata, arcstats.mru_evictable_metadata);
156
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mru_ghost_size", mibs.mru_ghost_size, arcstats.mru_ghost_size);
157
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mru_ghost_evictable_data", mibs.mru_ghost_evictable_data, arcstats.mru_ghost_evictable_data);
158
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mru_ghost_evictable_metadata", mibs.mru_ghost_evictable_metadata, arcstats.mru_ghost_evictable_metadata);
159
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mfu_size", mibs.mfu_size, arcstats.mfu_size);
160
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mfu_evictable_data", mibs.mfu_evictable_data, arcstats.mfu_evictable_data);
161
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mfu_evictable_metadata", mibs.mfu_evictable_metadata, arcstats.mfu_evictable_metadata);
162
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mfu_ghost_size", mibs.mfu_ghost_size, arcstats.mfu_ghost_size);
163
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mfu_ghost_evictable_data", mibs.mfu_ghost_evictable_data, arcstats.mfu_ghost_evictable_data);
164
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mfu_ghost_evictable_metadata", mibs.mfu_ghost_evictable_metadata, arcstats.mfu_ghost_evictable_metadata);
165
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_hits", mibs.l2_hits, arcstats.l2_hits);
166
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_misses", mibs.l2_misses, arcstats.l2_misses);
167
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_feeds", mibs.l2_feeds, arcstats.l2_feeds);
168
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_rw_clash", mibs.l2_rw_clash, arcstats.l2_rw_clash);
169
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_read_bytes", mibs.l2_read_bytes, arcstats.l2_read_bytes);
170
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_write_bytes", mibs.l2_write_bytes, arcstats.l2_write_bytes);
171
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_writes_sent", mibs.l2_writes_sent, arcstats.l2_writes_sent);
172
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_writes_done", mibs.l2_writes_done, arcstats.l2_writes_done);
173
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_writes_error", mibs.l2_writes_error, arcstats.l2_writes_error);
174
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_writes_lock_retry", mibs.l2_writes_lock_retry, arcstats.l2_writes_lock_retry);
175
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_evict_lock_retry", mibs.l2_evict_lock_retry, arcstats.l2_evict_lock_retry);
176
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_evict_reading", mibs.l2_evict_reading, arcstats.l2_evict_reading);
177
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_evict_l1cached", mibs.l2_evict_l1cached, arcstats.l2_evict_l1cached);
178
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_free_on_write", mibs.l2_free_on_write, arcstats.l2_free_on_write);
179
+ // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_cdata_free_on_write", mibs.l2_cdata_free_on_write, arcstats.l2_cdata_free_on_write);
180
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_abort_lowmem", mibs.l2_abort_lowmem, arcstats.l2_abort_lowmem);
181
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_cksum_bad", mibs.l2_cksum_bad, arcstats.l2_cksum_bad);
182
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_io_error", mibs.l2_io_error, arcstats.l2_io_error);
183
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_size", mibs.l2_size, arcstats.l2_size);
184
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_asize", mibs.l2_asize, arcstats.l2_asize);
185
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_hdr_size", mibs.l2_hdr_size, arcstats.l2_hdr_size);
186
+ // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_compress_successes", mibs.l2_compress_successes, arcstats.l2_compress_successes);
187
+ // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_compress_zeros", mibs.l2_compress_zeros, arcstats.l2_compress_zeros);
188
+ // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_compress_failures", mibs.l2_compress_failures, arcstats.l2_compress_failures);
189
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.memory_throttle_count", mibs.memory_throttle_count, arcstats.memory_throttle_count);
190
+ // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.duplicate_buffers", mibs.duplicate_buffers, arcstats.duplicate_buffers);
191
+ // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.duplicate_buffers_size", mibs.duplicate_buffers_size, arcstats.duplicate_buffers_size);
192
+ // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.duplicate_reads", mibs.duplicate_reads, arcstats.duplicate_reads);
193
+ // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.memory_direct_count", mibs.memory_direct_count, arcstats.memory_direct_count);
194
+ // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.memory_indirect_count", mibs.memory_indirect_count, arcstats.memory_indirect_count);
195
+ // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_no_grow", mibs.arc_no_grow, arcstats.arc_no_grow);
196
+ // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_tempreserve", mibs.arc_tempreserve, arcstats.arc_tempreserve);
197
+ // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_loaned_bytes", mibs.arc_loaned_bytes, arcstats.arc_loaned_bytes);
198
+ // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_prune", mibs.arc_prune, arcstats.arc_prune);
199
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_meta_used", mibs.arc_meta_used, arcstats.arc_meta_used);
200
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_meta_limit", mibs.arc_meta_limit, arcstats.arc_meta_limit);
201
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_meta_max", mibs.arc_meta_max, arcstats.arc_meta_max);
202
+ // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_meta_min", mibs.arc_meta_min, arcstats.arc_meta_min);
203
+ // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_need_free", mibs.arc_need_free, arcstats.arc_need_free);
204
+ // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_sys_free", mibs.arc_sys_free, arcstats.arc_sys_free);
205
+
206
+ generate_charts_arcstats(update_every);
207
+ generate_charts_arc_summary(update_every);
208
+
209
+ return 0;
210
+}
\ No newline at end of file
src/proc_spl_kstat_zfs.c
+3
-983
@@ -1,995 +1,16 @@
1
#include "common.h"
2
+#include "zfs_common.h"
3
4
#define ZFS_PROC_ARCSTATS "/proc/spl/kstat/zfs/arcstats"
4
-#define ZFS_FAMILY_SIZE "size"
5
-#define ZFS_FAMILY_EFFICIENCY "efficiency"
6
-#define ZFS_FAMILY_ACCESSES "accesses"
7
-#define ZFS_FAMILY_OPERATIONS "operations"
8
-#define ZFS_FAMILY_HASH "hashes"
5
10
-static struct arcstats {
11
- unsigned long long hits;
12
- unsigned long long misses;
13
- unsigned long long demand_data_hits;
14
- unsigned long long demand_data_misses;
15
- unsigned long long demand_metadata_hits;
16
- unsigned long long demand_metadata_misses;
17
- unsigned long long prefetch_data_hits;
18
- unsigned long long prefetch_data_misses;
19
- unsigned long long prefetch_metadata_hits;
20
- unsigned long long prefetch_metadata_misses;
21
- unsigned long long mru_hits;
22
- unsigned long long mru_ghost_hits;
23
- unsigned long long mfu_hits;
24
- unsigned long long mfu_ghost_hits;
25
- unsigned long long deleted;
26
- unsigned long long mutex_miss;
27
- unsigned long long evict_skip;
28
- unsigned long long evict_not_enough;
29
- unsigned long long evict_l2_cached;
30
- unsigned long long evict_l2_eligible;
31
- unsigned long long evict_l2_ineligible;
32
- unsigned long long evict_l2_skip;
33
- unsigned long long hash_elements;
34
- unsigned long long hash_elements_max;
35
- unsigned long long hash_collisions;
36
- unsigned long long hash_chains;
37
- unsigned long long hash_chain_max;
38
- unsigned long long p;
39
- unsigned long long c;
40
- unsigned long long c_min;
41
- unsigned long long c_max;
42
- unsigned long long size;
43
- unsigned long long hdr_size;
44
- unsigned long long data_size;
45
- unsigned long long metadata_size;
46
- unsigned long long other_size;
47
- unsigned long long anon_size;
48
- unsigned long long anon_evictable_data;
49
- unsigned long long anon_evictable_metadata;
50
- unsigned long long mru_size;
51
- unsigned long long mru_evictable_data;
52
- unsigned long long mru_evictable_metadata;
53
- unsigned long long mru_ghost_size;
54
- unsigned long long mru_ghost_evictable_data;
55
- unsigned long long mru_ghost_evictable_metadata;
56
- unsigned long long mfu_size;
57
- unsigned long long mfu_evictable_data;
58
- unsigned long long mfu_evictable_metadata;
59
- unsigned long long mfu_ghost_size;
60
- unsigned long long mfu_ghost_evictable_data;
61
- unsigned long long mfu_ghost_evictable_metadata;
62
- unsigned long long l2_hits;
63
- unsigned long long l2_misses;
64
- unsigned long long l2_feeds;
65
- unsigned long long l2_rw_clash;
66
- unsigned long long l2_read_bytes;
67
- unsigned long long l2_write_bytes;
68
- unsigned long long l2_writes_sent;
69
- unsigned long long l2_writes_done;
70
- unsigned long long l2_writes_error;
71
- unsigned long long l2_writes_lock_retry;
72
- unsigned long long l2_evict_lock_retry;
73
- unsigned long long l2_evict_reading;
74
- unsigned long long l2_evict_l1cached;
75
- unsigned long long l2_free_on_write;
76
- unsigned long long l2_cdata_free_on_write;
77
- unsigned long long l2_abort_lowmem;
78
- unsigned long long l2_cksum_bad;
79
- unsigned long long l2_io_error;
80
- unsigned long long l2_size;
81
- unsigned long long l2_asize;
82
- unsigned long long l2_hdr_size;
83
- unsigned long long l2_compress_successes;
84
- unsigned long long l2_compress_zeros;
85
- unsigned long long l2_compress_failures;
86
- unsigned long long memory_throttle_count;
87
- unsigned long long duplicate_buffers;
88
- unsigned long long duplicate_buffers_size;
89
- unsigned long long duplicate_reads;
90
- unsigned long long memory_direct_count;
91
- unsigned long long memory_indirect_count;
92
- unsigned long long arc_no_grow;
93
- unsigned long long arc_tempreserve;
94
- unsigned long long arc_loaned_bytes;
95
- unsigned long long arc_prune;
96
- unsigned long long arc_meta_used;
97
- unsigned long long arc_meta_limit;
98
- unsigned long long arc_meta_max;
99
- unsigned long long arc_meta_min;
100
- unsigned long long arc_need_free;
101
- unsigned long long arc_sys_free;
102
-} arcstats = { 0 };
103
-
104
-int l2exist = -1;
105
-
106
-static void generate_charts_arcstats(int update_every) {
107
-
108
- // ARC reads
109
- unsigned long long aread = arcstats.hits + arcstats.misses;
110
-
111
- // Demand reads
112
- unsigned long long dhit = arcstats.demand_data_hits + arcstats.demand_metadata_hits;
113
- unsigned long long dmiss = arcstats.demand_data_misses + arcstats.demand_metadata_misses;
114
- unsigned long long dread = dhit + dmiss;
115
-
116
- // Prefetch reads
117
- unsigned long long phit = arcstats.prefetch_data_hits + arcstats.prefetch_metadata_hits;
118
- unsigned long long pmiss = arcstats.prefetch_data_misses + arcstats.prefetch_metadata_misses;
119
- unsigned long long pread = phit + pmiss;
120
-
121
- // Metadata reads
122
- unsigned long long mhit = arcstats.prefetch_metadata_hits + arcstats.demand_metadata_hits;
123
- unsigned long long mmiss = arcstats.prefetch_metadata_misses + arcstats.demand_metadata_misses;
124
- unsigned long long mread = mhit + mmiss;
125
-
126
- // l2 reads
127
- unsigned long long l2hit = arcstats.l2_hits + arcstats.l2_misses;
128
- unsigned long long l2miss = arcstats.prefetch_metadata_misses + arcstats.demand_metadata_misses;
129
- unsigned long long l2read = l2hit + l2miss;
130
-
131
- // --------------------------------------------------------------------
132
-
133
- {
134
- static RRDSET *st_arc_size = NULL;
135
- static RRDDIM *rd_arc_size = NULL;
136
- static RRDDIM *rd_arc_target_size = NULL;
137
- static RRDDIM *rd_arc_target_min_size = NULL;
138
- static RRDDIM *rd_arc_target_max_size = NULL;
139
-
140
- if (unlikely(!st_arc_size)) {
141
- st_arc_size = rrdset_create_localhost(
142
- "zfs"
143
- , "arc_size"
144
- , NULL
145
- , ZFS_FAMILY_SIZE
146
- , NULL
147
- , "ZFS ARC Size"
148
- , "MB"
149
- , 2000
150
- , update_every
151
- , RRDSET_TYPE_AREA
152
- );
153
-
154
- rd_arc_size = rrddim_add(st_arc_size, "size", "arcsz", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
155
- rd_arc_target_size = rrddim_add(st_arc_size, "target", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
156
- rd_arc_target_min_size = rrddim_add(st_arc_size, "min", "min (hard limit)", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
157
- rd_arc_target_max_size = rrddim_add(st_arc_size, "max", "max (high water)", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
158
- }
159
- else
160
- rrdset_next(st_arc_size);
161
-
162
- rrddim_set_by_pointer(st_arc_size, rd_arc_size, arcstats.size);
163
- rrddim_set_by_pointer(st_arc_size, rd_arc_target_size, arcstats.c);
164
- rrddim_set_by_pointer(st_arc_size, rd_arc_target_min_size, arcstats.c_min);
165
- rrddim_set_by_pointer(st_arc_size, rd_arc_target_max_size, arcstats.c_max);
166
- rrdset_done(st_arc_size);
167
- }
168
-
169
- // --------------------------------------------------------------------
170
-
171
- if(likely(l2exist)) {
172
- static RRDSET *st_l2_size = NULL;
173
- static RRDDIM *rd_l2_size = NULL;
174
- static RRDDIM *rd_l2_asize = NULL;
175
-
176
- if (unlikely(!st_l2_size)) {
177
- st_l2_size = rrdset_create_localhost(
178
- "zfs"
179
- , "l2_size"
180
- , NULL
181
- , ZFS_FAMILY_SIZE
182
- , NULL
183
- , "ZFS L2 ARC Size"
184
- , "MB"
185
- , 2000
186
- , update_every
187
- , RRDSET_TYPE_AREA
188
- );
189
-
190
- rd_l2_asize = rrddim_add(st_l2_size, "actual", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
191
- rd_l2_size = rrddim_add(st_l2_size, "size", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
192
- }
193
- else
194
- rrdset_next(st_l2_size);
195
-
196
- rrddim_set_by_pointer(st_l2_size, rd_l2_size, arcstats.l2_size);
197
- rrddim_set_by_pointer(st_l2_size, rd_l2_asize, arcstats.l2_asize);
198
- rrdset_done(st_l2_size);
199
- }
200
-
201
- // --------------------------------------------------------------------
202
-
203
- {
204
- static RRDSET *st_reads = NULL;
205
- static RRDDIM *rd_aread = NULL;
206
- static RRDDIM *rd_dread = NULL;
207
- static RRDDIM *rd_pread = NULL;
208
- static RRDDIM *rd_mread = NULL;
209
- static RRDDIM *rd_l2read = NULL;
210
-
211
- if (unlikely(!st_reads)) {
212
- st_reads = rrdset_create_localhost(
213
- "zfs"
214
- , "reads"
215
- , NULL
216
- , ZFS_FAMILY_ACCESSES
217
- , NULL
218
- , "ZFS Reads"
219
- , "reads/s"
220
- , 2010
221
- , update_every
222
- , RRDSET_TYPE_AREA
223
- );
224
-
225
- rd_aread = rrddim_add(st_reads, "areads", "arc", 1, 1, RRD_ALGORITHM_INCREMENTAL);
226
- rd_dread = rrddim_add(st_reads, "dreads", "demand", 1, 1, RRD_ALGORITHM_INCREMENTAL);
227
- rd_pread = rrddim_add(st_reads, "preads", "prefetch", 1, 1, RRD_ALGORITHM_INCREMENTAL);
228
- rd_mread = rrddim_add(st_reads, "mreads", "metadata", 1, 1, RRD_ALGORITHM_INCREMENTAL);
229
-
230
- if(l2exist)
231
- rd_l2read = rrddim_add(st_reads, "l2reads", "l2", 1, 1, RRD_ALGORITHM_INCREMENTAL);
232
- }
233
- else
234
- rrdset_next(st_reads);
235
-
236
- rrddim_set_by_pointer(st_reads, rd_aread, aread);
237
- rrddim_set_by_pointer(st_reads, rd_dread, dread);
238
- rrddim_set_by_pointer(st_reads, rd_pread, pread);
239
- rrddim_set_by_pointer(st_reads, rd_mread, mread);
240
-
241
- if(l2exist)
242
- rrddim_set_by_pointer(st_reads, rd_l2read, l2read);
243
-
244
- rrdset_done(st_reads);
245
- }
246
-
247
- // --------------------------------------------------------------------
248
-
249
- if(likely(l2exist)) {
250
- static RRDSET *st_l2bytes = NULL;
251
- static RRDDIM *rd_l2_read_bytes = NULL;
252
- static RRDDIM *rd_l2_write_bytes = NULL;
253
-
254
- if (unlikely(!st_l2bytes)) {
255
- st_l2bytes = rrdset_create_localhost(
256
- "zfs"
257
- , "bytes"
258
- , NULL
259
- , ZFS_FAMILY_ACCESSES
260
- , NULL
261
- , "ZFS ARC L2 Read/Write Rate"
262
- , "kilobytes/s"
263
- , 2200
264
- , update_every
265
- , RRDSET_TYPE_AREA
266
- );
267
-
268
- rd_l2_read_bytes = rrddim_add(st_l2bytes, "read", NULL, 1, 1024, RRD_ALGORITHM_INCREMENTAL);
269
- rd_l2_write_bytes = rrddim_add(st_l2bytes, "write", NULL, -1, 1024, RRD_ALGORITHM_INCREMENTAL);
270
- }
271
- else
272
- rrdset_next(st_l2bytes);
273
-
274
- rrddim_set_by_pointer(st_l2bytes, rd_l2_read_bytes, arcstats.l2_read_bytes);
275
- rrddim_set_by_pointer(st_l2bytes, rd_l2_write_bytes, arcstats.l2_write_bytes);
276
- rrdset_done(st_l2bytes);
277
- }
278
-
279
- // --------------------------------------------------------------------
280
-
281
- {
282
- static RRDSET *st_ahits = NULL;
283
- static RRDDIM *rd_ahits = NULL;
284
- static RRDDIM *rd_amisses = NULL;
285
-
286
- if (unlikely(!st_ahits)) {
287
- st_ahits = rrdset_create_localhost(
288
- "zfs"
289
- , "hits"
290
- , NULL
291
- , ZFS_FAMILY_EFFICIENCY
292
- , NULL
293
- , "ZFS ARC Hits"
294
- , "percentage"
295
- , 2020
296
- , update_every
297
- , RRDSET_TYPE_STACKED
298
- );
299
-
300
- rd_ahits = rrddim_add(st_ahits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
301
- rd_amisses = rrddim_add(st_ahits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
302
- }
303
- else
304
- rrdset_next(st_ahits);
305
-
306
- rrddim_set_by_pointer(st_ahits, rd_ahits, arcstats.hits);
307
- rrddim_set_by_pointer(st_ahits, rd_amisses, arcstats.misses);
308
- rrdset_done(st_ahits);
309
- }
310
-
311
- // --------------------------------------------------------------------
312
-
313
- {
314
- static RRDSET *st_dhits = NULL;
315
- static RRDDIM *rd_dhits = NULL;
316
- static RRDDIM *rd_dmisses = NULL;
317
-
318
- if (unlikely(!st_dhits)) {
319
- st_dhits = rrdset_create_localhost(
320
- "zfs"
321
- , "dhits"
322
- , NULL
323
- , ZFS_FAMILY_EFFICIENCY
324
- , NULL
325
- , "ZFS Demand Hits"
326
- , "percentage"
327
- , 2030
328
- , update_every
329
- , RRDSET_TYPE_STACKED
330
- );
331
-
332
- rd_dhits = rrddim_add(st_dhits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
333
- rd_dmisses = rrddim_add(st_dhits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
334
- }
335
- else
336
- rrdset_next(st_dhits);
337
-
338
- rrddim_set_by_pointer(st_dhits, rd_dhits, dhit);
339
- rrddim_set_by_pointer(st_dhits, rd_dmisses, dmiss);
340
- rrdset_done(st_dhits);
341
- }
342
-
343
- // --------------------------------------------------------------------
344
-
345
- {
346
- static RRDSET *st_phits = NULL;
347
- static RRDDIM *rd_phits = NULL;
348
- static RRDDIM *rd_pmisses = NULL;
349
-
350
- if (unlikely(!st_phits)) {
351
- st_phits = rrdset_create_localhost(
352
- "zfs"
353
- , "phits"
354
- , NULL
355
- , ZFS_FAMILY_EFFICIENCY
356
- , NULL
357
- , "ZFS Prefetch Hits"
358
- , "percentage"
359
- , 2040
360
- , update_every
361
- , RRDSET_TYPE_STACKED
362
- );
363
-
364
- rd_phits = rrddim_add(st_phits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
365
- rd_pmisses = rrddim_add(st_phits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
366
- }
367
- else
368
- rrdset_next(st_phits);
369
-
370
- rrddim_set_by_pointer(st_phits, rd_phits, phit);
371
- rrddim_set_by_pointer(st_phits, rd_pmisses, pmiss);
372
- rrdset_done(st_phits);
373
- }
374
-
375
- // --------------------------------------------------------------------
376
-
377
- {
378
- static RRDSET *st_mhits = NULL;
379
- static RRDDIM *rd_mhits = NULL;
380
- static RRDDIM *rd_mmisses = NULL;
381
-
382
- if (unlikely(!st_mhits)) {
383
- st_mhits = rrdset_create_localhost(
384
- "zfs"
385
- , "mhits"
386
- , NULL
387
- , ZFS_FAMILY_EFFICIENCY
388
- , NULL
389
- , "ZFS Metadata Hits"
390
- , "percentage"
391
- , 2050
392
- , update_every
393
- , RRDSET_TYPE_STACKED
394
- );
395
-
396
- rd_mhits = rrddim_add(st_mhits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
397
- rd_mmisses = rrddim_add(st_mhits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
398
- }
399
- else
400
- rrdset_next(st_mhits);
401
-
402
- rrddim_set_by_pointer(st_mhits, rd_mhits, mhit);
403
- rrddim_set_by_pointer(st_mhits, rd_mmisses, mmiss);
404
- rrdset_done(st_mhits);
405
- }
406
-
407
- // --------------------------------------------------------------------
408
-
409
- if(likely(l2exist)) {
410
- static RRDSET *st_l2hits = NULL;
411
- static RRDDIM *rd_l2hits = NULL;
412
- static RRDDIM *rd_l2misses = NULL;
413
-
414
- if (unlikely(!st_l2hits)) {
415
- st_l2hits = rrdset_create_localhost(
416
- "zfs"
417
- , "l2hits"
418
- , NULL
419
- , ZFS_FAMILY_EFFICIENCY
420
- , NULL
421
- , "ZFS L2 Hits"
422
- , "percentage"
423
- , 2060
424
- , update_every
425
- , RRDSET_TYPE_STACKED
426
- );
427
-
428
- rd_l2hits = rrddim_add(st_l2hits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
429
- rd_l2misses = rrddim_add(st_l2hits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
430
- }
431
- else
432
- rrdset_next(st_l2hits);
433
-
434
- rrddim_set_by_pointer(st_l2hits, rd_l2hits, l2hit);
435
- rrddim_set_by_pointer(st_l2hits, rd_l2misses, l2miss);
436
- rrdset_done(st_l2hits);
437
- }
438
-
439
- // --------------------------------------------------------------------
440
-
441
- {
442
- static RRDSET *st_list_hits = NULL;
443
- static RRDDIM *rd_mfu = NULL;
444
- static RRDDIM *rd_mru = NULL;
445
- static RRDDIM *rd_mfug = NULL;
446
- static RRDDIM *rd_mrug = NULL;
447
-
448
- if (unlikely(!st_list_hits)) {
449
- st_list_hits = rrdset_create_localhost(
450
- "zfs"
451
- , "list_hits"
452
- , NULL
453
- , ZFS_FAMILY_EFFICIENCY
454
- , NULL
455
- , "ZFS List Hits"
456
- , "hits/s"
457
- , 2100
458
- , update_every
459
- , RRDSET_TYPE_AREA
460
- );
461
-
462
- rd_mfu = rrddim_add(st_list_hits, "mfu", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
463
- rd_mfug = rrddim_add(st_list_hits, "mfug", "mfu ghost", 1, 1, RRD_ALGORITHM_INCREMENTAL);
464
- rd_mru = rrddim_add(st_list_hits, "mru", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
465
- rd_mrug = rrddim_add(st_list_hits, "mrug", "mru ghost", 1, 1, RRD_ALGORITHM_INCREMENTAL);
466
- }
467
- else
468
- rrdset_next(st_list_hits);
469
-
470
- rrddim_set_by_pointer(st_list_hits, rd_mfu, arcstats.mfu_hits);
471
- rrddim_set_by_pointer(st_list_hits, rd_mru, arcstats.mru_hits);
472
- rrddim_set_by_pointer(st_list_hits, rd_mfug, arcstats.mfu_ghost_hits);
473
- rrddim_set_by_pointer(st_list_hits, rd_mrug, arcstats.mru_ghost_hits);
474
- rrdset_done(st_list_hits);
475
- }
476
-}
477
-
478
-static void generate_charts_arc_summary(int update_every) {
479
- unsigned long long arc_accesses_total = arcstats.hits + arcstats.misses;
480
- unsigned long long real_hits = arcstats.mfu_hits + arcstats.mru_hits;
481
- unsigned long long real_misses = arc_accesses_total - real_hits;
482
-
483
- //unsigned long long anon_hits = arcstats.hits - (arcstats.mfu_hits + arcstats.mru_hits + arcstats.mfu_ghost_hits + arcstats.mru_ghost_hits);
484
-
485
- unsigned long long arc_size = arcstats.size;
486
- unsigned long long mru_size = arcstats.p;
487
- //unsigned long long target_min_size = arcstats.c_min;
488
- //unsigned long long target_max_size = arcstats.c_max;
489
- unsigned long long target_size = arcstats.c;
490
- //unsigned long long target_size_ratio = (target_max_size / target_min_size);
491
-
492
- unsigned long long mfu_size;
493
- if(arc_size > target_size)
494
- mfu_size = arc_size - mru_size;
495
- else
496
- mfu_size = target_size - mru_size;
497
-
498
- // --------------------------------------------------------------------
499
-
500
- {
501
- static RRDSET *st_arc_size_breakdown = NULL;
502
- static RRDDIM *rd_most_recent = NULL;
503
- static RRDDIM *rd_most_frequent = NULL;
504
-
505
- if (unlikely(!st_arc_size_breakdown)) {
506
- st_arc_size_breakdown = rrdset_create_localhost(
507
- "zfs"
508
- , "arc_size_breakdown"
509
- , NULL
510
- , ZFS_FAMILY_EFFICIENCY
511
- , NULL
512
- , "ZFS ARC Size Breakdown"
513
- , "percentage"
514
- , 2020
515
- , update_every
516
- , RRDSET_TYPE_STACKED
517
- );
518
-
519
- rd_most_recent = rrddim_add(st_arc_size_breakdown, "recent", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_ROW_TOTAL);
520
- rd_most_frequent = rrddim_add(st_arc_size_breakdown, "frequent", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_ROW_TOTAL);
521
- }
522
- else
523
- rrdset_next(st_arc_size_breakdown);
524
-
525
- rrddim_set_by_pointer(st_arc_size_breakdown, rd_most_recent, mru_size);
526
- rrddim_set_by_pointer(st_arc_size_breakdown, rd_most_frequent, mfu_size);
527
- rrdset_done(st_arc_size_breakdown);
528
- }
529
-
530
- // --------------------------------------------------------------------
531
-
532
- {
533
- static RRDSET *st_memory = NULL;
534
-#ifndef __FreeBSD__
535
- static RRDDIM *rd_direct = NULL;
536
-#endif
537
- static RRDDIM *rd_throttled = NULL;
538
-#ifndef __FreeBSD__
539
- static RRDDIM *rd_indirect = NULL;
540
-#endif
541
-
542
- if (unlikely(!st_memory)) {
543
- st_memory = rrdset_create_localhost(
544
- "zfs"
545
- , "memory_ops"
546
- , NULL
547
- , ZFS_FAMILY_OPERATIONS
548
- , NULL
549
- , "ZFS Memory Operations"
550
- , "operations/s"
551
- , 2023
552
- , update_every
553
- , RRDSET_TYPE_LINE
554
- );
555
-
556
-#ifndef __FreeBSD__
557
- rd_direct = rrddim_add(st_memory, "direct", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
558
-#endif
559
- rd_throttled = rrddim_add(st_memory, "throttled", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
560
-#ifndef __FreeBSD__
561
- rd_indirect = rrddim_add(st_memory, "indirect", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
562
-#endif
563
- }
564
- else
565
- rrdset_next(st_memory);
566
-
567
-#ifndef __FreeBSD__
568
- rrddim_set_by_pointer(st_memory, rd_direct, arcstats.memory_direct_count);
569
-#endif
570
- rrddim_set_by_pointer(st_memory, rd_throttled, arcstats.memory_throttle_count);
571
-#ifndef __FreeBSD__
572
- rrddim_set_by_pointer(st_memory, rd_indirect, arcstats.memory_indirect_count);
573
-#endif
574
- rrdset_done(st_memory);
575
- }
576
-
577
- // --------------------------------------------------------------------
578
-
579
- {
580
- static RRDSET *st_important_ops = NULL;
581
- static RRDDIM *rd_deleted = NULL;
582
- static RRDDIM *rd_mutex_misses = NULL;
583
- static RRDDIM *rd_evict_skips = NULL;
584
- static RRDDIM *rd_hash_collisions = NULL;
585
-
586
- if (unlikely(!st_important_ops)) {
587
- st_important_ops = rrdset_create_localhost(
588
- "zfs"
589
- , "important_ops"
590
- , NULL
591
- , ZFS_FAMILY_OPERATIONS
592
- , NULL
593
- , "ZFS Important Operations"
594
- , "operations/s"
595
- , 2022
596
- , update_every
597
- , RRDSET_TYPE_LINE
598
- );
599
-
600
- rd_evict_skips = rrddim_add(st_important_ops, "eskip", "evict skip", 1, 1, RRD_ALGORITHM_INCREMENTAL);
601
- rd_deleted = rrddim_add(st_important_ops, "deleted", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
602
- rd_mutex_misses = rrddim_add(st_important_ops, "mtxmis", "mutex miss", 1, 1, RRD_ALGORITHM_INCREMENTAL);
603
- rd_hash_collisions = rrddim_add(st_important_ops, "hash_collisions", "hash collisions", 1, 1, RRD_ALGORITHM_INCREMENTAL);
604
- }
605
- else
606
- rrdset_next(st_important_ops);
607
-
608
- rrddim_set_by_pointer(st_important_ops, rd_deleted, arcstats.deleted);
609
- rrddim_set_by_pointer(st_important_ops, rd_evict_skips, arcstats.evict_skip);
610
- rrddim_set_by_pointer(st_important_ops, rd_mutex_misses, arcstats.mutex_miss);
611
- rrddim_set_by_pointer(st_important_ops, rd_hash_collisions, arcstats.hash_collisions);
612
- rrdset_done(st_important_ops);
613
- }
614
-
615
- // --------------------------------------------------------------------
616
-
617
- {
618
- static RRDSET *st_actual_hits = NULL;
619
- static RRDDIM *rd_actual_hits = NULL;
620
- static RRDDIM *rd_actual_misses = NULL;
621
-
622
- if (unlikely(!st_actual_hits)) {
623
- st_actual_hits = rrdset_create_localhost(
624
- "zfs"
625
- , "actual_hits"
626
- , NULL
627
- , ZFS_FAMILY_EFFICIENCY
628
- , NULL
629
- , "ZFS Actual Cache Hits"
630
- , "percentage"
631
- , 2019
632
- , update_every
633
- , RRDSET_TYPE_STACKED
634
- );
635
-
636
- rd_actual_hits = rrddim_add(st_actual_hits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
637
- rd_actual_misses = rrddim_add(st_actual_hits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
638
- }
639
- else
640
- rrdset_next(st_actual_hits);
641
-
642
- rrddim_set_by_pointer(st_actual_hits, rd_actual_hits, real_hits);
643
- rrddim_set_by_pointer(st_actual_hits, rd_actual_misses, real_misses);
644
- rrdset_done(st_actual_hits);
645
- }
646
-
647
- // --------------------------------------------------------------------
648
-
649
- {
650
- static RRDSET *st_demand_data_hits = NULL;
651
- static RRDDIM *rd_demand_data_hits = NULL;
652
- static RRDDIM *rd_demand_data_misses = NULL;
653
-
654
- if (unlikely(!st_demand_data_hits)) {
655
- st_demand_data_hits = rrdset_create_localhost(
656
- "zfs"
657
- , "demand_data_hits"
658
- , NULL
659
- , ZFS_FAMILY_EFFICIENCY
660
- , NULL
661
- , "ZFS Data Demand Efficiency"
662
- , "percentage"
663
- , 2031
664
- , update_every
665
- , RRDSET_TYPE_STACKED
666
- );
667
-
668
- rd_demand_data_hits = rrddim_add(st_demand_data_hits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
669
- rd_demand_data_misses = rrddim_add(st_demand_data_hits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
670
- }
671
- else
672
- rrdset_next(st_demand_data_hits);
673
-
674
- rrddim_set_by_pointer(st_demand_data_hits, rd_demand_data_hits, arcstats.demand_data_hits);
675
- rrddim_set_by_pointer(st_demand_data_hits, rd_demand_data_misses, arcstats.demand_data_misses);
676
- rrdset_done(st_demand_data_hits);
677
- }
678
-
679
- // --------------------------------------------------------------------
680
-
681
- {
682
- static RRDSET *st_prefetch_data_hits = NULL;
683
- static RRDDIM *rd_prefetch_data_hits = NULL;
684
- static RRDDIM *rd_prefetch_data_misses = NULL;
685
-
686
- if (unlikely(!st_prefetch_data_hits)) {
687
- st_prefetch_data_hits = rrdset_create_localhost(
688
- "zfs"
689
- , "prefetch_data_hits"
690
- , NULL
691
- , ZFS_FAMILY_EFFICIENCY
692
- , NULL
693
- , "ZFS Data Prefetch Efficiency"
694
- , "percentage"
695
- , 2032
696
- , update_every
697
- , RRDSET_TYPE_STACKED
698
- );
699
-
700
- rd_prefetch_data_hits = rrddim_add(st_prefetch_data_hits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
701
- rd_prefetch_data_misses = rrddim_add(st_prefetch_data_hits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
702
- }
703
- else
704
- rrdset_next(st_prefetch_data_hits);
705
-
706
- rrddim_set_by_pointer(st_prefetch_data_hits, rd_prefetch_data_hits, arcstats.prefetch_data_hits);
707
- rrddim_set_by_pointer(st_prefetch_data_hits, rd_prefetch_data_misses, arcstats.prefetch_data_misses);
708
- rrdset_done(st_prefetch_data_hits);
709
- }
710
-
711
- // --------------------------------------------------------------------
712
-
713
- {
714
- static RRDSET *st_hash_elements = NULL;
715
- static RRDDIM *rd_hash_elements_current = NULL;
716
- static RRDDIM *rd_hash_elements_max = NULL;
717
-
718
- if (unlikely(!st_hash_elements)) {
719
- st_hash_elements = rrdset_create_localhost(
720
- "zfs"
721
- , "hash_elements"
722
- , NULL
723
- , ZFS_FAMILY_HASH
724
- , NULL
725
- , "ZFS ARC Hash Elements"
726
- , "elements"
727
- , 2300
728
- , update_every
729
- , RRDSET_TYPE_LINE
730
- );
731
-
732
- rd_hash_elements_current = rrddim_add(st_hash_elements, "current", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
733
- rd_hash_elements_max = rrddim_add(st_hash_elements, "max", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
734
- }
735
- else
736
- rrdset_next(st_hash_elements);
737
-
738
- rrddim_set_by_pointer(st_hash_elements, rd_hash_elements_current, arcstats.hash_elements);
739
- rrddim_set_by_pointer(st_hash_elements, rd_hash_elements_max, arcstats.hash_elements_max);
740
- rrdset_done(st_hash_elements);
741
- }
742
-
743
- // --------------------------------------------------------------------
744
-
745
- {
746
- static RRDSET *st_hash_chains = NULL;
747
- static RRDDIM *rd_hash_chains_current = NULL;
748
- static RRDDIM *rd_hash_chains_max = NULL;
749
-
750
- if (unlikely(!st_hash_chains)) {
751
- st_hash_chains = rrdset_create_localhost(
752
- "zfs"
753
- , "hash_chains"
754
- , NULL
755
- , ZFS_FAMILY_HASH
756
- , NULL
757
- , "ZFS ARC Hash Chains"
758
- , "chains"
759
- , 2310
760
- , update_every
761
- , RRDSET_TYPE_LINE
762
- );
763
-
764
- rd_hash_chains_current = rrddim_add(st_hash_chains, "current", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
765
- rd_hash_chains_max = rrddim_add(st_hash_chains, "max", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
766
- }
767
- else
768
- rrdset_next(st_hash_chains);
769
-
770
- rrddim_set_by_pointer(st_hash_chains, rd_hash_chains_current, arcstats.hash_chains);
771
- rrddim_set_by_pointer(st_hash_chains, rd_hash_chains_max, arcstats.hash_chain_max);
772
- rrdset_done(st_hash_chains);
773
- }
774
-
775
- // --------------------------------------------------------------------
776
-
777
-}
778
-
779
-#ifdef __FreeBSD__
780
-// kstat.zfs.misc.arcstats
781
-int do_kstat_zfs_misc_arcstats(int update_every, usec_t dt) {
782
- (void)dt;
783
-
784
- unsigned long long l2_size;
785
- size_t uint64_t_size = sizeof(uint64_t);
786
- static struct mibs {
787
- int hits[5];
788
- int misses[5];
789
- int demand_data_hits[5];
790
- int demand_data_misses[5];
791
- int demand_metadata_hits[5];
792
- int demand_metadata_misses[5];
793
- int prefetch_data_hits[5];
794
- int prefetch_data_misses[5];
795
- int prefetch_metadata_hits[5];
796
- int prefetch_metadata_misses[5];
797
- int mru_hits[5];
798
- int mru_ghost_hits[5];
799
- int mfu_hits[5];
800
- int mfu_ghost_hits[5];
801
- int deleted[5];
802
- int mutex_miss[5];
803
- int evict_skip[5];
804
- int evict_not_enough[5];
805
- int evict_l2_cached[5];
806
- int evict_l2_eligible[5];
807
- int evict_l2_ineligible[5];
808
- int evict_l2_skip[5];
809
- int hash_elements[5];
810
- int hash_elements_max[5];
811
- int hash_collisions[5];
812
- int hash_chains[5];
813
- int hash_chain_max[5];
814
- int p[5];
815
- int c[5];
816
- int c_min[5];
817
- int c_max[5];
818
- int size[5];
819
- int hdr_size[5];
820
- int data_size[5];
821
- int metadata_size[5];
822
- int other_size[5];
823
- int anon_size[5];
824
- int anon_evictable_data[5];
825
- int anon_evictable_metadata[5];
826
- int mru_size[5];
827
- int mru_evictable_data[5];
828
- int mru_evictable_metadata[5];
829
- int mru_ghost_size[5];
830
- int mru_ghost_evictable_data[5];
831
- int mru_ghost_evictable_metadata[5];
832
- int mfu_size[5];
833
- int mfu_evictable_data[5];
834
- int mfu_evictable_metadata[5];
835
- int mfu_ghost_size[5];
836
- int mfu_ghost_evictable_data[5];
837
- int mfu_ghost_evictable_metadata[5];
838
- int l2_hits[5];
839
- int l2_misses[5];
840
- int l2_feeds[5];
841
- int l2_rw_clash[5];
842
- int l2_read_bytes[5];
843
- int l2_write_bytes[5];
844
- int l2_writes_sent[5];
845
- int l2_writes_done[5];
846
- int l2_writes_error[5];
847
- int l2_writes_lock_retry[5];
848
- int l2_evict_lock_retry[5];
849
- int l2_evict_reading[5];
850
- int l2_evict_l1cached[5];
851
- int l2_free_on_write[5];
852
- int l2_cdata_free_on_write[5];
853
- int l2_abort_lowmem[5];
854
- int l2_cksum_bad[5];
855
- int l2_io_error[5];
856
- int l2_size[5];
857
- int l2_asize[5];
858
- int l2_hdr_size[5];
859
- int l2_compress_successes[5];
860
- int l2_compress_zeros[5];
861
- int l2_compress_failures[5];
862
- int memory_throttle_count[5];
863
- int duplicate_buffers[5];
864
- int duplicate_buffers_size[5];
865
- int duplicate_reads[5];
866
- int memory_direct_count[5];
867
- int memory_indirect_count[5];
868
- int arc_no_grow[5];
869
- int arc_tempreserve[5];
870
- int arc_loaned_bytes[5];
871
- int arc_prune[5];
872
- int arc_meta_used[5];
873
- int arc_meta_limit[5];
874
- int arc_meta_max[5];
875
- int arc_meta_min[5];
876
- int arc_need_free[5];
877
- int arc_sys_free[5];
878
- } mibs;
879
-
880
- if(unlikely(sysctlbyname("kstat.zfs.misc.arcstats.l2_size", &l2_size, &uint64_t_size, NULL, 0)))
881
- return 0;
882
-
883
- if(likely(l2_size))
884
- l2exist = 1;
885
- else
886
- l2exist = 0;
887
-
888
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.hits", mibs.hits, arcstats.hits);
889
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.misses", mibs.misses, arcstats.misses);
890
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.demand_data_hits", mibs.demand_data_hits, arcstats.demand_data_hits);
891
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.demand_data_misses", mibs.demand_data_misses, arcstats.demand_data_misses);
892
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.demand_metadata_hits", mibs.demand_metadata_hits, arcstats.demand_metadata_hits);
893
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.demand_metadata_misses", mibs.demand_metadata_misses, arcstats.demand_metadata_misses);
894
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.prefetch_data_hits", mibs.prefetch_data_hits, arcstats.prefetch_data_hits);
895
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.prefetch_data_misses", mibs.prefetch_data_misses, arcstats.prefetch_data_misses);
896
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.prefetch_metadata_hits", mibs.prefetch_metadata_hits, arcstats.prefetch_metadata_hits);
897
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.prefetch_metadata_misses", mibs.prefetch_metadata_misses, arcstats.prefetch_metadata_misses);
898
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mru_hits", mibs.mru_hits, arcstats.mru_hits);
899
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mru_ghost_hits", mibs.mru_ghost_hits, arcstats.mru_ghost_hits);
900
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mfu_hits", mibs.mfu_hits, arcstats.mfu_hits);
901
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mfu_ghost_hits", mibs.mfu_ghost_hits, arcstats.mfu_ghost_hits);
902
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.deleted", mibs.deleted, arcstats.deleted);
903
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mutex_miss", mibs.mutex_miss, arcstats.mutex_miss);
904
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.evict_skip", mibs.evict_skip, arcstats.evict_skip);
905
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.evict_not_enough", mibs.evict_not_enough, arcstats.evict_not_enough);
906
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.evict_l2_cached", mibs.evict_l2_cached, arcstats.evict_l2_cached);
907
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.evict_l2_eligible", mibs.evict_l2_eligible, arcstats.evict_l2_eligible);
908
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.evict_l2_ineligible", mibs.evict_l2_ineligible, arcstats.evict_l2_ineligible);
909
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.evict_l2_skip", mibs.evict_l2_skip, arcstats.evict_l2_skip);
910
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.hash_elements", mibs.hash_elements, arcstats.hash_elements);
911
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.hash_elements_max", mibs.hash_elements_max, arcstats.hash_elements_max);
912
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.hash_collisions", mibs.hash_collisions, arcstats.hash_collisions);
913
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.hash_chains", mibs.hash_chains, arcstats.hash_chains);
914
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.hash_chain_max", mibs.hash_chain_max, arcstats.hash_chain_max);
915
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.p", mibs.p, arcstats.p);
916
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.c", mibs.c, arcstats.c);
917
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.c_min", mibs.c_min, arcstats.c_min);
918
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.c_max", mibs.c_max, arcstats.c_max);
919
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.size", mibs.size, arcstats.size);
920
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.hdr_size", mibs.hdr_size, arcstats.hdr_size);
921
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.data_size", mibs.data_size, arcstats.data_size);
922
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.metadata_size", mibs.metadata_size, arcstats.metadata_size);
923
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.other_size", mibs.other_size, arcstats.other_size);
924
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.anon_size", mibs.anon_size, arcstats.anon_size);
925
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.anon_evictable_data", mibs.anon_evictable_data, arcstats.anon_evictable_data);
926
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.anon_evictable_metadata", mibs.anon_evictable_metadata, arcstats.anon_evictable_metadata);
927
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mru_size", mibs.mru_size, arcstats.mru_size);
928
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mru_evictable_data", mibs.mru_evictable_data, arcstats.mru_evictable_data);
929
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mru_evictable_metadata", mibs.mru_evictable_metadata, arcstats.mru_evictable_metadata);
930
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mru_ghost_size", mibs.mru_ghost_size, arcstats.mru_ghost_size);
931
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mru_ghost_evictable_data", mibs.mru_ghost_evictable_data, arcstats.mru_ghost_evictable_data);
932
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mru_ghost_evictable_metadata", mibs.mru_ghost_evictable_metadata, arcstats.mru_ghost_evictable_metadata);
933
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mfu_size", mibs.mfu_size, arcstats.mfu_size);
934
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mfu_evictable_data", mibs.mfu_evictable_data, arcstats.mfu_evictable_data);
935
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mfu_evictable_metadata", mibs.mfu_evictable_metadata, arcstats.mfu_evictable_metadata);
936
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mfu_ghost_size", mibs.mfu_ghost_size, arcstats.mfu_ghost_size);
937
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mfu_ghost_evictable_data", mibs.mfu_ghost_evictable_data, arcstats.mfu_ghost_evictable_data);
938
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.mfu_ghost_evictable_metadata", mibs.mfu_ghost_evictable_metadata, arcstats.mfu_ghost_evictable_metadata);
939
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_hits", mibs.l2_hits, arcstats.l2_hits);
940
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_misses", mibs.l2_misses, arcstats.l2_misses);
941
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_feeds", mibs.l2_feeds, arcstats.l2_feeds);
942
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_rw_clash", mibs.l2_rw_clash, arcstats.l2_rw_clash);
943
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_read_bytes", mibs.l2_read_bytes, arcstats.l2_read_bytes);
944
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_write_bytes", mibs.l2_write_bytes, arcstats.l2_write_bytes);
945
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_writes_sent", mibs.l2_writes_sent, arcstats.l2_writes_sent);
946
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_writes_done", mibs.l2_writes_done, arcstats.l2_writes_done);
947
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_writes_error", mibs.l2_writes_error, arcstats.l2_writes_error);
948
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_writes_lock_retry", mibs.l2_writes_lock_retry, arcstats.l2_writes_lock_retry);
949
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_evict_lock_retry", mibs.l2_evict_lock_retry, arcstats.l2_evict_lock_retry);
950
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_evict_reading", mibs.l2_evict_reading, arcstats.l2_evict_reading);
951
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_evict_l1cached", mibs.l2_evict_l1cached, arcstats.l2_evict_l1cached);
952
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_free_on_write", mibs.l2_free_on_write, arcstats.l2_free_on_write);
953
- // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_cdata_free_on_write", mibs.l2_cdata_free_on_write, arcstats.l2_cdata_free_on_write);
954
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_abort_lowmem", mibs.l2_abort_lowmem, arcstats.l2_abort_lowmem);
955
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_cksum_bad", mibs.l2_cksum_bad, arcstats.l2_cksum_bad);
956
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_io_error", mibs.l2_io_error, arcstats.l2_io_error);
957
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_size", mibs.l2_size, arcstats.l2_size);
958
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_asize", mibs.l2_asize, arcstats.l2_asize);
959
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_hdr_size", mibs.l2_hdr_size, arcstats.l2_hdr_size);
960
- // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_compress_successes", mibs.l2_compress_successes, arcstats.l2_compress_successes);
961
- // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_compress_zeros", mibs.l2_compress_zeros, arcstats.l2_compress_zeros);
962
- // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.l2_compress_failures", mibs.l2_compress_failures, arcstats.l2_compress_failures);
963
- GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.memory_throttle_count", mibs.memory_throttle_count, arcstats.memory_throttle_count);
964
- // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.duplicate_buffers", mibs.duplicate_buffers, arcstats.duplicate_buffers);
965
- // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.duplicate_buffers_size", mibs.duplicate_buffers_size, arcstats.duplicate_buffers_size);
966
- // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.duplicate_reads", mibs.duplicate_reads, arcstats.duplicate_reads);
967
- // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.memory_direct_count", mibs.memory_direct_count, arcstats.memory_direct_count);
968
- // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.memory_indirect_count", mibs.memory_indirect_count, arcstats.memory_indirect_count);
969
- // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_no_grow", mibs.arc_no_grow, arcstats.arc_no_grow);
970
- // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_tempreserve", mibs.arc_tempreserve, arcstats.arc_tempreserve);
971
- // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_loaned_bytes", mibs.arc_loaned_bytes, arcstats.arc_loaned_bytes);
972
- // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_prune", mibs.arc_prune, arcstats.arc_prune);
973
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_meta_used", mibs.arc_meta_used, arcstats.arc_meta_used);
974
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_meta_limit", mibs.arc_meta_limit, arcstats.arc_meta_limit);
975
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_meta_max", mibs.arc_meta_max, arcstats.arc_meta_max);
976
- // not used: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_meta_min", mibs.arc_meta_min, arcstats.arc_meta_min);
977
- // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_need_free", mibs.arc_need_free, arcstats.arc_need_free);
978
- // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_sys_free", mibs.arc_sys_free, arcstats.arc_sys_free);
979
-
980
- generate_charts_arcstats(update_every);
981
- generate_charts_arc_summary(update_every);
982
-
983
- return 0;
984
-}
985
-
986
-#else
6
int do_proc_spl_kstat_zfs_arcstats(int update_every, usec_t dt) {
7
(void)dt;
8
9
static procfile *ff = NULL;
10
static ARL_BASE *arl_base = NULL;
11
12
+ l2exist = -1;
13
+
14
if(unlikely(!arl_base)) {
15
arl_base = arl_create("arcstats", NULL, 60);
16
@@ -1128,4 +149,3 @@ int do_proc_spl_kstat_zfs_arcstats(int update_every, usec_t dt) {
149
150
return 0;
151
}
1131
-#endif /* __FreeBSD__ */
src/zfs_common.c
new
+675
@@ -0,0 +1,675 @@
1
+#include "common.h"
2
+#include "zfs_common.h"
3
+
4
+void generate_charts_arcstats(int update_every) {
5
+
6
+ // ARC reads
7
+ unsigned long long aread = arcstats.hits + arcstats.misses;
8
+
9
+ // Demand reads
10
+ unsigned long long dhit = arcstats.demand_data_hits + arcstats.demand_metadata_hits;
11
+ unsigned long long dmiss = arcstats.demand_data_misses + arcstats.demand_metadata_misses;
12
+ unsigned long long dread = dhit + dmiss;
13
+
14
+ // Prefetch reads
15
+ unsigned long long phit = arcstats.prefetch_data_hits + arcstats.prefetch_metadata_hits;
16
+ unsigned long long pmiss = arcstats.prefetch_data_misses + arcstats.prefetch_metadata_misses;
17
+ unsigned long long pread = phit + pmiss;
18
+
19
+ // Metadata reads
20
+ unsigned long long mhit = arcstats.prefetch_metadata_hits + arcstats.demand_metadata_hits;
21
+ unsigned long long mmiss = arcstats.prefetch_metadata_misses + arcstats.demand_metadata_misses;
22
+ unsigned long long mread = mhit + mmiss;
23
+
24
+ // l2 reads
25
+ unsigned long long l2hit = arcstats.l2_hits + arcstats.l2_misses;
26
+ unsigned long long l2miss = arcstats.prefetch_metadata_misses + arcstats.demand_metadata_misses;
27
+ unsigned long long l2read = l2hit + l2miss;
28
+
29
+ // --------------------------------------------------------------------
30
+
31
+ {
32
+ static RRDSET *st_arc_size = NULL;
33
+ static RRDDIM *rd_arc_size = NULL;
34
+ static RRDDIM *rd_arc_target_size = NULL;
35
+ static RRDDIM *rd_arc_target_min_size = NULL;
36
+ static RRDDIM *rd_arc_target_max_size = NULL;
37
+
38
+ if (unlikely(!st_arc_size)) {
39
+ st_arc_size = rrdset_create_localhost(
40
+ "zfs"
41
+ , "arc_size"
42
+ , NULL
43
+ , ZFS_FAMILY_SIZE
44
+ , NULL
45
+ , "ZFS ARC Size"
46
+ , "MB"
47
+ , 2000
48
+ , update_every
49
+ , RRDSET_TYPE_AREA
50
+ );
51
+
52
+ rd_arc_size = rrddim_add(st_arc_size, "size", "arcsz", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
53
+ rd_arc_target_size = rrddim_add(st_arc_size, "target", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
54
+ rd_arc_target_min_size = rrddim_add(st_arc_size, "min", "min (hard limit)", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
55
+ rd_arc_target_max_size = rrddim_add(st_arc_size, "max", "max (high water)", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
56
+ }
57
+ else
58
+ rrdset_next(st_arc_size);
59
+
60
+ rrddim_set_by_pointer(st_arc_size, rd_arc_size, arcstats.size);
61
+ rrddim_set_by_pointer(st_arc_size, rd_arc_target_size, arcstats.c);
62
+ rrddim_set_by_pointer(st_arc_size, rd_arc_target_min_size, arcstats.c_min);
63
+ rrddim_set_by_pointer(st_arc_size, rd_arc_target_max_size, arcstats.c_max);
64
+ rrdset_done(st_arc_size);
65
+ }
66
+
67
+ // --------------------------------------------------------------------
68
+
69
+ if(likely(l2exist)) {
70
+ static RRDSET *st_l2_size = NULL;
71
+ static RRDDIM *rd_l2_size = NULL;
72
+ static RRDDIM *rd_l2_asize = NULL;
73
+
74
+ if (unlikely(!st_l2_size)) {
75
+ st_l2_size = rrdset_create_localhost(
76
+ "zfs"
77
+ , "l2_size"
78
+ , NULL
79
+ , ZFS_FAMILY_SIZE
80
+ , NULL
81
+ , "ZFS L2 ARC Size"
82
+ , "MB"
83
+ , 2000
84
+ , update_every
85
+ , RRDSET_TYPE_AREA
86
+ );
87
+
88
+ rd_l2_asize = rrddim_add(st_l2_size, "actual", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
89
+ rd_l2_size = rrddim_add(st_l2_size, "size", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
90
+ }
91
+ else
92
+ rrdset_next(st_l2_size);
93
+
94
+ rrddim_set_by_pointer(st_l2_size, rd_l2_size, arcstats.l2_size);
95
+ rrddim_set_by_pointer(st_l2_size, rd_l2_asize, arcstats.l2_asize);
96
+ rrdset_done(st_l2_size);
97
+ }
98
+
99
+ // --------------------------------------------------------------------
100
+
101
+ {
102
+ static RRDSET *st_reads = NULL;
103
+ static RRDDIM *rd_aread = NULL;
104
+ static RRDDIM *rd_dread = NULL;
105
+ static RRDDIM *rd_pread = NULL;
106
+ static RRDDIM *rd_mread = NULL;
107
+ static RRDDIM *rd_l2read = NULL;
108
+
109
+ if (unlikely(!st_reads)) {
110
+ st_reads = rrdset_create_localhost(
111
+ "zfs"
112
+ , "reads"
113
+ , NULL
114
+ , ZFS_FAMILY_ACCESSES
115
+ , NULL
116
+ , "ZFS Reads"
117
+ , "reads/s"
118
+ , 2010
119
+ , update_every
120
+ , RRDSET_TYPE_AREA
121
+ );
122
+
123
+ rd_aread = rrddim_add(st_reads, "areads", "arc", 1, 1, RRD_ALGORITHM_INCREMENTAL);
124
+ rd_dread = rrddim_add(st_reads, "dreads", "demand", 1, 1, RRD_ALGORITHM_INCREMENTAL);
125
+ rd_pread = rrddim_add(st_reads, "preads", "prefetch", 1, 1, RRD_ALGORITHM_INCREMENTAL);
126
+ rd_mread = rrddim_add(st_reads, "mreads", "metadata", 1, 1, RRD_ALGORITHM_INCREMENTAL);
127
+
128
+ if(l2exist)
129
+ rd_l2read = rrddim_add(st_reads, "l2reads", "l2", 1, 1, RRD_ALGORITHM_INCREMENTAL);
130
+ }
131
+ else
132
+ rrdset_next(st_reads);
133
+
134
+ rrddim_set_by_pointer(st_reads, rd_aread, aread);
135
+ rrddim_set_by_pointer(st_reads, rd_dread, dread);
136
+ rrddim_set_by_pointer(st_reads, rd_pread, pread);
137
+ rrddim_set_by_pointer(st_reads, rd_mread, mread);
138
+
139
+ if(l2exist)
140
+ rrddim_set_by_pointer(st_reads, rd_l2read, l2read);
141
+
142
+ rrdset_done(st_reads);
143
+ }
144
+
145
+ // --------------------------------------------------------------------
146
+
147
+ if(likely(l2exist)) {
148
+ static RRDSET *st_l2bytes = NULL;
149
+ static RRDDIM *rd_l2_read_bytes = NULL;
150
+ static RRDDIM *rd_l2_write_bytes = NULL;
151
+
152
+ if (unlikely(!st_l2bytes)) {
153
+ st_l2bytes = rrdset_create_localhost(
154
+ "zfs"
155
+ , "bytes"
156
+ , NULL
157
+ , ZFS_FAMILY_ACCESSES
158
+ , NULL
159
+ , "ZFS ARC L2 Read/Write Rate"
160
+ , "kilobytes/s"
161
+ , 2200
162
+ , update_every
163
+ , RRDSET_TYPE_AREA
164
+ );
165
+
166
+ rd_l2_read_bytes = rrddim_add(st_l2bytes, "read", NULL, 1, 1024, RRD_ALGORITHM_INCREMENTAL);
167
+ rd_l2_write_bytes = rrddim_add(st_l2bytes, "write", NULL, -1, 1024, RRD_ALGORITHM_INCREMENTAL);
168
+ }
169
+ else
170
+ rrdset_next(st_l2bytes);
171
+
172
+ rrddim_set_by_pointer(st_l2bytes, rd_l2_read_bytes, arcstats.l2_read_bytes);
173
+ rrddim_set_by_pointer(st_l2bytes, rd_l2_write_bytes, arcstats.l2_write_bytes);
174
+ rrdset_done(st_l2bytes);
175
+ }
176
+
177
+ // --------------------------------------------------------------------
178
+
179
+ {
180
+ static RRDSET *st_ahits = NULL;
181
+ static RRDDIM *rd_ahits = NULL;
182
+ static RRDDIM *rd_amisses = NULL;
183
+
184
+ if (unlikely(!st_ahits)) {
185
+ st_ahits = rrdset_create_localhost(
186
+ "zfs"
187
+ , "hits"
188
+ , NULL
189
+ , ZFS_FAMILY_EFFICIENCY
190
+ , NULL
191
+ , "ZFS ARC Hits"
192
+ , "percentage"
193
+ , 2020
194
+ , update_every
195
+ , RRDSET_TYPE_STACKED
196
+ );
197
+
198
+ rd_ahits = rrddim_add(st_ahits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
199
+ rd_amisses = rrddim_add(st_ahits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
200
+ }
201
+ else
202
+ rrdset_next(st_ahits);
203
+
204
+ rrddim_set_by_pointer(st_ahits, rd_ahits, arcstats.hits);
205
+ rrddim_set_by_pointer(st_ahits, rd_amisses, arcstats.misses);
206
+ rrdset_done(st_ahits);
207
+ }
208
+
209
+ // --------------------------------------------------------------------
210
+
211
+ {
212
+ static RRDSET *st_dhits = NULL;
213
+ static RRDDIM *rd_dhits = NULL;
214
+ static RRDDIM *rd_dmisses = NULL;
215
+
216
+ if (unlikely(!st_dhits)) {
217
+ st_dhits = rrdset_create_localhost(
218
+ "zfs"
219
+ , "dhits"
220
+ , NULL
221
+ , ZFS_FAMILY_EFFICIENCY
222
+ , NULL
223
+ , "ZFS Demand Hits"
224
+ , "percentage"
225
+ , 2030
226
+ , update_every
227
+ , RRDSET_TYPE_STACKED
228
+ );
229
+
230
+ rd_dhits = rrddim_add(st_dhits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
231
+ rd_dmisses = rrddim_add(st_dhits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
232
+ }
233
+ else
234
+ rrdset_next(st_dhits);
235
+
236
+ rrddim_set_by_pointer(st_dhits, rd_dhits, dhit);
237
+ rrddim_set_by_pointer(st_dhits, rd_dmisses, dmiss);
238
+ rrdset_done(st_dhits);
239
+ }
240
+
241
+ // --------------------------------------------------------------------
242
+
243
+ {
244
+ static RRDSET *st_phits = NULL;
245
+ static RRDDIM *rd_phits = NULL;
246
+ static RRDDIM *rd_pmisses = NULL;
247
+
248
+ if (unlikely(!st_phits)) {
249
+ st_phits = rrdset_create_localhost(
250
+ "zfs"
251
+ , "phits"
252
+ , NULL
253
+ , ZFS_FAMILY_EFFICIENCY
254
+ , NULL
255
+ , "ZFS Prefetch Hits"
256
+ , "percentage"
257
+ , 2040
258
+ , update_every
259
+ , RRDSET_TYPE_STACKED
260
+ );
261
+
262
+ rd_phits = rrddim_add(st_phits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
263
+ rd_pmisses = rrddim_add(st_phits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
264
+ }
265
+ else
266
+ rrdset_next(st_phits);
267
+
268
+ rrddim_set_by_pointer(st_phits, rd_phits, phit);
269
+ rrddim_set_by_pointer(st_phits, rd_pmisses, pmiss);
270
+ rrdset_done(st_phits);
271
+ }
272
+
273
+ // --------------------------------------------------------------------
274
+
275
+ {
276
+ static RRDSET *st_mhits = NULL;
277
+ static RRDDIM *rd_mhits = NULL;
278
+ static RRDDIM *rd_mmisses = NULL;
279
+
280
+ if (unlikely(!st_mhits)) {
281
+ st_mhits = rrdset_create_localhost(
282
+ "zfs"
283
+ , "mhits"
284
+ , NULL
285
+ , ZFS_FAMILY_EFFICIENCY
286
+ , NULL
287
+ , "ZFS Metadata Hits"
288
+ , "percentage"
289
+ , 2050
290
+ , update_every
291
+ , RRDSET_TYPE_STACKED
292
+ );
293
+
294
+ rd_mhits = rrddim_add(st_mhits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
295
+ rd_mmisses = rrddim_add(st_mhits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
296
+ }
297
+ else
298
+ rrdset_next(st_mhits);
299
+
300
+ rrddim_set_by_pointer(st_mhits, rd_mhits, mhit);
301
+ rrddim_set_by_pointer(st_mhits, rd_mmisses, mmiss);
302
+ rrdset_done(st_mhits);
303
+ }
304
+
305
+ // --------------------------------------------------------------------
306
+
307
+ if(likely(l2exist)) {
308
+ static RRDSET *st_l2hits = NULL;
309
+ static RRDDIM *rd_l2hits = NULL;
310
+ static RRDDIM *rd_l2misses = NULL;
311
+
312
+ if (unlikely(!st_l2hits)) {
313
+ st_l2hits = rrdset_create_localhost(
314
+ "zfs"
315
+ , "l2hits"
316
+ , NULL
317
+ , ZFS_FAMILY_EFFICIENCY
318
+ , NULL
319
+ , "ZFS L2 Hits"
320
+ , "percentage"
321
+ , 2060
322
+ , update_every
323
+ , RRDSET_TYPE_STACKED
324
+ );
325
+
326
+ rd_l2hits = rrddim_add(st_l2hits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
327
+ rd_l2misses = rrddim_add(st_l2hits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
328
+ }
329
+ else
330
+ rrdset_next(st_l2hits);
331
+
332
+ rrddim_set_by_pointer(st_l2hits, rd_l2hits, l2hit);
333
+ rrddim_set_by_pointer(st_l2hits, rd_l2misses, l2miss);
334
+ rrdset_done(st_l2hits);
335
+ }
336
+
337
+ // --------------------------------------------------------------------
338
+
339
+ {
340
+ static RRDSET *st_list_hits = NULL;
341
+ static RRDDIM *rd_mfu = NULL;
342
+ static RRDDIM *rd_mru = NULL;
343
+ static RRDDIM *rd_mfug = NULL;
344
+ static RRDDIM *rd_mrug = NULL;
345
+
346
+ if (unlikely(!st_list_hits)) {
347
+ st_list_hits = rrdset_create_localhost(
348
+ "zfs"
349
+ , "list_hits"
350
+ , NULL
351
+ , ZFS_FAMILY_EFFICIENCY
352
+ , NULL
353
+ , "ZFS List Hits"
354
+ , "hits/s"
355
+ , 2100
356
+ , update_every
357
+ , RRDSET_TYPE_AREA
358
+ );
359
+
360
+ rd_mfu = rrddim_add(st_list_hits, "mfu", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
361
+ rd_mfug = rrddim_add(st_list_hits, "mfug", "mfu ghost", 1, 1, RRD_ALGORITHM_INCREMENTAL);
362
+ rd_mru = rrddim_add(st_list_hits, "mru", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
363
+ rd_mrug = rrddim_add(st_list_hits, "mrug", "mru ghost", 1, 1, RRD_ALGORITHM_INCREMENTAL);
364
+ }
365
+ else
366
+ rrdset_next(st_list_hits);
367
+
368
+ rrddim_set_by_pointer(st_list_hits, rd_mfu, arcstats.mfu_hits);
369
+ rrddim_set_by_pointer(st_list_hits, rd_mru, arcstats.mru_hits);
370
+ rrddim_set_by_pointer(st_list_hits, rd_mfug, arcstats.mfu_ghost_hits);
371
+ rrddim_set_by_pointer(st_list_hits, rd_mrug, arcstats.mru_ghost_hits);
372
+ rrdset_done(st_list_hits);
373
+ }
374
+}
375
+
376
+void generate_charts_arc_summary(int update_every) {
377
+ unsigned long long arc_accesses_total = arcstats.hits + arcstats.misses;
378
+ unsigned long long real_hits = arcstats.mfu_hits + arcstats.mru_hits;
379
+ unsigned long long real_misses = arc_accesses_total - real_hits;
380
+
381
+ //unsigned long long anon_hits = arcstats.hits - (arcstats.mfu_hits + arcstats.mru_hits + arcstats.mfu_ghost_hits + arcstats.mru_ghost_hits);
382
+
383
+ unsigned long long arc_size = arcstats.size;
384
+ unsigned long long mru_size = arcstats.p;
385
+ //unsigned long long target_min_size = arcstats.c_min;
386
+ //unsigned long long target_max_size = arcstats.c_max;
387
+ unsigned long long target_size = arcstats.c;
388
+ //unsigned long long target_size_ratio = (target_max_size / target_min_size);
389
+
390
+ unsigned long long mfu_size;
391
+ if(arc_size > target_size)
392
+ mfu_size = arc_size - mru_size;
393
+ else
394
+ mfu_size = target_size - mru_size;
395
+
396
+ // --------------------------------------------------------------------
397
+
398
+ {
399
+ static RRDSET *st_arc_size_breakdown = NULL;
400
+ static RRDDIM *rd_most_recent = NULL;
401
+ static RRDDIM *rd_most_frequent = NULL;
402
+
403
+ if (unlikely(!st_arc_size_breakdown)) {
404
+ st_arc_size_breakdown = rrdset_create_localhost(
405
+ "zfs"
406
+ , "arc_size_breakdown"
407
+ , NULL
408
+ , ZFS_FAMILY_EFFICIENCY
409
+ , NULL
410
+ , "ZFS ARC Size Breakdown"
411
+ , "percentage"
412
+ , 2020
413
+ , update_every
414
+ , RRDSET_TYPE_STACKED
415
+ );
416
+
417
+ rd_most_recent = rrddim_add(st_arc_size_breakdown, "recent", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_ROW_TOTAL);
418
+ rd_most_frequent = rrddim_add(st_arc_size_breakdown, "frequent", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_ROW_TOTAL);
419
+ }
420
+ else
421
+ rrdset_next(st_arc_size_breakdown);
422
+
423
+ rrddim_set_by_pointer(st_arc_size_breakdown, rd_most_recent, mru_size);
424
+ rrddim_set_by_pointer(st_arc_size_breakdown, rd_most_frequent, mfu_size);
425
+ rrdset_done(st_arc_size_breakdown);
426
+ }
427
+
428
+ // --------------------------------------------------------------------
429
+
430
+ {
431
+ static RRDSET *st_memory = NULL;
432
+#ifndef __FreeBSD__
433
+ static RRDDIM *rd_direct = NULL;
434
+#endif
435
+ static RRDDIM *rd_throttled = NULL;
436
+#ifndef __FreeBSD__
437
+ static RRDDIM *rd_indirect = NULL;
438
+#endif
439
+
440
+ if (unlikely(!st_memory)) {
441
+ st_memory = rrdset_create_localhost(
442
+ "zfs"
443
+ , "memory_ops"
444
+ , NULL
445
+ , ZFS_FAMILY_OPERATIONS
446
+ , NULL
447
+ , "ZFS Memory Operations"
448
+ , "operations/s"
449
+ , 2023
450
+ , update_every
451
+ , RRDSET_TYPE_LINE
452
+ );
453
+
454
+#ifndef __FreeBSD__
455
+ rd_direct = rrddim_add(st_memory, "direct", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
456
+#endif
457
+ rd_throttled = rrddim_add(st_memory, "throttled", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
458
+#ifndef __FreeBSD__
459
+ rd_indirect = rrddim_add(st_memory, "indirect", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
460
+#endif
461
+ }
462
+ else
463
+ rrdset_next(st_memory);
464
+
465
+#ifndef __FreeBSD__
466
+ rrddim_set_by_pointer(st_memory, rd_direct, arcstats.memory_direct_count);
467
+#endif
468
+ rrddim_set_by_pointer(st_memory, rd_throttled, arcstats.memory_throttle_count);
469
+#ifndef __FreeBSD__
470
+ rrddim_set_by_pointer(st_memory, rd_indirect, arcstats.memory_indirect_count);
471
+#endif
472
+ rrdset_done(st_memory);
473
+ }
474
+
475
+ // --------------------------------------------------------------------
476
+
477
+ {
478
+ static RRDSET *st_important_ops = NULL;
479
+ static RRDDIM *rd_deleted = NULL;
480
+ static RRDDIM *rd_mutex_misses = NULL;
481
+ static RRDDIM *rd_evict_skips = NULL;
482
+ static RRDDIM *rd_hash_collisions = NULL;
483
+
484
+ if (unlikely(!st_important_ops)) {
485
+ st_important_ops = rrdset_create_localhost(
486
+ "zfs"
487
+ , "important_ops"
488
+ , NULL
489
+ , ZFS_FAMILY_OPERATIONS
490
+ , NULL
491
+ , "ZFS Important Operations"
492
+ , "operations/s"
493
+ , 2022
494
+ , update_every
495
+ , RRDSET_TYPE_LINE
496
+ );
497
+
498
+ rd_evict_skips = rrddim_add(st_important_ops, "eskip", "evict skip", 1, 1, RRD_ALGORITHM_INCREMENTAL);
499
+ rd_deleted = rrddim_add(st_important_ops, "deleted", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
500
+ rd_mutex_misses = rrddim_add(st_important_ops, "mtxmis", "mutex miss", 1, 1, RRD_ALGORITHM_INCREMENTAL);
501
+ rd_hash_collisions = rrddim_add(st_important_ops, "hash_collisions", "hash collisions", 1, 1, RRD_ALGORITHM_INCREMENTAL);
502
+ }
503
+ else
504
+ rrdset_next(st_important_ops);
505
+
506
+ rrddim_set_by_pointer(st_important_ops, rd_deleted, arcstats.deleted);
507
+ rrddim_set_by_pointer(st_important_ops, rd_evict_skips, arcstats.evict_skip);
508
+ rrddim_set_by_pointer(st_important_ops, rd_mutex_misses, arcstats.mutex_miss);
509
+ rrddim_set_by_pointer(st_important_ops, rd_hash_collisions, arcstats.hash_collisions);
510
+ rrdset_done(st_important_ops);
511
+ }
512
+
513
+ // --------------------------------------------------------------------
514
+
515
+ {
516
+ static RRDSET *st_actual_hits = NULL;
517
+ static RRDDIM *rd_actual_hits = NULL;
518
+ static RRDDIM *rd_actual_misses = NULL;
519
+
520
+ if (unlikely(!st_actual_hits)) {
521
+ st_actual_hits = rrdset_create_localhost(
522
+ "zfs"
523
+ , "actual_hits"
524
+ , NULL
525
+ , ZFS_FAMILY_EFFICIENCY
526
+ , NULL
527
+ , "ZFS Actual Cache Hits"
528
+ , "percentage"
529
+ , 2019
530
+ , update_every
531
+ , RRDSET_TYPE_STACKED
532
+ );
533
+
534
+ rd_actual_hits = rrddim_add(st_actual_hits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
535
+ rd_actual_misses = rrddim_add(st_actual_hits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
536
+ }
537
+ else
538
+ rrdset_next(st_actual_hits);
539
+
540
+ rrddim_set_by_pointer(st_actual_hits, rd_actual_hits, real_hits);
541
+ rrddim_set_by_pointer(st_actual_hits, rd_actual_misses, real_misses);
542
+ rrdset_done(st_actual_hits);
543
+ }
544
+
545
+ // --------------------------------------------------------------------
546
+
547
+ {
548
+ static RRDSET *st_demand_data_hits = NULL;
549
+ static RRDDIM *rd_demand_data_hits = NULL;
550
+ static RRDDIM *rd_demand_data_misses = NULL;
551
+
552
+ if (unlikely(!st_demand_data_hits)) {
553
+ st_demand_data_hits = rrdset_create_localhost(
554
+ "zfs"
555
+ , "demand_data_hits"
556
+ , NULL
557
+ , ZFS_FAMILY_EFFICIENCY
558
+ , NULL
559
+ , "ZFS Data Demand Efficiency"
560
+ , "percentage"
561
+ , 2031
562
+ , update_every
563
+ , RRDSET_TYPE_STACKED
564
+ );
565
+
566
+ rd_demand_data_hits = rrddim_add(st_demand_data_hits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
567
+ rd_demand_data_misses = rrddim_add(st_demand_data_hits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
568
+ }
569
+ else
570
+ rrdset_next(st_demand_data_hits);
571
+
572
+ rrddim_set_by_pointer(st_demand_data_hits, rd_demand_data_hits, arcstats.demand_data_hits);
573
+ rrddim_set_by_pointer(st_demand_data_hits, rd_demand_data_misses, arcstats.demand_data_misses);
574
+ rrdset_done(st_demand_data_hits);
575
+ }
576
+
577
+ // --------------------------------------------------------------------
578
+
579
+ {
580
+ static RRDSET *st_prefetch_data_hits = NULL;
581
+ static RRDDIM *rd_prefetch_data_hits = NULL;
582
+ static RRDDIM *rd_prefetch_data_misses = NULL;
583
+
584
+ if (unlikely(!st_prefetch_data_hits)) {
585
+ st_prefetch_data_hits = rrdset_create_localhost(
586
+ "zfs"
587
+ , "prefetch_data_hits"
588
+ , NULL
589
+ , ZFS_FAMILY_EFFICIENCY
590
+ , NULL
591
+ , "ZFS Data Prefetch Efficiency"
592
+ , "percentage"
593
+ , 2032
594
+ , update_every
595
+ , RRDSET_TYPE_STACKED
596
+ );
597
+
598
+ rd_prefetch_data_hits = rrddim_add(st_prefetch_data_hits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
599
+ rd_prefetch_data_misses = rrddim_add(st_prefetch_data_hits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
600
+ }
601
+ else
602
+ rrdset_next(st_prefetch_data_hits);
603
+
604
+ rrddim_set_by_pointer(st_prefetch_data_hits, rd_prefetch_data_hits, arcstats.prefetch_data_hits);
605
+ rrddim_set_by_pointer(st_prefetch_data_hits, rd_prefetch_data_misses, arcstats.prefetch_data_misses);
606
+ rrdset_done(st_prefetch_data_hits);
607
+ }
608
+
609
+ // --------------------------------------------------------------------
610
+
611
+ {
612
+ static RRDSET *st_hash_elements = NULL;
613
+ static RRDDIM *rd_hash_elements_current = NULL;
614
+ static RRDDIM *rd_hash_elements_max = NULL;
615
+
616
+ if (unlikely(!st_hash_elements)) {
617
+ st_hash_elements = rrdset_create_localhost(
618
+ "zfs"
619
+ , "hash_elements"
620
+ , NULL
621
+ , ZFS_FAMILY_HASH
622
+ , NULL
623
+ , "ZFS ARC Hash Elements"
624
+ , "elements"
625
+ , 2300
626
+ , update_every
627
+ , RRDSET_TYPE_LINE
628
+ );
629
+
630
+ rd_hash_elements_current = rrddim_add(st_hash_elements, "current", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
631
+ rd_hash_elements_max = rrddim_add(st_hash_elements, "max", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
632
+ }
633
+ else
634
+ rrdset_next(st_hash_elements);
635
+
636
+ rrddim_set_by_pointer(st_hash_elements, rd_hash_elements_current, arcstats.hash_elements);
637
+ rrddim_set_by_pointer(st_hash_elements, rd_hash_elements_max, arcstats.hash_elements_max);
638
+ rrdset_done(st_hash_elements);
639
+ }
640
+
641
+ // --------------------------------------------------------------------
642
+
643
+ {
644
+ static RRDSET *st_hash_chains = NULL;
645
+ static RRDDIM *rd_hash_chains_current = NULL;
646
+ static RRDDIM *rd_hash_chains_max = NULL;
647
+
648
+ if (unlikely(!st_hash_chains)) {
649
+ st_hash_chains = rrdset_create_localhost(
650
+ "zfs"
651
+ , "hash_chains"
652
+ , NULL
653
+ , ZFS_FAMILY_HASH
654
+ , NULL
655
+ , "ZFS ARC Hash Chains"
656
+ , "chains"
657
+ , 2310
658
+ , update_every
659
+ , RRDSET_TYPE_LINE
660
+ );
661
+
662
+ rd_hash_chains_current = rrddim_add(st_hash_chains, "current", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
663
+ rd_hash_chains_max = rrddim_add(st_hash_chains, "max", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
664
+ }
665
+ else
666
+ rrdset_next(st_hash_chains);
667
+
668
+ rrddim_set_by_pointer(st_hash_chains, rd_hash_chains_current, arcstats.hash_chains);
669
+ rrddim_set_by_pointer(st_hash_chains, rd_hash_chains_max, arcstats.hash_chain_max);
670
+ rrdset_done(st_hash_chains);
671
+ }
672
+
673
+ // --------------------------------------------------------------------
674
+
675
+}
\ No newline at end of file
src/zfs_common.h
new
+109
@@ -0,0 +1,109 @@
1
+#ifndef NETDATA_ZFS_COMMON_H
2
+#define NETDATA_ZFS_COMMON_H
3
+
4
+#define ZFS_FAMILY_SIZE "size"
5
+#define ZFS_FAMILY_EFFICIENCY "efficiency"
6
+#define ZFS_FAMILY_ACCESSES "accesses"
7
+#define ZFS_FAMILY_OPERATIONS "operations"
8
+#define ZFS_FAMILY_HASH "hashes"
9
+
10
+static struct arcstats {
11
+ unsigned long long hits;
12
+ unsigned long long misses;
13
+ unsigned long long demand_data_hits;
14
+ unsigned long long demand_data_misses;
15
+ unsigned long long demand_metadata_hits;
16
+ unsigned long long demand_metadata_misses;
17
+ unsigned long long prefetch_data_hits;
18
+ unsigned long long prefetch_data_misses;
19
+ unsigned long long prefetch_metadata_hits;
20
+ unsigned long long prefetch_metadata_misses;
21
+ unsigned long long mru_hits;
22
+ unsigned long long mru_ghost_hits;
23
+ unsigned long long mfu_hits;
24
+ unsigned long long mfu_ghost_hits;
25
+ unsigned long long deleted;
26
+ unsigned long long mutex_miss;
27
+ unsigned long long evict_skip;
28
+ unsigned long long evict_not_enough;
29
+ unsigned long long evict_l2_cached;
30
+ unsigned long long evict_l2_eligible;
31
+ unsigned long long evict_l2_ineligible;
32
+ unsigned long long evict_l2_skip;
33
+ unsigned long long hash_elements;
34
+ unsigned long long hash_elements_max;
35
+ unsigned long long hash_collisions;
36
+ unsigned long long hash_chains;
37
+ unsigned long long hash_chain_max;
38
+ unsigned long long p;
39
+ unsigned long long c;
40
+ unsigned long long c_min;
41
+ unsigned long long c_max;
42
+ unsigned long long size;
43
+ unsigned long long hdr_size;
44
+ unsigned long long data_size;
45
+ unsigned long long metadata_size;
46
+ unsigned long long other_size;
47
+ unsigned long long anon_size;
48
+ unsigned long long anon_evictable_data;
49
+ unsigned long long anon_evictable_metadata;
50
+ unsigned long long mru_size;
51
+ unsigned long long mru_evictable_data;
52
+ unsigned long long mru_evictable_metadata;
53
+ unsigned long long mru_ghost_size;
54
+ unsigned long long mru_ghost_evictable_data;
55
+ unsigned long long mru_ghost_evictable_metadata;
56
+ unsigned long long mfu_size;
57
+ unsigned long long mfu_evictable_data;
58
+ unsigned long long mfu_evictable_metadata;
59
+ unsigned long long mfu_ghost_size;
60
+ unsigned long long mfu_ghost_evictable_data;
61
+ unsigned long long mfu_ghost_evictable_metadata;
62
+ unsigned long long l2_hits;
63
+ unsigned long long l2_misses;
64
+ unsigned long long l2_feeds;
65
+ unsigned long long l2_rw_clash;
66
+ unsigned long long l2_read_bytes;
67
+ unsigned long long l2_write_bytes;
68
+ unsigned long long l2_writes_sent;
69
+ unsigned long long l2_writes_done;
70
+ unsigned long long l2_writes_error;
71
+ unsigned long long l2_writes_lock_retry;
72
+ unsigned long long l2_evict_lock_retry;
73
+ unsigned long long l2_evict_reading;
74
+ unsigned long long l2_evict_l1cached;
75
+ unsigned long long l2_free_on_write;
76
+ unsigned long long l2_cdata_free_on_write;
77
+ unsigned long long l2_abort_lowmem;
78
+ unsigned long long l2_cksum_bad;
79
+ unsigned long long l2_io_error;
80
+ unsigned long long l2_size;
81
+ unsigned long long l2_asize;
82
+ unsigned long long l2_hdr_size;
83
+ unsigned long long l2_compress_successes;
84
+ unsigned long long l2_compress_zeros;
85
+ unsigned long long l2_compress_failures;
86
+ unsigned long long memory_throttle_count;
87
+ unsigned long long duplicate_buffers;
88
+ unsigned long long duplicate_buffers_size;
89
+ unsigned long long duplicate_reads;
90
+ unsigned long long memory_direct_count;
91
+ unsigned long long memory_indirect_count;
92
+ unsigned long long arc_no_grow;
93
+ unsigned long long arc_tempreserve;
94
+ unsigned long long arc_loaned_bytes;
95
+ unsigned long long arc_prune;
96
+ unsigned long long arc_meta_used;
97
+ unsigned long long arc_meta_limit;
98
+ unsigned long long arc_meta_max;
99
+ unsigned long long arc_meta_min;
100
+ unsigned long long arc_need_free;
101
+ unsigned long long arc_sys_free;
102
+} arcstats = { 0 };
103
+
104
+int l2exist;
105
+
106
+void generate_charts_arcstats(int update_every);
107
+void generate_charts_arc_summary(int update_every);
108
+
109
+#endif //NETDATA_ZFS_COMMON_H