From 1a146775d42a15202cba4e19c0fcda465705bcb8 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 17 Sep 2014 07:41:38 +0200 Subject: [PATCH] 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 --- src/swap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 */ -- 2.11.0