Index: files/patch-zfsarc =================================================================== --- files/patch-zfsarc (revision 0) +++ files/patch-zfsarc (working copy) @@ -0,0 +1,131 @@ +diff --git configure.in configure.in +index 1cfc2fc..f362459 100644 +--- configure.in ++++ configure.in +@@ -71,6 +71,10 @@ case $host_os in + AC_DEFINE([KERNEL_AIX], 1, [True if program is to be compiled for a AIX kernel]) + ac_system="AIX" + ;; ++ *freebsd*) ++ AC_DEFINE([KERNEL_FREEBSD], 1, [True if program is to be compiled for a FreeBSD kernel]) ++ ac_system="FreeBSD" ++ ;; + *) + ac_system="unknown" + esac +@@ -4557,6 +4561,12 @@ then + plugin_tcpconns="yes" + fi + ++if test "x$ac_system" = "xFreeBSD" ++then ++ plugin_zfs_arc="yes" ++fi ++ ++ + if test "x$with_perfstat" = "xyes" + then + plugin_cpu="yes" +diff --git src/Makefile.am src/Makefile.am +index ab580d7..8900ecd 100644 +--- src/Makefile.am ++++ src/Makefile.am +@@ -1315,7 +1315,6 @@ pkglib_LTLIBRARIES += zfs_arc.la + zfs_arc_la_SOURCES = zfs_arc.c + zfs_arc_la_CFLAGS = $(AM_CFLAGS) + zfs_arc_la_LDFLAGS = -module -avoid-version +-zfs_arc_la_LIBADD = -lkstat + collectd_LDADD += "-dlopen" zfs_arc.la + collectd_DEPENDENCIES += zfs_arc.la + endif +diff --git src/zfs_arc.c src/zfs_arc.c +index e77569f..e5b894c 100644 +--- src/zfs_arc.c ++++ src/zfs_arc.c +@@ -28,8 +28,40 @@ + /* + * Global variables + */ ++#if !defined(__FreeBSD__) + static kstat_t *ksp; + extern kstat_ctl_t *kc; ++#else ++#include ++#include ++ ++static void *ksp = NULL; ++const char zfs_arcstat[] = "kstat.zfs.misc.arcstats."; ++#if defined(get_kstat_value) ++#undef get_kstat_value ++#endif ++#if !defined(kstat_t) ++typedef void kstat_t; ++#endif ++ ++static long long get_kstat_value(void * dummy __unused, const char *kstat_value) ++{ ++ long long value; ++ size_t valuelen = sizeof(value); ++ int length, rv; ++ char *key; ++ ++ length = asprintf(&key, "%s%s", zfs_arcstat, kstat_value); ++ if (length) { ++ rv = sysctlbyname(key, (void *)&value, &valuelen, NULL, (size_t)0); ++ free(key); ++ if (rv == 0) ++ return (value); ++ } ++ ++ return (-1); ++} ++#endif + + static void za_submit (const char* type, const char* type_instance, value_t* values, int values_len) + { +@@ -69,6 +101,7 @@ static int za_read_derive (kstat_t *ksp, const char *kstat_value, + + v.derive = (derive_t) tmp; + za_submit (type, type_instance, /* values = */ &v, /* values_num = */ 1); ++ return (0); + } + + static int za_read_gauge (kstat_t *ksp, const char *kstat_value, +@@ -86,6 +119,7 @@ static int za_read_gauge (kstat_t *ksp, const char *kstat_value, + + v.gauge = (gauge_t) tmp; + za_submit (type, type_instance, /* values = */ &v, /* values_num = */ 1); ++ return (0); + } + + static void za_submit_ratio (const char* type_instance, gauge_t hits, gauge_t misses) +@@ -108,12 +142,14 @@ static int za_read (void) + gauge_t arc_hits, arc_misses, l2_hits, l2_misses; + value_t l2_io[2]; + ++#if !defined(__FreeBSD__) + get_kstat (&ksp, "zfs", 0, "arcstats"); + if (ksp == NULL) + { + ERROR ("zfs_arc plugin: Cannot find zfs:0:arcstats kstat."); + return (-1); + } ++#endif + + /* Sizes */ + za_read_gauge (ksp, "size", "cache_size", "arc"); +@@ -165,12 +201,14 @@ static int za_init (void) /* {{{ */ + { + ksp = NULL; + ++#if !defined(__FreeBSD__) + /* kstats chain already opened by update_kstat (using *kc), verify everything went fine. */ + if (kc == NULL) + { + ERROR ("zfs_arc plugin: kstat chain control structure not available."); + return (-1); + } ++#endif + + return (0); + } /* }}} int za_init */ Index: pkg-plist =================================================================== --- pkg-plist (revision 303393) +++ pkg-plist (working copy) @@ -113,6 +113,8 @@ libdata/pkgconfig/libcollectdclient.pc %%XMMS%%lib/collectd/xmms.la %%XMMS%%lib/collectd/xmms.so +%%ZFSARC%%lib/collectd/zfs_arc.la +%%ZFSARC%%lib/collectd/zfs_arc.so %%DATADIR%%/postgresql_default.conf %%DATADIR%%/types.db @dirrm lib/collectd Index: Makefile =================================================================== --- Makefile (revision 303393) +++ Makefile (working copy) @@ -48,7 +48,8 @@ TOKYOTYRANT "Input: Tokyotyrant database" Off \ XMMS "Input: XMMS" Off \ RRDTOOL "Output: RRDTool" On \ - RRDCACHED "Output: RRDTool Cached (require RRDTOOL)" On + RRDCACHED "Output: RRDTool Cached (require RRDTOOL)" On \ + ZFSARC "Input: ZFS ARC statistics" On MAN1= collectd.1 collectd-nagios.1 collectdmon.1 collectdctl.1 MAN5= collectd.conf.5 collectd-email.5 collectd-exec.5 \ @@ -127,7 +128,6 @@ --disable-vserver \ --disable-wireless \ --disable-write_http \ - --disable-zfs_arc \ --without-perl-bindings \ --without-librabbitmq \ --disable-varnish \ @@ -394,6 +394,14 @@ PLIST_SUB+= XMMS="@comment " .endif +.if defined(WITH_ZFSARC) +CONFIGURE_ARGS+=--enable-zfs_arc +PLIST_SUB+= ZFSARC="" +.else +CONFIGURE_ARGS+=--disable-zfs_arc +PLIST_SUB+= ZFSARC="@comment " +.endif + AUTOTOOLSFILES= aclocal.m4 post-patch: