Use swap -l command to get virtual memory size
authorJamie Cameron <jcameron@webmin.com>
Wed, 27 Jun 2007 00:13:17 +0000 (00:13 +0000)
committerJamie Cameron <jcameron@webmin.com>
Wed, 27 Jun 2007 00:13:17 +0000 (00:13 +0000)
proc/sysv-lib.pl

index b99954a..3cd7182 100644 (file)
@@ -225,9 +225,17 @@ foreach my $s ("physmem", "freemem", "swap_alloc", "swap_avail") {
                $stat{$s} = $1;
                }
        }
+local ($swaptotal, $swapfree);
+&open_execute_command(SWAP, "swap -l", 1);
+while(<SWAP>) {
+       if (/^\S+\s+\d+,\d+\s+\d+\s+(\d+)\s+(\d+)/) {
+               $swaptotal += $1;
+               $swapfree += $2;
+               }
+       }
+close(SWAP);
 return ($stat{'physmem'}*8, $stat{'freemem'}*8,
-       $stat{'swap_avail'}/1048576,
-       ($stat{'swap_avail'}-$stat{'swap_alloc'})/1048576);
+       $swaptotal/2, $swapfree/2);
 }