]> git.etc.gen.nz Git - spong.git/commitdiff
Support the output of top on Linux.
authorAndrew Ruthven <andrew@etc.gen.nz>
Sun, 23 Dec 2007 03:21:23 +0000 (16:21 +1300)
committerAndrew Ruthven <andrew@etc.gen.nz>
Sun, 23 Dec 2007 03:21:23 +0000 (16:21 +1300)
src/lib/Spong/Client/plugins/check_memory

index 97a43c8b4a6ff91ab917b89ee33734fee9987d11..050aedf3268a273083852022ecb6af8894cdf66c 100755 (executable)
@@ -77,13 +77,13 @@ sub check_memory_top {
       $message .= $_;
       if (/^Mem/) {
          # top from the procps on Linux has this format:
-         if (/^Mem:$kmb av,$kmb used,$kmb free,$kmb shrd,$kmb buff/) {
-            ($memtotal,$memused,$memfree,$shared,$buffers) = ($1,$2,$3,$4,$5);
+         if (/^Mem:$kmb (av|total),$kmb used,$kmb free,($kmb shrd,)?$kmb buff/i) {
+            ($memtotal,$memused,$memfree,$shared,$buffers) = ($1,$3,$4,$7,$8);
             &to_KB($memtotal,$memused,$memfree,$shared,$buffers);
             $_ = <CMD>;
             $message .= $_;
-            if (/^Swap:$kmb av,$kmb used,$kmb free$kmb cached/) {
-               ($swaptotal, $swapused, $swapfree, $cached) = ($1,$2,$3,$4);
+            if (/^Swap:$kmb (av|total),$kmb used,$kmb free,*$kmb cached/i) {
+               ($swaptotal, $swapused, $swapfree, $cached) = ($1,$3,$4,$5);
                &to_KB($swaptotal, $swapused, $swapfree, $cached);
             } else {
                close CMD;