Merge branch 'collectd-3.11' into collectd-4.0
[collectd.git] / src / swap.c
index 945c758..3018cb9 100644 (file)
 #undef  MAX
 #define MAX(x,y) ((x) > (y) ? (x) : (y))
 
-static data_source_t data_source[1] =
-{
-       {"value", DS_TYPE_GAUGE, 0, 1099511627776.0}
-};
-
-static data_set_t data_set =
-{
-       "swap", 1, data_source
-};
-
 #if SWAP_HAVE_READ
 #if KERNEL_LINUX
 /* No global variables */
@@ -156,7 +146,9 @@ static int swap_read (void)
 
        if ((fh = fopen ("/proc/meminfo", "r")) == NULL)
        {
-               WARNING ("memory: fopen: %s", strerror (errno));
+               char errbuf[1024];
+               WARNING ("memory: fopen: %s",
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
                return (-1);
        }
 
@@ -182,7 +174,11 @@ static int swap_read (void)
        }
 
        if (fclose (fh))
-               WARNING ("memory: fclose: %s", strerror (errno));
+       {
+               char errbuf[1024];
+               WARNING ("memory: fclose: %s",
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
+       }
 
        if ((swap_total == 0LL) || ((swap_free + swap_cached) > swap_total))
                return (-1);
@@ -203,8 +199,9 @@ static int swap_read (void)
 
        if (swapctl (SC_AINFO, &ai) == -1)
        {
+               char errbuf[1024];
                ERROR ("swap plugin: swapctl failed: %s",
-                               strerror (errno));
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
                return (-1);
        }
 
@@ -307,10 +304,8 @@ static int swap_read (void)
 
 void module_register (void)
 {
-       plugin_register_data_set (&data_set);
-
 #if SWAP_HAVE_READ
        plugin_register_init ("swap", swap_init);
        plugin_register_read ("swap", swap_read);
 #endif /* SWAP_HAVE_READ */
-}
+} /* void module_register */