From 0727d3efa7cfa2c79304f68bfc6da9c2a4040613 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 30 Dec 2010 08:54:04 +0100 Subject: [PATCH] swap plugin: Deactivate the kstat-based code. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit As discussed with Aurélien Reynaud on the mailing list. --- configure.in | 5 -- src/collectd.conf.pod | 24 ++------ src/swap.c | 127 +++++++++--------------------------------- 3 files changed, 30 insertions(+), 126 deletions(-) diff --git a/configure.in b/configure.in index 69bbfe19..60b740c8 100644 --- a/configure.in +++ b/configure.in @@ -4366,11 +4366,6 @@ then plugin_tape="yes" fi -if test "x$have_sys_swap_h$with_kstat$ac_system" = "xyesyesSolaris" -then - plugin_swap="yes" -fi - # libstatgrab if test "x$with_libstatgrab" = "xyes" then diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 589e1694..b63f486b 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -4172,34 +4172,20 @@ L. Please see there for details. =head2 Plugin C The I collects information about used and available swap space. On -Solaris, it is possible to collect information on physical swap devices and the -view of the virtual memory subsystem on the matter. On I, the -following options are available: +I, the following options are available: =over 4 -=item B B|B|B +=item B B|B -Configures how to report physical swap devices. If B is used (the +Configures how to report physical swap devices. If set to B is used (the default), the summary over all swap devices is reported only, i.e. the globally -used and available space over all devices. If B is configured, the -used and available space of each device will be reported separately. B -deactivates collection of physical swap information (only valid if collection -via L is available). +used and available space over all devices. If B is configured, the used +and available space of each device will be reported separately. This option is only available if the I can use the L mechanism under I. -=item B B|B - -Configures whether or not to report the view of the virtual memory subsystem on -swap space. This information is used under Solaris if L is not -available and was the default behavior under I in I4>. - -This option is only available if the I can use L and -L to collect swap statistics under I. It defaults to -B. - =back =head2 Plugin C diff --git a/src/swap.c b/src/swap.c index a1c78b6c..6c346021 100644 --- a/src/swap.c +++ b/src/swap.c @@ -73,28 +73,17 @@ /* No global variables */ /* #endif KERNEL_LINUX */ -#elif HAVE_LIBKSTAT || (HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS) +#elif HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS static derive_t pagesize; -# if HAVE_LIBKSTAT -static kstat_t *ksp; -# endif /* HAVE_LIBKSTAT */ -# if HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS static const char *config_keys[] = { -# if HAVE_LIBKSTAT - "ReportVirtual", -# endif - "ReportPhysical" + "ReportByDevice" }; static int config_keys_num = STATIC_ARRAY_SIZE (config_keys); -# if HAVE_LIBKSTAT -static _Bool report_virtual = 0; -# endif -static int report_physical = 1; -# endif /* HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS */ -/* #endif HAVE_LIBKSTAT || (HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS) */ +static _Bool report_by_device = 0; +/* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS */ #elif defined(VM_SWAPUSAGE) /* No global variables */ @@ -124,13 +113,6 @@ static int swap_init (void) /* No init stuff */ /* #endif KERNEL_LINUX */ -#elif HAVE_LIBKSTAT - /* getpagesize(3C) tells me this does not fail.. */ - pagesize = (derive_t) getpagesize (); - if (get_kstat (&ksp, "unix", 0, "system_pages")) - ksp = NULL; -/* #endif HAVE_LIBKSTAT */ - #elif HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS /* getpagesize(3C) tells me this does not fail.. */ pagesize = (derive_t) getpagesize (); @@ -320,14 +302,16 @@ static int swap_read (void) /* {{{ */ } /* }}} int swap_read */ /* #endif KERNEL_LINUX */ -/* Sorry for the amount of preprocessor magic that follows. Under Solaris, two - * mechanisms can be used to read swap statistics, swapctl and kstat. The - * former reads physical space used on a device, the latter reports the view - * from the virtual memory system. The following magic tries to be as flexible - * as possible by allowing either mechanism to be missing and act correctly in - * the event that both are available, i.e. let the user decide what to do. */ -#elif HAVE_LIBKSTAT || (HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS) -# if HAVE_LIBKSTAT +/* + * Under Solaris, two mechanisms can be used to read swap statistics, swapctl + * and kstat. The former reads physical space used on a device, the latter + * reports the view from the virtual memory system. It was decided that the + * kstat-based information should be moved to the "vmem" plugin, but nobody + * with enough Solaris experience was available at that time to do this. The + * code below is still there for your reference but it won't be activated in + * *this* plugin again. --octo + */ +#elif 0 && HAVE_LIBKSTAT /* kstat-based read function */ static int swap_read_kstat (void) /* {{{ */ { @@ -377,11 +361,11 @@ static int swap_read_kstat (void) /* {{{ */ return (0); } /* }}} int swap_read_kstat */ -# endif /* HAVE_LIBKSTAT */ +/* #endif 0 && HAVE_LIBKSTAT */ -# if HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS +#elif HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS /* swapctl-based read function */ -static int swap_read_swapctl2 (void) /* {{{ */ +static int swap_read (void) /* {{{ */ { swaptbl_t *s; char *s_paths; @@ -463,7 +447,7 @@ static int swap_read_swapctl2 (void) /* {{{ */ this_avail = ((derive_t) s->swt_ent[i].ste_free) * pagesize; /* Shortcut for the "combined" setting (default) */ - if (report_physical != 2) + if (!report_by_device) { avail += this_avail; total += this_total; @@ -501,9 +485,9 @@ static int swap_read_swapctl2 (void) /* {{{ */ return (-1); } - /* If the "separate" option was specified (report_physical == 2), all + /* If the "separate" option was specified (report_by_device == 2), all * values have already been dispatched from within the loop. */ - if (report_physical != 2) + if (!report_by_device) { swap_submit ("used", total - avail, DS_TYPE_GAUGE); swap_submit ("free", avail, DS_TYPE_GAUGE); @@ -517,36 +501,13 @@ static int swap_read_swapctl2 (void) /* {{{ */ /* Configuration: Present when swapctl or both methods are available. */ static int swap_config (const char *key, const char *value) /* {{{ */ { - if (strcasecmp ("ReportPhysical", key) == 0) - { - if (strcasecmp ("combined", value) == 0) - report_physical = 1; - else if (strcasecmp ("separate", value) == 0) - report_physical = 2; -# if HAVE_LIBKSTAT - else if (IS_TRUE (value)) - report_physical = 1; - else if (IS_FALSE (value)) - report_physical = 0; -# endif - else - WARNING ("swap plugin: The value \"%s\" is not " - "recognized by the ReportPhysical option.", - value); - } -# if HAVE_LIBKSTAT - else if (strcasecmp ("ReportVirtual", key) == 0) + if (strcasecmp ("ReportByDevice", key) == 0) { if (IS_TRUE (value)) - report_physical = 1; - else if (IS_FALSE (value)) - report_physical = 0; + report_by_device = 1; else - WARNING ("swap plugin: The value \"%s\" is not " - "recognized by the ReportVirtual option.", - value); + report_by_device = 0; } -# endif /* HAVE_LIBKSTAT */ else { return (-1); @@ -554,45 +515,7 @@ static int swap_config (const char *key, const char *value) /* {{{ */ return (0); } /* }}} int swap_config */ -# endif /* HAVE_SWAPCTL_TWO_ARGS */ - -/* If both methods are available, check the config variables to decide which - * function to call. Otherwise, add aliases for the functions so we can - * "swap_read" in "module_register". */ -# if HAVE_LIBKSTAT && HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS -static int swap_read (void) /* {{{ */ -{ - int status; - - if (!report_physical && !report_virtual) - { - WARNING ("swap plugin: Neither the \"ReportPhysical\" nor the \"ReportVirtual\" option " - "has been activated. This plugin will not collect any data."); - return (-1); - } - - if (report_physical) - { - status = swap_read_swapctl2 (); - if (status != 0) - return (status); - } - - if (report_virtual) - { - status = swap_read_kstat (); - if (status != 0) - return (status); - } - - return (0); -} /* }}} int swap_read */ -# elif HAVE_LIBKSTAT -# define swap_read swap_read_kstat -# else /* if HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS */ -# define swap_read swap_read_swapctl2 -# endif -/* #endif HAVE_LIBKSTAT || (HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS) */ +/* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS */ #elif HAVE_SWAPCTL && HAVE_SWAPCTL_THREE_ARGS static int swap_read (void) /* {{{ */ @@ -663,7 +586,7 @@ static int swap_read (void) /* {{{ */ return (0); } /* }}} int swap_read */ -/* #endif HAVE_SWAPCTL */ +/* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_THREE_ARGS */ #elif defined(VM_SWAPUSAGE) static int swap_read (void) /* {{{ */ -- 2.30.2