From 87a3da3a1cc2ad366bf3d1983718db485ad527b3 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sat, 29 Aug 2009 15:21:42 +0200 Subject: [PATCH] =?utf8?q?zfs=5Farc=20plugin:=20Renamed=20the=20=E2=80=9Ca?= =?utf8?q?rc=E2=80=9D=20plugin=20to=20=E2=80=9Czfs=5Farc=E2=80=9D.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- configure.in | 8 +++---- src/Makefile.am | 20 ++++++++--------- src/{arc.c => zfs_arc.c} | 58 +++++++++++++++++++++++++----------------------- 3 files changed, 44 insertions(+), 42 deletions(-) rename src/{arc.c => zfs_arc.c} (66%) diff --git a/configure.in b/configure.in index 19d5eefe..11ca85ec 100644 --- a/configure.in +++ b/configure.in @@ -3433,7 +3433,6 @@ dependency_warning="no" dependency_error="no" plugin_ascent="no" -plugin_arc="no" plugin_battery="no" plugin_bind="no" plugin_conntrack="no" @@ -3467,6 +3466,7 @@ plugin_uptime="no" plugin_vmem="no" plugin_vserver="no" plugin_wireless="no" +plugin_zfs_arc="no" # Linux if test "x$ac_system" = "xLinux" @@ -3516,7 +3516,7 @@ fi if test "x$with_kstat" = "xyes" then plugin_uptime="yes" - plugin_arc="yes" + plugin_zfs_arc="yes" fi if test "x$with_devinfo$with_kstat" = "xyesyes" @@ -3705,7 +3705,6 @@ AC_PLUGIN([apache], [$with_libcurl], [Apache httpd statistics]) AC_PLUGIN([apcups], [yes], [Statistics of UPSes by APC]) AC_PLUGIN([apple_sensors], [$with_libiokit], [Apple's hardware sensors]) AC_PLUGIN([ascent], [$plugin_ascent], [AscentEmu player statistics]) -AC_PLUGIN([arc], [$plugin_arc], [ARC statistics]) AC_PLUGIN([battery], [$plugin_battery], [Battery statistics]) AC_PLUGIN([bind], [$plugin_bind], [ISC Bind nameserver statistics]) AC_PLUGIN([conntrack], [$plugin_conntrack], [nf_conntrack statistics]) @@ -3790,6 +3789,7 @@ AC_PLUGIN([vserver], [$plugin_vserver], [Linux VServer statistics]) AC_PLUGIN([wireless], [$plugin_wireless], [Wireless statistics]) AC_PLUGIN([write_http], [$with_libcurl], [HTTP output plugin]) AC_PLUGIN([xmms], [$with_libxmms], [XMMS statistics]) +AC_PLUGIN([zfs_arc], [$plugin_zfs_arc], [ZFS ARC statistics]) dnl Default configuration file # Load either syslog or logfile @@ -4005,7 +4005,6 @@ Configuration: apcups . . . . . . . $enable_apcups apple_sensors . . . . $enable_apple_sensors ascent . . . . . . . $enable_ascent - arc . . . . . . . . . $enable_arc battery . . . . . . . $enable_battery bind . . . . . . . . $enable_bind conntrack . . . . . . $enable_conntrack @@ -4090,6 +4089,7 @@ Configuration: wireless . . . . . . $enable_wireless write_http . . . . . $enable_write_http xmms . . . . . . . . $enable_xmms + zfs_arc . . . . . . . $enable_zfs_arc EOF diff --git a/src/Makefile.am b/src/Makefile.am index 3ea0682f..0dd5ff31 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -142,16 +142,6 @@ collectd_LDADD += "-dlopen" ascent.la collectd_DEPENDENCIES += ascent.la endif -if BUILD_PLUGIN_ARC -pkglib_LTLIBRARIES += arc.la -arc_la_SOURCES = arc.c -arc_la_CFLAGS = $(AM_CFLAGS) -arc_la_LDFLAGS = -module -avoid-version -arc_la_LIBADD = -lkstat -collectd_LDADD += "-dlopen" arc.la -collectd_DEPENDENCIES += arc.la -endif - if BUILD_PLUGIN_BATTERY pkglib_LTLIBRARIES += battery.la battery_la_SOURCES = battery.c @@ -1076,6 +1066,16 @@ collectd_LDADD += "-dlopen" xmms.la collectd_DEPENDENCIES += xmms.la endif +if BUILD_PLUGIN_ZFS_ARC +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 + dist_man_MANS = collectd.1 \ collectd.conf.5 \ diff --git a/src/arc.c b/src/zfs_arc.c similarity index 66% rename from src/arc.c rename to src/zfs_arc.c index 8d0eca8e..43e5b03e 100644 --- a/src/arc.c +++ b/src/zfs_arc.c @@ -1,6 +1,6 @@ /** - * collectd - src/arc.c - * Copyright (C) 2009 Anthony Dewhurst + * collectd - src/zfs_arc.c + * Copyright (C) 2009 Anthony Dewhurst * * 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 @@ -29,7 +29,7 @@ static kstat_t *ksp; extern kstat_ctl_t *kc; -static void arc_submit (const char* type, const char* type_instance, value_t values[], int values_len) +static void za_submit (const char* type, const char* type_instance, value_t values[], int values_len) { value_list_t vl = VALUE_LIST_INIT; @@ -37,23 +37,23 @@ static void arc_submit (const char* type, const char* type_instance, value_t val vl.values_len = values_len; sstrncpy (vl.host, hostname_g, sizeof (vl.host)); - sstrncpy (vl.plugin, "arc", sizeof (vl.plugin)); + sstrncpy (vl.plugin, "zfs_arc", sizeof (vl.plugin)); sstrncpy (vl.type, type, sizeof (vl.type)); sstrncpy (vl.type_instance, type_instance, sizeof (vl.type)); plugin_dispatch_values (&vl); } -static void arc_submit_gauge (const char* type, const char* type_instance, gauge_t value) +static void za_submit_gauge (const char* type, const char* type_instance, gauge_t value) { value_t values[1]; values[0].gauge = value; - arc_submit (type, type_instance, values, STATIC_ARRAY_SIZE(values)); + za_submit (type, type_instance, values, STATIC_ARRAY_SIZE(values)); } -static void arc_submit_size (gauge_t size, gauge_t size_target, gauge_t limit_min, gauge_t limit_max) +static void za_submit_size (gauge_t size, gauge_t size_target, gauge_t limit_min, gauge_t limit_max) { value_t values[4]; @@ -62,20 +62,20 @@ static void arc_submit_size (gauge_t size, gauge_t size_target, gauge_t limit_mi values[2].gauge = limit_min; values[3].gauge = limit_max; - arc_submit ("arc_size", "", values, STATIC_ARRAY_SIZE(values)); + za_submit ("arc_size", "", values, STATIC_ARRAY_SIZE(values)); } -static void arc_submit_bytes (counter_t read, counter_t write) +static void za_submit_bytes (counter_t read, counter_t write) { value_t values[2]; values[0].counter = read; values[1].counter = write; - arc_submit ("arc_l2_bytes", "", values, STATIC_ARRAY_SIZE(values)); + za_submit ("arc_l2_bytes", "", values, STATIC_ARRAY_SIZE(values)); } -static void arc_submit_counts (char *type_instance, counter_t demand_data, counter_t demand_metadata, +static void za_submit_counts (char *type_instance, counter_t demand_data, counter_t demand_metadata, counter_t prefetch_data, counter_t prefetch_metadata) { value_t values[4]; @@ -85,10 +85,10 @@ static void arc_submit_counts (char *type_instance, counter_t demand_data, count values[2].counter = prefetch_data; values[3].counter = prefetch_metadata; - arc_submit ("arc_counts", type_instance, values, STATIC_ARRAY_SIZE(values)); + za_submit ("arc_counts", type_instance, values, STATIC_ARRAY_SIZE(values)); } -static int arc_read (void) +static int za_read (void) { gauge_t arcsize, targetsize, minlimit, maxlimit, hits, misses, l2_size, l2_hits, l2_misses; counter_t demand_data_hits, demand_metadata_hits, prefetch_data_hits, prefetch_metadata_hits; @@ -98,7 +98,7 @@ static int arc_read (void) get_kstat (&ksp, "zfs", 0, "arcstats"); if (ksp == NULL) { - ERROR ("arc plugin: Cannot find zfs:0:arcstats kstat."); + ERROR ("zfs_arc plugin: Cannot find zfs:0:arcstats kstat."); return (-1); } @@ -127,38 +127,40 @@ static int arc_read (void) l2_misses = get_kstat_value(ksp, "l2_misses"); - arc_submit_size (arcsize, targetsize, minlimit, maxlimit); - arc_submit_gauge ("arc_l2_size", "", l2_size); + za_submit_size (arcsize, targetsize, minlimit, maxlimit); + za_submit_gauge ("arc_l2_size", "", l2_size); - arc_submit_counts ("hits", demand_data_hits, demand_metadata_hits, - prefetch_data_hits, prefetch_metadata_hits); - arc_submit_counts ("misses", demand_data_misses, demand_metadata_misses, - prefetch_data_misses, prefetch_metadata_misses); + za_submit_counts ("hits", demand_data_hits, demand_metadata_hits, + prefetch_data_hits, prefetch_metadata_hits); + za_submit_counts ("misses", demand_data_misses, demand_metadata_misses, + prefetch_data_misses, prefetch_metadata_misses); - arc_submit_gauge ("arc_ratio", "L1", hits / (hits + misses)); - arc_submit_gauge ("arc_ratio", "L2", l2_hits / (l2_hits + l2_misses)); + za_submit_gauge ("arc_ratio", "L1", hits / (hits + misses)); + za_submit_gauge ("arc_ratio", "L2", l2_hits / (l2_hits + l2_misses)); - arc_submit_bytes (l2_read_bytes, l2_write_bytes); + za_submit_bytes (l2_read_bytes, l2_write_bytes); return (0); } -static int arc_init (void) /* {{{ */ +static int za_init (void) /* {{{ */ { ksp = NULL; /* kstats chain already opened by update_kstat (using *kc), verify everything went fine. */ if (kc == NULL) { - ERROR ("arc plugin: kstat chain control structure not available."); + ERROR ("zfs_arc plugin: kstat chain control structure not available."); return (-1); } return (0); -} /* }}} int arc_init */ +} /* }}} int za_init */ void module_register (void) { - plugin_register_init ("arc", arc_init); - plugin_register_read ("arc", arc_read); + plugin_register_init ("zfs_arc", za_init); + plugin_register_read ("zfs_arc", za_read); } /* void module_register */ + +/* vmi: set sw=8 noexpandtab fdm=marker : */ -- 2.11.0