[xiph-cvs] cvs commit: mgm/modules/linux diskstat

Monty xiphmont at xiph.org
Sun Apr 22 16:21:48 PDT 2001



xiphmont    01/04/22 16:21:48

  Modified:    modules/linux diskstat
  Log:
  Updated for linux 2.4 style disk reporting
  
  Monty

Revision  Changes    Path
1.6       +38 -6     mgm/modules/linux/diskstat

Index: diskstat
===================================================================
RCS file: /usr/local/cvsroot/mgm/modules/linux/diskstat,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- diskstat	1999/09/28 20:23:20	1.5
+++ diskstat	2001/04/22 23:21:48	1.6
@@ -13,7 +13,7 @@
 
 package MGMmodule::diskstat;
 use vars qw($xpath @rsectors @wsectors @prevr @prevw $widget $graph 
-	    $numdisks $lastmod);
+	    $numdisks $lastmod $kernel);
 
 # class init
 sub module_init{
@@ -23,8 +23,17 @@
 
     # how many disks?  Call read once to init
     $numdisks=0;
-    $this->read_proc if(defined($MGMmodule::helperST::proc{"disk_rblk"}));
 
+    # 2.0 and 2.2
+    if(defined($MGMmodule::helperST::proc{"disk_rblk"})){
+	$kernel=0;$this->read_proc; 
+    }
+
+    # 2.4
+    if(defined($MGMmodule::helperST::proc{"disk_io:"})){
+	$kernel=4;$this->read_proc;
+    } 
+
     map{$numdisks++ if ($rsectors[$_] || $wsectors[$_])}(0..$#rsectors);
 
     if(!$numdisks){
@@ -52,7 +61,7 @@
         $toplevel->optionAdd("$xpath.bar.".($i*2+1).".litbackground", 
                              '#ade774',21);
     }
-    $toplevel->optionAdd("$xpath.scalewidadj", 150*$numdisks,21);  # narrower
+    $toplevel->optionAdd("$xpath.scalewidadj", 160*$numdisks,21);  # narrower
     $toplevel->optionAdd("$xpath.scalereturn", 120,21);
     # this relies on the above defaults
 
@@ -78,9 +87,22 @@
 
 sub read_proc{
     # now uses the 00helper to save on opens 
-
-    @rsectors=split ' ',$MGMmodule::helperST::proc{"disk_rblk"};
-    @wsectors=split ' ',$MGMmodule::helperST::proc{"disk_wblk"};
+    if($kernel==4){
+	my $disk;
+	my at disks=split ' ',$MGMmodule::helperST::proc{"disk_io:"};
+	my$i=0;
+	undef @rsectors;
+	undef @wsectors;
+	foreach $disk (@disks){
+	    $disk=~m/\(\d+,\d+\):\(\d+,\d+,(\d+),\d+,(\d+)\)/;
+	    $rsectors[$i]=$1;
+	    $wsectors[$i]=$2;
+	    $i++;
+	}
+    }else{
+	@rsectors=split ' ',$MGMmodule::helperST::proc{"disk_rblk"};
+	@wsectors=split ' ',$MGMmodule::helperST::proc{"disk_wblk"};
+    }
 }
 
 sub module_update{ 
@@ -90,6 +112,9 @@
     if($lastmod!=$MGMmodule::helperST::lastmod){
         my$time=$MGMmodule::helperST::lastmod;
         $this->read_proc;
+
+	return &reconfig if($numdisks-1 != $#rsectors);
+
         if(defined(@prevr)){
             my @vals;
             
@@ -112,6 +137,13 @@
         @prevw=@wsectors;
         $lastmod=$time;
     }
+}
+
+sub reconfig{
+    $numdisks= $#rsectors+1;
+    @prevr=@rsectors;
+    @prevw=@wsectors;
+    &main::reinstance() if($widget->optionGet("reconfig","") eq 'true');
 }
 
 sub destroy{

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list