Lines 1-232
Link Here
|
1 |
--- src/zfs_arc.c.orig 2012-04-02 08:04:58.000000000 +0000 |
1 |
diff --git configure.in configure.in |
2 |
+++ src/zfs_arc.c 2012-11-24 17:54:21.715129054 +0000 |
2 |
index 4660787..54fd9d8 100644 |
3 |
@@ -25,11 +25,57 @@ |
3 |
--- configure.in |
4 |
#include "common.h" |
4 |
+++ configure.in |
5 |
#include "plugin.h" |
5 |
@@ -4843,6 +4843,12 @@ then |
|
|
6 |
plugin_users="yes" |
7 |
fi |
6 |
|
8 |
|
7 |
+#if !defined(HAVE_LIBKSTAT) && defined(HAVE_SYSCTLBYNAME) |
9 |
+# FreeBSD |
8 |
+#include <sys/sysctl.h> |
10 |
+if test "x$have_struct_kinfo_proc_freebsd" = "xyes" |
9 |
+#endif |
11 |
+then |
|
|
12 |
+ plugin_zfs_arc="yes" |
13 |
+fi |
10 |
+ |
14 |
+ |
11 |
/* |
15 |
m4_divert_once([HELP_ENABLE], [ |
|
|
16 |
collectd plugins:]) |
17 |
|
18 |
diff --git src/zfs_arc.c src/zfs_arc.c |
19 |
index aa90019..17e8513 100644 |
20 |
--- src/zfs_arc.c |
21 |
+++ src/zfs_arc.c |
22 |
@@ -19,6 +19,8 @@ |
23 |
* Authors: |
24 |
* Anthony Dewhurst <dewhurst at gmail> |
25 |
* Aurelien Rougemont <beorn at gandi.net> |
26 |
+ * Brad Davis <brd at FreeBSD.org> |
27 |
+ * William Grzybowski <william88 at gmail> |
28 |
**/ |
29 |
|
30 |
#include "collectd.h" |
31 |
@@ -29,7 +31,14 @@ |
12 |
* Global variables |
32 |
* Global variables |
13 |
*/ |
33 |
*/ |
14 |
-static kstat_t *ksp; |
34 |
|
15 |
+#if defined(HAVE_LIBKSTAT) |
35 |
+#if defined(HAVE_LIBKSTAT) |
|
|
36 |
+static kstat_t *ksp; |
16 |
extern kstat_ctl_t *kc; |
37 |
extern kstat_ctl_t *kc; |
17 |
+#endif |
38 |
+#elif defined(HAVE_SYSCTLBYNAME) |
|
|
39 |
+ typedef void kstat_t; |
40 |
+# include <sys/types.h> |
41 |
+# include <sys/sysctl.h> |
42 |
+#endif /* HAVE_SYSCTLBYNAME */ |
43 |
|
44 |
static void za_submit (const char* type, const char* type_instance, value_t* values, int values_len) |
45 |
{ |
46 |
@@ -57,37 +66,56 @@ static void za_submit_gauge (const char* type, const char* type_instance, gauge_ |
47 |
static int za_read_derive (kstat_t *ksp, const char *kstat_value, |
48 |
const char *type, const char *type_instance) |
49 |
{ |
50 |
- long long tmp; |
51 |
- value_t v; |
52 |
- |
53 |
- tmp = get_kstat_value (ksp, (char *)kstat_value); |
54 |
- if (tmp == -1LL) |
55 |
- { |
56 |
- ERROR ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value); |
57 |
- return (-1); |
58 |
- } |
59 |
- |
60 |
- v.derive = (derive_t) tmp; |
61 |
- za_submit (type, type_instance, /* values = */ &v, /* values_num = */ 1); |
62 |
- return (0); |
63 |
+ long long tmp; |
64 |
+ value_t v; |
18 |
+ |
65 |
+ |
19 |
+/* |
|
|
20 |
+ * Context |
21 |
+ */ |
22 |
+struct za_context { |
23 |
+#if defined(HAVE_LIBKSTAT) |
66 |
+#if defined(HAVE_LIBKSTAT) |
24 |
+ kstat_t *ksp; |
67 |
+ tmp = get_kstat_value (ksp, (char *)kstat_value); |
25 |
+#endif |
68 |
+ if (tmp == -1LL) |
26 |
+}; |
|
|
27 |
+ |
28 |
+static int za_init_context(struct za_context *ctx) |
29 |
+{ |
30 |
+#if defined(HAVE_LIBKSTAT) |
31 |
+ get_kstat (&ctx->ksp, "zfs", 0, "arcstats"); |
32 |
+ if (ctx->ksp == NULL) |
33 |
+ { |
69 |
+ { |
34 |
+ ERROR ("zfs_arc plugin: Cannot find zfs:0:arcstats kstat."); |
70 |
+ ERROR ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value); |
35 |
+ return (-1); |
71 |
+ return (-1); |
36 |
+ } |
72 |
+ } |
37 |
+#endif |
|
|
38 |
+ return 0; |
39 |
+} |
40 |
+ |
41 |
+static long long za_get_value(struct za_context *ctx, const char* name) |
42 |
+{ |
43 |
+#if defined(HAVE_LIBKSTAT) |
44 |
+ return get_kstat_value(ctx->ksp, name); |
45 |
+#elif defined(HAVE_SYSCTLBYNAME) |
73 |
+#elif defined(HAVE_SYSCTLBYNAME) |
46 |
+ // kstat values are available on FreeBSD through sysctl |
74 |
+ size_t size; |
47 |
+ char fullname[512]; |
75 |
+ size = sizeof(tmp); |
48 |
+ long long result = 0; |
76 |
+ if (sysctlbyname(kstat_value, &tmp, &size, NULL, 0) < 0) { |
49 |
+ size_t size = sizeof(result); |
77 |
+ ERROR ("zfs_arc plugin: Reading sysctl \"%s\" failed.", kstat_value); |
50 |
+ ssnprintf(fullname, sizeof(fullname), "kstat.zfs.misc.arcstats.%s", name); |
78 |
+ return (-1); |
51 |
+ if (sysctlbyname(fullname, &result, &size, NULL, 0) != 0 || size != sizeof(result)) |
|
|
52 |
+ { |
53 |
+ ERROR ("zfs_arc plugin: Cannot find stats using sysctl"); |
54 |
+ result = 0; |
55 |
+ } |
79 |
+ } |
56 |
+ return result; |
80 |
+#endif /* HAVE_LIBKSTAT */ |
57 |
+#endif |
81 |
+ |
58 |
+} |
82 |
+ v.derive = (derive_t) tmp; |
59 |
|
83 |
+ za_submit (type, type_instance, /* values = */ &v, /* values_num = */ 1); |
60 |
static void za_submit (const char* type, const char* type_instance, value_t* values, int values_len) |
84 |
+ return (0); |
61 |
{ |
|
|
62 |
@@ -54,13 +100,13 @@ |
63 |
za_submit (type, type_instance, &vv, 1); |
64 |
} |
85 |
} |
65 |
|
86 |
|
66 |
-static int za_read_derive (kstat_t *ksp, const char *kstat_value, |
87 |
static int za_read_gauge (kstat_t *ksp, const char *kstat_value, |
67 |
+static int za_read_derive (struct za_context *ctx, const char *kstat_value, |
|
|
68 |
const char *type, const char *type_instance) |
88 |
const char *type, const char *type_instance) |
69 |
{ |
89 |
{ |
70 |
long long tmp; |
90 |
- long long tmp; |
71 |
value_t v; |
91 |
- value_t v; |
72 |
|
92 |
- |
73 |
- tmp = get_kstat_value (ksp, kstat_value); |
93 |
- tmp = get_kstat_value (ksp, (char *)kstat_value); |
74 |
+ tmp = za_get_value (ctx, (char *)kstat_value); |
94 |
- if (tmp == -1LL) |
75 |
if (tmp == -1LL) |
95 |
- { |
76 |
{ |
96 |
- ERROR ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value); |
77 |
ERROR ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value); |
97 |
- return (-1); |
78 |
@@ -69,15 +115,16 @@ |
98 |
- } |
79 |
|
99 |
- |
80 |
v.derive = (derive_t) tmp; |
100 |
- v.gauge = (gauge_t) tmp; |
81 |
za_submit (type, type_instance, /* values = */ &v, /* values_num = */ 1); |
101 |
- za_submit (type, type_instance, /* values = */ &v, /* values_num = */ 1); |
82 |
+ return (0); |
102 |
- return (0); |
|
|
103 |
+ long long tmp; |
104 |
+ value_t v; |
105 |
+ |
106 |
+#if defined(HAVE_LIBKSTAT) |
107 |
+ tmp = get_kstat_value (ksp, (char *)kstat_value); |
108 |
+ if (tmp == -1LL) |
109 |
+ { |
110 |
+ ERROR ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value); |
111 |
+ return (-1); |
112 |
+ } |
113 |
+ |
114 |
+#elif defined(HAVE_SYSCTLBYNAME) |
115 |
+ size_t size; |
116 |
+ size = sizeof(tmp); |
117 |
+ if (sysctlbyname(kstat_value, &tmp, &size, NULL, 0) < 0) { |
118 |
+ ERROR ("zfs_arc plugin: Reading sysctl \"%s\" failed.", kstat_value); |
119 |
+ return (-1); |
120 |
+ } |
121 |
+#endif /* HAVE_LIBKSTAT */ |
122 |
+ |
123 |
+ v.gauge = (gauge_t) tmp; |
124 |
+ za_submit (type, type_instance, /* values = */ &v, /* values_num = */ 1); |
125 |
+ return (0); |
83 |
} |
126 |
} |
84 |
|
127 |
|
85 |
-static int za_read_gauge (kstat_t *ksp, const char *kstat_value, |
128 |
static void za_submit_ratio (const char* type_instance, gauge_t hits, gauge_t misses) |
86 |
+static int za_read_gauge (struct za_context *ctx, const char *kstat_value, |
129 |
@@ -105,11 +133,67 @@ static void za_submit_ratio (const char* type_instance, gauge_t hits, gauge_t mi |
87 |
const char *type, const char *type_instance) |
130 |
za_submit_gauge ("cache_ratio", type_instance, ratio); |
88 |
{ |
|
|
89 |
long long tmp; |
90 |
value_t v; |
91 |
|
92 |
- tmp = get_kstat_value (ksp, kstat_value); |
93 |
+ tmp = za_get_value (ctx, (char *)kstat_value); |
94 |
if (tmp == -1LL) |
95 |
{ |
96 |
ERROR ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value); |
97 |
@@ -86,18 +133,14 @@ |
98 |
|
99 |
v.gauge = (gauge_t) tmp; |
100 |
za_submit (type, type_instance, /* values = */ &v, /* values_num = */ 1); |
101 |
+ return (0); |
102 |
} |
131 |
} |
103 |
|
132 |
|
104 |
-static void za_submit_ratio (const char* type_instance, gauge_t hits, gauge_t misses) |
133 |
-static int za_read (void) |
105 |
+static void za_submit_ratio (const char* type_instance, long long hits, long long misses) |
134 |
+#if defined(HAVE_SYSCTLBYNAME) |
106 |
{ |
135 |
+static int za_read_freebsd (void) |
107 |
gauge_t ratio = NAN; |
136 |
+{ |
108 |
|
137 |
+ // Sizes |
109 |
- if (!isfinite (hits) || (hits < 0.0)) |
138 |
+ za_read_gauge (NULL, "kstat.zfs.misc.arcstats.size", "cache_size", "arc"); |
110 |
- hits = 0.0; |
139 |
+ za_read_gauge (NULL, "kstat.zfs.misc.arcstats.l2_size", "cache_size", "L2"); |
111 |
- if (!isfinite (misses) || (misses < 0.0)) |
140 |
+ |
112 |
- misses = 0.0; |
|
|
113 |
- |
114 |
- if ((hits != 0.0) || (misses != 0.0)) |
115 |
+ if ((hits > 0) || (misses > 0)) |
116 |
ratio = hits / (hits + misses); |
117 |
|
118 |
za_submit_gauge ("cache_ratio", type_instance, ratio); |
119 |
@@ -105,56 +148,55 @@ |
120 |
|
121 |
static int za_read (void) |
122 |
{ |
123 |
- gauge_t arc_hits, arc_misses, l2_hits, l2_misses; |
124 |
+ long long arc_hits, arc_misses, l2_hits, l2_misses; |
125 |
value_t l2_io[2]; |
126 |
+ struct za_context ctx; |
127 |
|
128 |
- get_kstat (&ksp, "zfs", 0, "arcstats"); |
129 |
- if (ksp == NULL) |
130 |
+ if (za_init_context (&ctx) < 0) |
131 |
{ |
132 |
- ERROR ("zfs_arc plugin: Cannot find zfs:0:arcstats kstat."); |
133 |
return (-1); |
134 |
} |
135 |
|
136 |
/* Sizes */ |
137 |
- za_read_gauge (ksp, "size", "cache_size", "arc"); |
138 |
- za_read_gauge (ksp, "l2_size", "cache_size", "L2"); |
139 |
+ za_read_gauge (&ctx, "size", "cache_size", "arc"); |
140 |
+ za_read_gauge (&ctx, "l2_size", "cache_size", "L2"); |
141 |
|
142 |
- /* Operations */ |
143 |
- za_read_derive (ksp, "allocated","cache_operation", "allocated"); |
144 |
- za_read_derive (ksp, "deleted", "cache_operation", "deleted"); |
145 |
- za_read_derive (ksp, "stolen", "cache_operation", "stolen"); |
146 |
- |
147 |
- /* Issue indicators */ |
148 |
- za_read_derive (ksp, "mutex_miss", "mutex_operation", "miss"); |
149 |
- za_read_derive (ksp, "hash_collisions", "hash_collisions", ""); |
150 |
+ /* Operations */ |
141 |
+ /* Operations */ |
151 |
+ za_read_derive (&ctx, "allocated","cache_operation", "allocated"); |
142 |
+ za_read_derive (NULL, "kstat.zfs.misc.arcstats.allocated", "cache_operation", "allocated"); |
152 |
+ za_read_derive (&ctx, "deleted", "cache_operation", "deleted"); |
143 |
+ za_read_derive (NULL, "kstat.zfs.misc.arcstats.deleted", "cache_operation", "deleted"); |
153 |
+ za_read_derive (&ctx, "stolen", "cache_operation", "stolen"); |
144 |
+ za_read_derive (NULL, "kstat.zfs.misc.arcstats.stolen", "cache_operation", "stolen"); |
154 |
+ |
145 |
+ |
155 |
+ /* Issue indicators */ |
146 |
+ /* Issue indicators */ |
156 |
+ za_read_derive (&ctx, "mutex_miss", "mutex_operation", "miss"); |
147 |
+ za_read_derive (NULL, "kstat.zfs.misc.arcstats.mutex_miss", "mutex_operation", "miss"); |
157 |
+ za_read_derive (&ctx, "hash_collisions", "hash_collisions", ""); |
148 |
+ za_read_derive (NULL, "kstat.zfs.misc.arcstats.hash_collisions", "hash_collisions", ""); |
158 |
|
149 |
+ |
159 |
- /* Evictions */ |
|
|
160 |
- za_read_derive (ksp, "evict_l2_cached", "cache_eviction", "cached"); |
161 |
- za_read_derive (ksp, "evict_l2_eligible", "cache_eviction", "eligible"); |
162 |
- za_read_derive (ksp, "evict_l2_ineligible", "cache_eviction", "ineligible"); |
163 |
+ /* Evictions */ |
150 |
+ /* Evictions */ |
164 |
+ za_read_derive (&ctx, "evict_l2_cached", "cache_eviction", "cached"); |
151 |
+ za_read_derive (NULL, "kstat.zfs.misc.arcstats.evict_l2_cached", "cache_eviction", "cached"); |
165 |
+ za_read_derive (&ctx, "evict_l2_eligible", "cache_eviction", "eligible"); |
152 |
+ za_read_derive (NULL, "kstat.zfs.misc.arcstats.evict_l2_eligible", "cache_eviction", "eligible"); |
166 |
+ za_read_derive (&ctx, "evict_l2_ineligible", "cache_eviction", "ineligible"); |
153 |
+ za_read_derive (NULL, "kstat.zfs.misc.arcstats.evict_l2_ineligible", "cache_eviction", "ineligible"); |
|
|
154 |
+ |
155 |
+ /* Hits / misses */ |
156 |
+ za_read_derive (NULL, "kstat.zfs.misc.arcstats.demand_data_hits", "cache_result", "demand_data-hit"); |
157 |
+ za_read_derive (NULL, "kstat.zfs.misc.arcstats.demand_metadata_hits", "cache_result", "demand_metadata-hit"); |
158 |
+ za_read_derive (NULL, "kstat.zfs.misc.arcstats.prefetch_data_hits", "cache_result", "prefetch_data-hit"); |
159 |
+ za_read_derive (NULL, "kstat.zfs.misc.arcstats.prefetch_metadata_hits", "cache_result", "prefetch_metadata-hit"); |
160 |
+ za_read_derive (NULL, "kstat.zfs.misc.arcstats.demand_data_misses", "cache_result", "demand_data-miss"); |
161 |
+ za_read_derive (NULL, "kstat.zfs.misc.arcstats.demand_metadata_misses", "cache_result", "demand_metadata-miss"); |
162 |
+ za_read_derive (NULL, "kstat.zfs.misc.arcstats.prefetch_data_misses", "cache_result", "prefetch_data-miss"); |
163 |
+ za_read_derive (NULL, "kstat.zfs.misc.arcstats.prefetch_metadata_misses", "cache_result", "prefetch_metadata-miss"); |
164 |
+ |
165 |
+ /* Ratios */ |
166 |
+ gauge_t arc_hits; |
167 |
+ gauge_t arc_misses; |
168 |
+ gauge_t l2_hits; |
169 |
+ gauge_t l2_misses; |
170 |
+ value_t l2_io[2]; |
171 |
+ |
172 |
+ size_t size; |
173 |
+ size = sizeof(arc_hits); |
174 |
+ sysctlbyname("kstat.zfs.misc.arcstats.hits", &arc_hits, &size, NULL, 0); |
175 |
+ sysctlbyname("kstat.zfs.misc.arcstats.misses", &arc_misses, &size, NULL, 0); |
176 |
+ sysctlbyname("kstat.zfs.misc.arcstats.l2_hits", &l2_hits, &size, NULL, 0); |
177 |
+ sysctlbyname("kstat.zfs.misc.arcstats.l2_misses", &l2_misses, &size, NULL, 0); |
178 |
+ |
179 |
+ za_submit_ratio ("arc", arc_hits, arc_misses); |
180 |
+ za_submit_ratio ("L2", l2_hits, l2_misses); |
181 |
+ |
182 |
+ /* I/O */ |
183 |
+ sysctlbyname("kstat.zfs.misc.arcstats.l2_read_bytes", &l2_io[0].derive, &size, NULL, 0); |
184 |
+ sysctlbyname("kstat.zfs.misc.arcstats.l2_write_bytes", &l2_io[1].derive, &size, NULL, 0); |
185 |
+ |
186 |
+ za_submit ("io_octets", "L2", l2_io, /* num values = */ 2); |
187 |
+ |
188 |
+ return (0); |
189 |
+} |
190 |
+#elif defined(HAVE_LIBKSTAT) |
191 |
+static int za_read_solaris (void) |
192 |
{ |
193 |
gauge_t arc_hits, arc_misses, l2_hits, l2_misses; |
194 |
value_t l2_io[2]; |
195 |
- kstat_t *ksp = NULL; |
167 |
|
196 |
|
168 |
/* Hits / misses */ |
197 |
get_kstat (&ksp, "zfs", 0, "arcstats"); |
169 |
- za_read_derive (ksp, "demand_data_hits", "cache_result", "demand_data-hit"); |
198 |
if (ksp == NULL) |
170 |
- za_read_derive (ksp, "demand_metadata_hits", "cache_result", "demand_metadata-hit"); |
199 |
@@ -163,15 +247,20 @@ static int za_read (void) |
171 |
- za_read_derive (ksp, "prefetch_data_hits", "cache_result", "prefetch_data-hit"); |
|
|
172 |
- za_read_derive (ksp, "prefetch_metadata_hits", "cache_result", "prefetch_metadata-hit"); |
173 |
- za_read_derive (ksp, "demand_data_misses", "cache_result", "demand_data-miss"); |
174 |
- za_read_derive (ksp, "demand_metadata_misses", "cache_result", "demand_metadata-miss"); |
175 |
- za_read_derive (ksp, "prefetch_data_misses", "cache_result", "prefetch_data-miss"); |
176 |
- za_read_derive (ksp, "prefetch_metadata_misses", "cache_result", "prefetch_metadata-miss"); |
177 |
+ za_read_derive (&ctx, "demand_data_hits", "cache_result", "demand_data-hit"); |
178 |
+ za_read_derive (&ctx, "demand_metadata_hits", "cache_result", "demand_metadata-hit"); |
179 |
+ za_read_derive (&ctx, "prefetch_data_hits", "cache_result", "prefetch_data-hit"); |
180 |
+ za_read_derive (&ctx, "prefetch_metadata_hits", "cache_result", "prefetch_metadata-hit"); |
181 |
+ za_read_derive (&ctx, "demand_data_misses", "cache_result", "demand_data-miss"); |
182 |
+ za_read_derive (&ctx, "demand_metadata_misses", "cache_result", "demand_metadata-miss"); |
183 |
+ za_read_derive (&ctx, "prefetch_data_misses", "cache_result", "prefetch_data-miss"); |
184 |
+ za_read_derive (&ctx, "prefetch_metadata_misses", "cache_result", "prefetch_metadata-miss"); |
185 |
|
200 |
|
186 |
/* Ratios */ |
201 |
return (0); |
187 |
- arc_hits = (gauge_t) get_kstat_value(ksp, "hits"); |
202 |
} /* int za_read */ |
188 |
- arc_misses = (gauge_t) get_kstat_value(ksp, "misses"); |
203 |
+#endif |
189 |
- l2_hits = (gauge_t) get_kstat_value(ksp, "l2_hits"); |
|
|
190 |
- l2_misses = (gauge_t) get_kstat_value(ksp, "l2_misses"); |
191 |
+ arc_hits = za_get_value (&ctx, "hits"); |
192 |
+ arc_misses = za_get_value (&ctx, "misses"); |
193 |
+ l2_hits = za_get_value (&ctx, "l2_hits"); |
194 |
+ l2_misses = za_get_value (&ctx, "l2_misses"); |
195 |
|
204 |
|
196 |
za_submit_ratio ("arc", arc_hits, arc_misses); |
|
|
197 |
za_submit_ratio ("L2", l2_hits, l2_misses); |
198 |
|
199 |
/* I/O */ |
200 |
- l2_io[0].derive = get_kstat_value(ksp, "l2_read_bytes"); |
201 |
- l2_io[1].derive = get_kstat_value(ksp, "l2_write_bytes"); |
202 |
+ l2_io[0].derive = za_get_value (&ctx, "l2_read_bytes"); |
203 |
+ l2_io[1].derive = za_get_value (&ctx, "l2_write_bytes"); |
204 |
|
205 |
za_submit ("io_octets", "L2", l2_io, /* num values = */ 2); |
206 |
|
207 |
@@ -163,14 +205,23 @@ |
208 |
|
209 |
static int za_init (void) /* {{{ */ |
205 |
static int za_init (void) /* {{{ */ |
210 |
{ |
206 |
{ |
211 |
- ksp = NULL; |
|
|
212 |
- |
213 |
+#if defined(HAVE_LIBKSTAT) |
207 |
+#if defined(HAVE_LIBKSTAT) |
|
|
208 |
+ ksp = NULL; |
209 |
+ |
214 |
/* kstats chain already opened by update_kstat (using *kc), verify everything went fine. */ |
210 |
/* kstats chain already opened by update_kstat (using *kc), verify everything went fine. */ |
215 |
if (kc == NULL) |
211 |
if (kc == NULL) |
216 |
{ |
212 |
{ |
217 |
ERROR ("zfs_arc plugin: kstat chain control structure not available."); |
213 |
ERROR ("zfs_arc plugin: kstat chain control structure not available."); |
218 |
return (-1); |
214 |
return (-1); |
219 |
} |
215 |
} |
220 |
+#elif defined(HAVE_SYSCTLBYNAME) |
216 |
+#endif /* HAVE_LIBKSTAT */ |
221 |
+ /* make sure ARC is available (arc_size is not null) */ |
|
|
222 |
+ unsigned long long arc_size; |
223 |
+ size_t size = sizeof(arc_size); |
224 |
+ if (sysctlbyname("kstat.zfs.misc.arcstats.size", &arc_size, &size, NULL, 0) != 0 || arc_size == 0) |
225 |
+ { |
226 |
+ ERROR ("zfs_arc plugin: could not get ARC size using sysctl, is ARC enabled?"); |
227 |
+ return (-1); |
228 |
+ } |
229 |
+#endif |
230 |
|
217 |
|
231 |
return (0); |
218 |
return (0); |
232 |
} /* }}} int za_init */ |
219 |
} /* }}} int za_init */ |
|
|
220 |
@@ -179,7 +268,16 @@ static int za_init (void) /* {{{ */ |
221 |
void module_register (void) |
222 |
{ |
223 |
plugin_register_init ("zfs_arc", za_init); |
224 |
- plugin_register_read ("zfs_arc", za_read); |
225 |
+ |
226 |
+#if defined(HAVE_LIBKSTAT) |
227 |
+ plugin_register_read ("zfs_arc", za_read_solaris); |
228 |
+#elif defined(HAVE_SYSCTLBYNAME) |
229 |
+ plugin_register_read ("zfs_arc", za_read_freebsd); |
230 |
+#else |
231 |
+ ERROR ("Unable to determine which OS we are on"); |
232 |
+ return (-1); |
233 |
+#endif /* HAVE_SYSCTLBYNAME */ |
234 |
+ |
235 |
} /* void module_register */ |
236 |
|
237 |
/* vmi: set sw=8 noexpandtab fdm=marker : */ |