From: Florian Forster Date: Wed, 17 Sep 2014 05:41:38 +0000 (+0200) Subject: swap plugin: Make "cached" optional under Linux. X-Git-Tag: collectd-5.3.2~33 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1a146775d42a15202cba4e19c0fcda465705bcb8;p=collectd.git swap plugin: Make "cached" optional under Linux. This is the smallest possible fix for OpenVZ, where cached is not available. master has a more complete fix which should be used going forward. Fixes: #733 --- diff --git a/src/swap.c b/src/swap.c index 46d3534f..1621f7af 100644 --- a/src/swap.c +++ b/src/swap.c @@ -339,7 +339,7 @@ static int swap_read_combined (void) /* {{{ */ fclose (fh); - if (have_data != 0x07) + if ((have_data & 0x03) != 0x03) return (ENOENT); if (isnan (swap_total) @@ -351,7 +351,8 @@ static int swap_read_combined (void) /* {{{ */ swap_submit_gauge (NULL, "used", 1024.0 * swap_used); swap_submit_gauge (NULL, "free", 1024.0 * swap_free); - swap_submit_gauge (NULL, "cached", 1024.0 * swap_cached); + if (have_data & 0x04) + swap_submit_gauge (NULL, "cached", 1024.0 * swap_cached); return (0); } /* }}} int swap_read_combined */