[xiph-commits] r9068 - trunk/mgm/modules/linux
xiphmont at motherfish-iii.xiph.org
xiphmont at motherfish-iii.xiph.org
Sat Mar 12 20:48:29 PST 2005
Author: xiphmont
Date: 2005-03-12 20:48:27 -0800 (Sat, 12 Mar 2005)
New Revision: 9068
Modified:
trunk/mgm/modules/linux/memuse
Log:
Update linux memuse module to understand kernel 2.6 syntax
Modified: trunk/mgm/modules/linux/memuse
===================================================================
--- trunk/mgm/modules/linux/memuse 2005-03-12 14:39:40 UTC (rev 9067)
+++ trunk/mgm/modules/linux/memuse 2005-03-13 04:48:27 UTC (rev 9068)
@@ -72,24 +72,46 @@
}
sub read_proc{
+ $memtotal=0;
+ $memuse=0;
+ $swaptotal=0;
+ $swapuse=0;
+
if(open(PROC,"/proc/meminfo")){
- <PROC>;
- $_=<PROC>;
- if(m/^Mem:\s+(\d+)\s+(\d+)\s+\d+\s+\d+\s+(\d+)\s+(\d+)/){
- $memtotal=$1;
- $memuse=$2-$3-$4;
- }else{
- $memtotal=0;
- $memuse=0;
+
+ while(defined($_=<PROC>)){
+
+ # 2.0/2.2/2.4-ish
+ if(m/^Mem:\s+(\d+)\s+(\d+)\s+\d+\s+\d+\s+(\d+)\s+(\d+)/){
+ $memtotal=$1;
+ $memuse=$2-$3-$4;
+ }
+ if(m/^Swap:\s+(\d+)\s+(\d+)/){
+ $swaptotal=$1;
+ $swapuse=$2;
+ }
+
+ # 2.6-ish
+ if(m/^MemTotal:\s+(\d+)\s+kB/){
+ $memtotal=$1*1000;
+ }
+ if(m/^SwapTotal:\s+(\d+)\s+kB/){
+ $swaptotal=$1*1000;
+ }
+ if(m/^MemFree:\s+(\d+)\s+kB/){
+ $memuse=$memtotal-$1*1000;
+ }
+ if(m/^Buffers:\s+(\d+)\s+kB/){
+ $memuse=$memuse-$1*1000;
+ }
+ if(m/^Cached:\s+(\d+)\s+kB/){
+ $memuse=$memuse-$1*1000;
+ }
+ if(m/^SwapFree:\s+(\d+)\s+kB/){
+ $swapuse=$swaptotal-$1*1000;
+ }
}
- $_=<PROC>;
- if(m/^Swap:\s+(\d+)\s+(\d+)/){
- $swaptotal=$1;
- $swapuse=$2;
- }else{
- $swaptotal=0;
- $swapuse=0;
- }
+
close PROC;
}
}
More information about the commits
mailing list