aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Lorenz <12514511+RincewindsHat@users.noreply.github.com> 2022-01-03 14:35:29 +0100
committerGravatar GitHub <noreply@github.com> 2022-01-03 14:35:29 +0100
commit9899bc736f45400fa70bdee281f5f5b46490b805 (patch)
tree60b951b3a120e3e2db8c1e1d4146dfdbf45083b6
parent78a999edd4dd3305ef8fa3e06c43f6a893fb6fea (diff)
parentd496d6523bd0def281f001ddfb2a3f467bd9a4a6 (diff)
downloadmonitoring-plugins-9899bc736f45400fa70bdee281f5f5b46490b805.tar.gz
Merge pull request #1642 from mdavranche/master
check_swap: Handle cached swap
-rw-r--r--plugins/check_swap.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 7da26cfc..bb854beb 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -145,11 +145,12 @@ main (int argc, char **argv)
xasprintf (&status, "%s [%lu (%d%%)]", status, dskfree_mb, 100 - percent);
}
}
+
/*
* The following sscanf call looks for lines looking like: "SwapTotal: 123" and "SwapFree: 123"
* This format exists at least on Debian Linux with a 5.* kernel
*/
- else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %lu %*[k]%*[B]", str, &tmp_KB)) {
+ else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFreCchd]%*[:] %f %*[k]%*[B]", str, &tmp_KB)) {
if (verbose >= 3) {
printf("Got %s with %lu\n", str, tmp_KB);
}
@@ -158,7 +159,10 @@ main (int argc, char **argv)
dsktotal_mb = tmp_KB / 1024;
}
else if (strcmp ("Free", str) == 0) {
- dskfree_mb = tmp_KB / 1024;
+ dskfree_mb = dskfree_mb + tmp_KB / 1024;
+ }
+ else if (strcmp ("Cached", str) == 0) {
+ dskfree_mb = dskfree_mb + tmp_KB / 1024;
}
}
}