Module: monitoring-plugins
 Branch: master
 Commit: 11af74de386ba7c02d5d0e53f2500b5029a4537d
 Author: mdavranche <mdavranche@erine.email>
   Date: Tue Aug 18 15:37:38 2020 -0400
    URL: 
https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=11af74d

check_swap: Handle cached swap

---

 plugins/check_swap.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 0ff0c77..ce3f1d7 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -133,7 +133,7 @@ main (int argc, char **argv)
                                        xasprintf (&status, "%s [%.0f (%d%%)]", 
status, dskfree_mb, 100 - percent);
                        }
                }
-               else if (sscanf (input_buffer, 
"%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %f %*[k]%*[B]", str, &tmp_mb)) {
+               else if (sscanf (input_buffer, 
"%*[S]%*[w]%*[a]%*[p]%[TotalFreCchd]%*[:] %f %*[k]%*[B]", str, &tmp_mb)) {
                        if (verbose >= 3) {
                                printf("Got %s with %f\n", str, tmp_mb);
                        }
@@ -142,7 +142,10 @@ main (int argc, char **argv)
                                dsktotal_mb = tmp_mb / 1024;
                        }
                        else if (strcmp ("Free", str) == 0) {
-                               dskfree_mb = tmp_mb / 1024;
+                               dskfree_mb = dskfree_mb + tmp_mb / 1024;
+                       }
+                       else if (strcmp ("Cached", str) == 0) {
+                               dskfree_mb = dskfree_mb + tmp_mb / 1024;
                        }
                }
        }

Reply via email to