Merge branch 'collectd-5.0' into collectd-5.1
authorFlorian Forster <octo@collectd.org>
Sun, 23 Sep 2012 10:22:27 +0000 (12:22 +0200)
committerFlorian Forster <octo@collectd.org>
Sun, 23 Sep 2012 10:22:27 +0000 (12:22 +0200)
1  2 
configure.in
src/zfs_arc.c

diff --combined configure.in
@@@ -1,5 -1,5 +1,5 @@@
  dnl Process this file with autoconf to produce a configure script.
 -AC_INIT(collectd, m4_esyscmd(./version-gen.sh))
 +AC_INIT(collectd, [m4_esyscmd(./version-gen.sh)])
  AC_CONFIG_SRCDIR(src/collectd.c)
  AC_CONFIG_HEADERS(src/config.h)
  AC_CONFIG_AUX_DIR([libltdl/config])
  # For hddtemp module
  AC_CHECK_HEADERS(linux/major.h libgen.h)
  
 +# For md module (Linux only)
 +if test "x$ac_system" = "xLinux"
 +then
 +      AC_CHECK_HEADERS(linux/raid/md_u.h,
 +                       [have_linux_raid_md_u_h="yes"],
 +                       [have_linux_raid_md_u_h="no"],
 +[
 +#include <sys/ioctl.h>
 +#include <linux/major.h>
 +#include <linux/types.h>
 +])
 +else
 +      have_linux_raid_md_u_h="no"
 +fi
 +
  # For the battery plugin
  AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
  [
@@@ -404,33 -389,6 +404,33 @@@ AC_CHECK_HEADERS(linux/netdevice.h, []
  #endif
  ])
  
 +# For ethstat module
 +AC_CHECK_HEADERS(linux/sockios.h,
 +    [have_linux_sockios_h="yes"],
 +    [have_linux_sockios_h="no"],
 +    [
 +#if HAVE_SYS_IOCTL_H
 +# include <sys/ioctl.h>
 +#endif
 +#if HAVE_NET_IF_H
 +# include <net/if.h>
 +#endif
 +    ])
 +AC_CHECK_HEADERS(linux/ethtool.h,
 +    [have_linux_ethtool_h="yes"],
 +    [have_linux_ethtool_h="no"],
 +    [
 +#if HAVE_SYS_IOCTL_H
 +# include <sys/ioctl.h>
 +#endif
 +#if HAVE_NET_IF_H
 +# include <net/if.h>
 +#endif
 +#if HAVE_LINUX_SOCKIOS_H
 +# include <linux/sockios.h>
 +#endif
 +    ])
 +
  # For ipvs module
  have_linux_ip_vs_h="no"
  have_net_ip_vs_h="no"
@@@ -1228,6 -1186,7 +1228,7 @@@ AC_CHECK_MEMBERS([struct kinfo_proc.ki_
                have_struct_kinfo_proc_freebsd="no"
        ],
        [
+ AC_INCLUDES_DEFAULT
  #include <kvm.h>
  #include <sys/param.h>
  #include <sys/sysctl.h>
@@@ -1244,6 -1203,7 +1245,7 @@@ AC_CHECK_MEMBERS([struct kinfo_proc.kp_
                have_struct_kinfo_proc_openbsd="no"
        ],
        [
+ AC_INCLUDES_DEFAULT
  #include <sys/param.h>
  #include <sys/sysctl.h>
  #include <kvm.h>
@@@ -1304,7 -1264,6 +1306,7 @@@ AC_CHECK_MEMBERS([kstat_io_t.nwritten, 
  #
  # Checks for libraries begin here
  #
 +
  with_libresolv="yes"
  AC_CHECK_LIB(resolv, res_search,
  [
  # This could be in iptc or ip4tc
  if test "x$with_libiptc" = "xpkgconfig"
  then
+       SAVE_LIBS="$LIBS"
        AC_SEARCH_LIBS(iptc_init, [iptc ip4tc],
                        [with_libiptc="pkgconfig"],
                        [with_libiptc="no"],
                        [$with_libiptc_libs])
+       LIBS="$SAVE_LIBS"
  fi
  if test "x$with_libiptc" = "xpkgconfig"
  then
  fi
  if test "x$with_libmodbus" = "xuse_pkgconfig"
  then
 -      AC_MSG_NOTICE([Checking for modbus using $PKG_CONFIG])
 -      $PKG_CONFIG --exists 'modbus' 2>/dev/null
 +      AC_MSG_NOTICE([Checking for libmodbus using $PKG_CONFIG])
 +      $PKG_CONFIG --exists 'libmodbus' 2>/dev/null
        if test $? -ne 0
        then
 -              with_libmodbus="no (pkg-config doesn't know modbus)"
 +              with_libmodbus="no (pkg-config doesn't know libmodbus)"
        fi
  fi
  if test "x$with_libmodbus" = "xuse_pkgconfig"
  then
 -      with_libmodbus_cflags="`$PKG_CONFIG --cflags 'modbus'`"
 +      with_libmodbus_cflags="`$PKG_CONFIG --cflags 'libmodbus'`"
        if test $? -ne 0
        then
                with_libmodbus="no ($PKG_CONFIG failed)"
        fi
 -      with_libmodbus_libs="`$PKG_CONFIG --libs 'modbus'`"
 +      with_libmodbus_libs="`$PKG_CONFIG --libs 'libmodbus'`"
        if test $? -ne 0
        then
                with_libmodbus="no ($PKG_CONFIG failed)"
  fi
  # }}}
  
 +# --with-libmongoc {{{
 +AC_ARG_WITH(libmongoc, [AS_HELP_STRING([--with-libmongoc@<:@=PREFIX@:>@], [Path to libmongoc.])],
 +[
 + if test "x$withval" = "xyes"
 + then
 +       with_libmongoc="yes"
 + else if test "x$withval" = "xno"
 + then
 +       with_libmongoc="no"
 + else
 +       with_libmongoc="yes"
 +       LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS -I$withval/include"
 +       LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS -L$withval/lib"
 + fi; fi
 +],
 +[with_libmongoc="yes"])
 +
 +SAVE_CPPFLAGS="$CPPFLAGS"
 +SAVE_LDFLAGS="$LDFLAGS"
 +
 +CPPFLAGS="$CPPFLAGS $LIBMONGOC_CPPFLAGS"
 +LDFLAGS="$LDFLAGS $LIBMONGOC_LDFLAGS"
 +
 +if test "x$with_libmongoc" = "xyes"
 +then
 +      if test "x$LIBMONGOC_CPPFLAGS" != "x"
 +      then
 +              AC_MSG_NOTICE([libmongoc CPPFLAGS: $LIBMONGOC_CPPFLAGS])
 +      fi
 +      AC_CHECK_HEADERS(mongo.h,
 +      [with_libmongoc="yes"],
 +      [with_libmongoc="no ('mongo.h' not found)"],
 +[#if HAVE_STDINT_H
 +# define MONGO_HAVE_STDINT 1
 +#else
 +# define MONGO_USE_LONG_LONG_INT 1
 +#endif
 +])
 +fi
 +if test "x$with_libmongoc" = "xyes"
 +then
 +      if test "x$LIBMONGOC_LDFLAGS" != "x"
 +      then
 +              AC_MSG_NOTICE([libmongoc LDFLAGS: $LIBMONGOC_LDFLAGS])
 +      fi
 +      AC_CHECK_LIB(mongoc, mongo_run_command,
 +      [with_libmongoc="yes"],
 +      [with_libmongoc="no (symbol 'mongo_run_command' not found)"])
 +fi
 +
 +CPPFLAGS="$SAVE_CPPFLAGS"
 +LDFLAGS="$SAVE_LDFLAGS"
 +
 +if test "x$with_libmongoc" = "xyes"
 +then
 +      BUILD_WITH_LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS"
 +      BUILD_WITH_LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS"
 +      AC_SUBST(BUILD_WITH_LIBMONGOC_CPPFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBMONGOC_LDFLAGS)
 +fi
 +AM_CONDITIONAL(BUILD_WITH_LIBMONGOC, test "x$with_libmongoc" = "xyes")
 +# }}}
 +
  # --with-libmysql {{{
  with_mysql_config="mysql_config"
  with_mysql_cflags=""
  fi
  if test "x$with_libnetlink" = "xyes"
  then
+       SAVE_CFLAGS="$CFLAGS"
+       CFLAGS="$CFLAGS $with_libnetlink_cflags"
+       AC_CACHE_CHECK(
+               [if function 'rtnl_dump_filter' expects five arguments],
+               [c_cv_rtnl_dump_filter_five_args],
+               AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+                               [
+ AC_INCLUDES_DEFAULT
+ #include <asm/types.h>
+ #include <sys/socket.h>
+ #if HAVE_LIBNETLINK_H
+ # include <libnetlink.h>
+ #elif HAVE_IPROUTE_LIBNETLINK_H
+ # include <iproute/libnetlink.h>
+ #elif HAVE_LINUX_LIBNETLINK_H
+ # include <linux/libnetlink.h>
+ #endif
+                               ],
+                               [
+ if (rtnl_dump_filter(NULL, NULL, NULL, NULL, NULL))
+       return 1;
+ return 0;
+                               ]
+                       )],
+                       [c_cv_rtnl_dump_filter_five_args="yes"],
+                       [c_cv_rtnl_dump_filter_five_args="no"]
+               )
+       )
+       AC_CACHE_CHECK(
+               [if function 'rtnl_dump_filter' expects three arguments],
+               [c_cv_rtnl_dump_filter_three_args],
+               AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+                               [
+ AC_INCLUDES_DEFAULT
+ #include <asm/types.h>
+ #include <sys/socket.h>
+ #if HAVE_LIBNETLINK_H
+ # include <libnetlink.h>
+ #elif HAVE_IPROUTE_LIBNETLINK_H
+ # include <iproute/libnetlink.h>
+ #elif HAVE_LINUX_LIBNETLINK_H
+ # include <linux/libnetlink.h>
+ #endif
+                               ],
+                               [
+ if (rtnl_dump_filter(NULL, NULL, NULL))
+       return 1;
+ return 0;
+                               ]
+                       )],
+                       [c_cv_rtnl_dump_filter_three_args="yes"],
+                       [c_cv_rtnl_dump_filter_three_args="no"]
+               )
+       )
+       CFLAGS="$SAVE_CFLAGS"
+       if test "x$c_cv_rtnl_dump_filter_five_args" = "xyes"
+       then
+               AC_DEFINE(RTNL_DUMP_FILTER_FIVE_ARGS, 1,
+                               [Define to 1 if function 'rtnl_dump_filter' expects five arguments.])
+       fi
+       if test "x$c_cv_rtnl_dump_filter_three_args" = "xyes"
+       then
+               AC_DEFINE(RTNL_DUMP_FILTER_THREE_ARGS, 1,
+                               [Define to 1 if function 'rtnl_dump_filter' expects three arguments.])
+       fi
        BUILD_WITH_LIBNETLINK_CFLAGS="$with_libnetlink_cflags"
        BUILD_WITH_LIBNETLINK_LIBS="$with_libnetlink_libs"
        AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS)
@@@ -4060,7 -4028,7 +4134,7 @@@ AC_ARG_WITH(libvarnish, [AS_HELP_STRING
        then
                AC_MSG_NOTICE([Not checking for libvarnish: Manually configured])
                with_libvarnish_cflags="-I$withval/include"
-               with_libvarnish_libs="-L$withval/lib -lvarnish -lvarnishcompat -lvarnishapi"
+               with_libvarnish_libs="-L$withval/lib -lvarnishapi"
                with_libvarnish="yes"
        fi; fi; fi
  ],
@@@ -4119,9 -4087,10 +4193,9 @@@ the
        CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags"
        #LDFLAGS="$LDFLAGS $with_libvarnish_libs"
  
 -      AC_CHECK_LIB(varnishapi, VSL_OpenStats,
 -                   [with_libvarnish="yes"],
 -                   [with_libvarnish="no (symbol VSL_OpenStats not found)"],
 -                   [$with_libvarnish_libs])
 +    AC_CHECK_HEADERS(varnish/vsc.h,
 +        [AC_DEFINE([HAVE_VARNISH_V3], [1], [Varnish 3 API support])],
 +        [AC_DEFINE([HAVE_VARNISH_V2], [1], [Varnish 2 API support])])
  
        CPPFLAGS="$SAVE_CPPFLAGS"
        #LDFLAGS="$SAVE_LDFLAGS"
@@@ -4479,8 -4448,6 +4553,8 @@@ plugin_curl_xml="no
  plugin_df="no"
  plugin_disk="no"
  plugin_entropy="no"
 +plugin_ethstat="no"
 +plugin_fscache="no"
  plugin_interface="no"
  plugin_ipmi="no"
  plugin_ipvs="no"
@@@ -4490,7 -4457,7 +4564,7 @@@ plugin_load="no
  plugin_memory="no"
  plugin_multimeter="no"
  plugin_nfs="no"
 -plugin_fscache="no"
 +plugin_numa="no"
  plugin_perl="no"
  plugin_processes="no"
  plugin_protocols="no"
        plugin_cpufreq="yes"
        plugin_disk="yes"
        plugin_entropy="yes"
 +      plugin_fscache="yes"
        plugin_interface="yes"
        plugin_irq="yes"
        plugin_load="yes"
        plugin_memory="yes"
        plugin_nfs="yes"
 -      plugin_fscache="yes"
 +      plugin_numa="yes"
        plugin_processes="yes"
        plugin_protocols="yes"
        plugin_serial="yes"
  fi
  
  # AIX
 +
 +if test "x$ac_system" = "xAIX"
 +then
 +        plugin_tcpconns="yes"
 +fi
 +
  if test "x$with_perfstat" = "xyes"
  then
        plugin_cpu="yes"
  # Solaris
  if test "x$with_kstat" = "xyes"
  then
 +      plugin_nfs="yes"
        plugin_uptime="yes"
        plugin_zfs_arc="yes"
  fi
        fi
  fi
  
 +if test "x$have_linux_sockios_h$have_linux_ethtool_h" = "xyesyes"
 +then
 +      plugin_ethstat="yes"
 +fi
 +
  if test "x$have_getifaddrs" = "xyes"
  then
        plugin_interface="yes"
@@@ -4798,7 -4752,6 +4872,7 @@@ AC_PLUGIN([disk],        [$plugin_disk]
  AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
  AC_PLUGIN([email],       [yes],                [EMail statistics])
  AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
 +AC_PLUGIN([ethstat],     [$plugin_ethstat],    [Stats from NIC driver])
  AC_PLUGIN([exec],        [yes],                [Execution of external programs])
  AC_PLUGIN([filecount],   [yes],                [Count files in directories])
  AC_PLUGIN([fscache],     [$plugin_fscache],    [fscache statistics])
@@@ -4821,7 -4774,6 +4895,7 @@@ AC_PLUGIN([match_regex], [yes]
  AC_PLUGIN([match_timediff], [yes],             [The timediff match])
  AC_PLUGIN([match_value], [yes],                [The value match])
  AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
 +AC_PLUGIN([md],          [$have_linux_raid_md_u_h], [md (Linux software RAID) devices])
  AC_PLUGIN([memcachec],   [$with_libmemcached], [memcachec statistics])
  AC_PLUGIN([memcached],   [yes],                [memcached statistics])
  AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
@@@ -4836,7 -4788,6 +4910,7 @@@ AC_PLUGIN([nginx],       [$with_libcurl
  AC_PLUGIN([notify_desktop], [$with_libnotify], [Desktop notifications])
  AC_PLUGIN([notify_email], [$with_libesmtp],    [Email notifier])
  AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
 +AC_PLUGIN([numa],        [$plugin_numa],       [NUMA virtual memory statistics])
  AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
  AC_PLUGIN([olsrd],       [yes],                [olsrd statistics])
  AC_PLUGIN([onewire],     [$with_libowcapi],    [OneWire sensor statistics])
@@@ -4882,10 -4833,8 +4956,10 @@@ AC_PLUGIN([varnish],     [$with_libvarn
  AC_PLUGIN([vmem],        [$plugin_vmem],       [Virtual memory statistics])
  AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
  AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
 +AC_PLUGIN([write_graphite], [yes],             [Graphite / Carbon output plugin])
  AC_PLUGIN([write_http],  [$with_libcurl],      [HTTP output plugin])
  AC_PLUGIN([write_redis], [$with_libcredis],    [Redis output plugin])
 +AC_PLUGIN([write_mongodb], [$with_libmongoc],  [MongoDB output plugin])
  AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
  AC_PLUGIN([zfs_arc],     [$plugin_zfs_arc],    [ZFS ARC statistics])
  
@@@ -5028,7 -4977,7 +5102,7 @@@ AC_SUBST(LCC_VERSION_STRING
  
  AC_CONFIG_FILES(src/libcollectdclient/lcc_features.h)
  
 -AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/owniptc/Makefile src/libcollectdclient/Makefile src/libcollectdclient/libcollectdclient.pc src/liboconfig/Makefile bindings/Makefile bindings/java/Makefile)
 +AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libcollectdclient/Makefile src/libcollectdclient/libcollectdclient.pc src/liboconfig/Makefile bindings/Makefile bindings/java/Makefile)
  
  if test "x$with_librrd" = "xyes" \
        && test "x$librrd_threadsafe" != "xyes"
@@@ -5130,7 -5079,6 +5204,7 @@@ Configuration
      dns . . . . . . . . . $enable_dns
      email . . . . . . . . $enable_email
      entropy . . . . . . . $enable_entropy
 +    ethstat . . . . . . . $enable_ethstat
      exec  . . . . . . . . $enable_exec
      filecount . . . . . . $enable_filecount
      fscache . . . . . . . $enable_fscache
      match_timediff  . . . $enable_match_timediff
      match_value . . . . . $enable_match_value
      mbmon . . . . . . . . $enable_mbmon
 +    md  . . . . . . . . . $enable_md
      memcachec . . . . . . $enable_memcachec
      memcached . . . . . . $enable_memcached
      memory  . . . . . . . $enable_memory
      notify_desktop  . . . $enable_notify_desktop
      notify_email  . . . . $enable_notify_email
      ntpd  . . . . . . . . $enable_ntpd
 +    numa  . . . . . . . . $enable_numa
      nut . . . . . . . . . $enable_nut
      olsrd . . . . . . . . $enable_olsrd
      onewire . . . . . . . $enable_onewire
      vmem  . . . . . . . . $enable_vmem
      vserver . . . . . . . $enable_vserver
      wireless  . . . . . . $enable_wireless
 +    write_graphite  . . . $enable_write_graphite
      write_http  . . . . . $enable_write_http
      write_redis . . . . . $enable_write_redis
 +    write_mongodb . . . . $enable_write_mongodb
      xmms  . . . . . . . . $enable_xmms
      zfs_arc . . . . . . . $enable_zfs_arc
  
diff --combined src/zfs_arc.c
@@@ -1,7 -1,6 +1,7 @@@
  /**
   * collectd - src/zfs_arc.c
   * Copyright (C) 2009  Anthony Dewhurst
 + * Copyright (C) 2012  Aurelien Rougemont
   *
   * This program is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License as published by the
@@@ -18,7 -17,6 +18,7 @@@
   *
   * Authors:
   *   Anthony Dewhurst <dewhurst at gmail>
 + *   Aurelien Rougemont <beorn at gandi.net>
   **/
  
  #include "collectd.h"
@@@ -28,7 -26,7 +28,7 @@@
  /*
   * Global variables
   */
- static kstat_t *ksp;
  extern kstat_ctl_t *kc;
  
  static void za_submit (const char* type, const char* type_instance, value_t* values, int values_len)
@@@ -54,40 -52,12 +54,40 @@@ static void za_submit_gauge (const char
        za_submit (type, type_instance, &vv, 1);
  }
  
 -static void za_submit_derive (const char* type, const char* type_instance, derive_t dv)
 +static int za_read_derive (kstat_t *ksp, const char *kstat_value,
 +    const char *type, const char *type_instance)
  {
 -      value_t vv;
 +  long long tmp;
 +  value_t v;
 +
 +  tmp = get_kstat_value (ksp, (char *)kstat_value);
 +  if (tmp == -1LL)
 +  {
 +    ERROR ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value);
 +    return (-1);
 +  }
 +
 +  v.derive = (derive_t) tmp;
 +  za_submit (type, type_instance, /* values = */ &v, /* values_num = */ 1);
 +  return (0);
 +}
  
 -      vv.derive = dv;
 -      za_submit (type, type_instance, &vv, 1);
 +static int za_read_gauge (kstat_t *ksp, const char *kstat_value,
 +    const char *type, const char *type_instance)
 +{
 +  long long tmp;
 +  value_t v;
 +
 +  tmp = get_kstat_value (ksp, (char *)kstat_value);
 +  if (tmp == -1LL)
 +  {
 +    ERROR ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value);
 +    return (-1);
 +  }
 +
 +  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)
  
  static int za_read (void)
  {
 -      gauge_t  arc_size, l2_size;
 -      derive_t demand_data_hits,
 -               demand_metadata_hits,
 -               prefetch_data_hits,
 -               prefetch_metadata_hits,
 -               demand_data_misses,
 -               demand_metadata_misses,
 -               prefetch_data_misses,
 -               prefetch_metadata_misses;
        gauge_t  arc_hits, arc_misses, l2_hits, l2_misses;
        value_t  l2_io[2];
+       kstat_t  *ksp   = NULL;
  
        get_kstat (&ksp, "zfs", 0, "arcstats");
        if (ksp == NULL)
        }
  
        /* Sizes */
 -      arc_size   = get_kstat_value(ksp, "size");
 -      l2_size    = get_kstat_value(ksp, "l2_size");
 -
 -      za_submit_gauge ("cache_size", "arc", arc_size);
 -      za_submit_gauge ("cache_size", "L2", l2_size);
 +      za_read_gauge (ksp, "size",    "cache_size", "arc");
 +      za_read_gauge (ksp, "l2_size", "cache_size", "L2");
 +
 +        /* Operations */
 +      za_read_derive (ksp, "allocated","cache_operation", "allocated");
 +      za_read_derive (ksp, "deleted",  "cache_operation", "deleted");
 +      za_read_derive (ksp, "stolen",   "cache_operation", "stolen");
 +
 +        /* Issue indicators */
 +        za_read_derive (ksp, "mutex_miss", "mutex_operation", "miss");
 +      za_read_derive (ksp, "hash_collisions", "hash_collisions", "");
 +      
 +        /* Evictions */
 +      za_read_derive (ksp, "evict_l2_cached",     "cache_eviction", "cached");
 +      za_read_derive (ksp, "evict_l2_eligible",   "cache_eviction", "eligible");
 +      za_read_derive (ksp, "evict_l2_ineligible", "cache_eviction", "ineligible");
  
        /* Hits / misses */
 -      demand_data_hits       = get_kstat_value(ksp, "demand_data_hits");
 -      demand_metadata_hits   = get_kstat_value(ksp, "demand_metadata_hits");
 -      prefetch_data_hits     = get_kstat_value(ksp, "prefetch_data_hits");
 -      prefetch_metadata_hits = get_kstat_value(ksp, "prefetch_metadata_hits");
 -
 -      demand_data_misses       = get_kstat_value(ksp, "demand_data_misses");
 -      demand_metadata_misses   = get_kstat_value(ksp, "demand_metadata_misses");
 -      prefetch_data_misses     = get_kstat_value(ksp, "prefetch_data_misses");
 -      prefetch_metadata_misses = get_kstat_value(ksp, "prefetch_metadata_misses");
 -
 -      za_submit_derive ("cache_result", "demand_data-hit",       demand_data_hits);
 -      za_submit_derive ("cache_result", "demand_metadata-hit",   demand_metadata_hits);
 -      za_submit_derive ("cache_result", "prefetch_data-hit",     prefetch_data_hits);
 -      za_submit_derive ("cache_result", "prefetch_metadata-hit", prefetch_metadata_hits);
 -
 -      za_submit_derive ("cache_result", "demand_data-miss",       demand_data_misses);
 -      za_submit_derive ("cache_result", "demand_metadata-miss",   demand_metadata_misses);
 -      za_submit_derive ("cache_result", "prefetch_data-miss",     prefetch_data_misses);
 -      za_submit_derive ("cache_result", "prefetch_metadata-miss", prefetch_metadata_misses);
 +      za_read_derive (ksp, "demand_data_hits",         "cache_result", "demand_data-hit");
 +      za_read_derive (ksp, "demand_metadata_hits",     "cache_result", "demand_metadata-hit");
 +      za_read_derive (ksp, "prefetch_data_hits",       "cache_result", "prefetch_data-hit");
 +      za_read_derive (ksp, "prefetch_metadata_hits",   "cache_result", "prefetch_metadata-hit");
 +      za_read_derive (ksp, "demand_data_misses",       "cache_result", "demand_data-miss");
 +      za_read_derive (ksp, "demand_metadata_misses",   "cache_result", "demand_metadata-miss");
 +      za_read_derive (ksp, "prefetch_data_misses",     "cache_result", "prefetch_data-miss");
 +      za_read_derive (ksp, "prefetch_metadata_misses", "cache_result", "prefetch_metadata-miss");
  
        /* Ratios */
        arc_hits   = (gauge_t) get_kstat_value(ksp, "hits");
  
  static int za_init (void) /* {{{ */
  {
-       ksp = NULL;
        /* kstats chain already opened by update_kstat (using *kc), verify everything went fine. */
        if (kc == NULL)
        {