summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d26335b)
raw | patch | inline | side by side (parent: d26335b)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 30 Dec 2010 07:54:04 +0000 (08:54 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 30 Dec 2010 07:54:04 +0000 (08:54 +0100) |
As discussed with Aurélien Reynaud on the mailing list.
configure.in | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history | |
src/swap.c | patch | blob | history |
diff --git a/configure.in b/configure.in
index 69bbfe19513a429c8cb7d3a1ffd815e1ecc03772..60b740c8888a76fa9b998a616a10ac15096df2a5 100644 (file)
--- a/configure.in
+++ b/configure.in
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 589e1694c080a3944486020dcd471b9a5df16823..b63f486ba0cb984e1375a475d064947b8f762668 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
=head2 Plugin C<swap>
The I<Swap plugin> 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<Solaris>, the
-following options are available:
+I<Solaris>, the following options are available:
=over 4
-=item B<ReportPhysical> B<combined>|B<separate>|B<false>
+=item B<ReportByDevice> B<false>|B<true>
-Configures how to report physical swap devices. If B<combined> is used (the
+Configures how to report physical swap devices. If set to B<false> 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<separate> is configured, the
-used and available space of each device will be reported separately. B<false>
-deactivates collection of physical swap information (only valid if collection
-via L<kstat(3KSTAT)> is available).
+used and available space over all devices. If B<true> is configured, the used
+and available space of each device will be reported separately.
This option is only available if the I<Swap plugin> can use the L<swapctl(2)>
mechanism under I<Solaris>.
-=item B<ReportVirtual> B<false>|B<true>
-
-Configures whether or not to report the view of the virtual memory subsystem on
-swap space. This information is used under Solaris if L<swapctl(2)> is not
-available and was the default behavior under I<Solaris> in I<collectdE<nbsp>4>.
-
-This option is only available if the I<Swap plugin> can use L<swapctl(2)> and
-L<kstat(3KSTAT)> to collect swap statistics under I<Solaris>. It defaults to
-B<false>.
-
=back
=head2 Plugin C<syslog>
diff --git a/src/swap.c b/src/swap.c
index a1c78b6ca4a204c70bae8d8855875659bdb3e64a..6c34602150890dad0df90c824efda16de2d8385b 100644 (file)
--- a/src/swap.c
+++ b/src/swap.c
/* 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 */
/* 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 ();
} /* }}} 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) /* {{{ */
{
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;
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;
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);
/* 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);
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) /* {{{ */
return (0);
} /* }}} int swap_read */
-/* #endif HAVE_SWAPCTL */
+/* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_THREE_ARGS */
#elif defined(VM_SWAPUSAGE)
static int swap_read (void) /* {{{ */