collectd/collectd — Issue #10: swap plugin unable to report swap_io
Author: octo
Created: 2012-02-19 20:37:46+00:00
State: open

From: J Devenish (Mantis #18)

**Description:** is a string comparison logic error in src/swap.c which means it never records the actual values of pswpin (swap_io-in) or pswpout (swap_io-out).

**Discussion:**

*Rrpv:* I can confirm that bug and solution proposed.

On mine systems "cat /proc/vmstat" shows "unevictable_pgs_mlockfreed 0" as a last string, thats why both 'swap_in' and 'swap_out' values are equal to zero in mostly cases. The first, 'swap_in', is zero because the "unevictable_pgs_mlockfreed" counter grows rarely, and the second is zero because appropriate code is not reachable due wrong condition.

I think this patch need to be committed.

----

*Rrpv:* Additionaly, on my Linux system, page is 4k size, so multiplication is needed.

```patch
-swap_submit ("in", swap_in, DS_TYPE_DERIVE);
-swap_submit ("out", swap_out, DS_TYPE_DERIVE);
+swap_submit ("in", 4096 * swap_in, DS_TYPE_DERIVE);
+swap_submit ("out", 4096 * swap_out, DS_TYPE_DERIVE);
```

But I do not know, how the page size should be defined in the common case.