=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>
/* 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) /* {{{ */