[Orca-checkins] r458 - tags/orca/0.27/contrib/procallator

guilherme_chehab at yahoo.com guilherme_chehab at yahoo.com
Mon Jul 4 12:18:23 PDT 2005


Author: guilherme_chehab at yahoo.com
Date: Mon Jul  4 12:17:53 2005
New Revision: 458

Added:
   tags/orca/0.27/contrib/procallator/install.sh
      - copied unchanged from r456, /tags/orca/0.27/contrib/procallator/install.sh
   tags/orca/0.27/contrib/procallator/procallator
      - copied unchanged from r456, /tags/orca/0.27/contrib/procallator/procallator
   tags/orca/0.27/contrib/procallator/procallator.cfg
      - copied unchanged from r456, /tags/orca/0.27/contrib/procallator/procallator.cfg
   tags/orca/0.27/contrib/procallator/update_orca_server.sh
      - copied unchanged from r456, /tags/orca/0.27/contrib/procallator/update_orca_server.sh
Removed:
   tags/orca/0.27/contrib/procallator/CHANGES
   tags/orca/0.27/contrib/procallator/Makefile.in
   tags/orca/0.27/contrib/procallator/gpl.txt
   tags/orca/0.27/contrib/procallator/install.sh.in
   tags/orca/0.27/contrib/procallator/procallator.cfg.in
   tags/orca/0.27/contrib/procallator/procallator.in
   tags/orca/0.27/contrib/procallator/update_orca_server.sh.in
Modified:
   tags/orca/0.27/contrib/procallator/README
   tags/orca/0.27/contrib/procallator/TODO
   tags/orca/0.27/contrib/procallator/procallator.pl.in

Log:
* tags/orca/0.27:
   Revert revision 457 which committed the new procallator code to
   Orca's 0.27 tag instead of trunk.


Modified: tags/orca/0.27/contrib/procallator/README
==============================================================================
--- tags/orca/0.27/contrib/procallator/README	(original)
+++ tags/orca/0.27/contrib/procallator/README	Mon Jul  4 12:17:53 2005
@@ -19,5 +19,5 @@
 		- on the server, run orca using the exmple procallator.cfg
 
 This software is in alpha stage, use at your own risk.
-Any comments to Guilherme Chehab <guilherme_chehab at yahoo.com>
+Any comments to Guilherme Chehab <gchehab at abordo.com.br>
 Copyright (C) 2001 Guilherme Carvalho Chehab.  All Rights Reserved

Modified: tags/orca/0.27/contrib/procallator/TODO
==============================================================================
--- tags/orca/0.27/contrib/procallator/TODO	(original)
+++ tags/orca/0.27/contrib/procallator/TODO	Mon Jul  4 12:17:53 2005
@@ -3,8 +3,7 @@
 	- Document and optimize collectorn source code
 	- Write better config file for network and NFS stats
 	- Add web server stats
-	- LVM stats
-	- Organize and modularize code
+	- LVM statsi
 
 
 Copyright (C) 2001 Guilherme Carvalho Chehab.  All Rights Reserved

Modified: tags/orca/0.27/contrib/procallator/procallator.pl.in
==============================================================================
--- tags/orca/0.27/contrib/procallator/procallator.pl.in	(original)
+++ tags/orca/0.27/contrib/procallator/procallator.pl.in	Mon Jul  4 12:17:53 2005
@@ -1,55 +1,25 @@
 #!/usr/bin/perl -w
 #
-#	 Performance statistics collector for /proc statistics for use 
-#	 with Linux 2.2, 2.4 & 2.6 kernels.
+#	collector for /proc statistics for use with Linux 2.2 and 2.4 kernels.
 #
-#	 Copyright (C) 2001 Guilherme Carvalho Chehab.
+#	 Copyright (C) 2001 Guilherme Carvalho Chehab.  All Rights Reserved.
 #
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-
 # Config variables
-
+#$PROC="./linux-2.2";		# Proc directory, usually /proc
 $PROC="/proc";			# Proc directory, usually /proc
 $INTERVAL=300;			# Interval between each measure, in seconds
 $COMPRESS="/usr/bin/gzip";	# Compressor...
 $HOSTNAME=`/bin/hostname`;
 chomp $HOSTNAME;
-$DEST_DIR="@VAR_DIR@/procallator/$HOSTNAME";	# Destination dir for output files
-#$DEST_DIR="/tmp";		# Destination dir for output files
-#
-# Output Options
-$NFS_PROTO_DETAILS=0;		# Include per NFS per protocol versions stats on output
+$DEST_DIR="/usr/local/var/orca/$HOSTNAME";	# Destination dir for output files
+#$DEST_DIR="/tmp";	# Destination dir for output files
 
 # Initializations
-$DEBUG=0;
 $r=0;				# Rotating indice for measuring counter differences
 $rate_ok=0;			# Check if is ok to calculate rates
-$num=0;				# Serial number of output file
-$n_cols[0]=0;
-$n_cols[1]=0;
-
-if (!$DEBUG) {
-	use POSIX qw(setsid);
-	umask 0;
-	exit (0) if (fork);
-	setsid;
-}
-	
 
 # Create output dir if needed
-if (! -d $DEST_DIR  && !$DEBUG) {
+if (! -d $DEST_DIR ) {
    `mkdir -p $DEST_DIR`;
 }
 
@@ -58,34 +28,29 @@
 ($os,$line,$version)=split / +/ , <F_VERSION>, 4;
 close (F_VERSION);
 
-print "$os, $line, $version \n"  if ($DEBUG);
-my ($major,$minor,$release) = split /[\.| |-]/, $version;
-
-$INTERVAL=5 if ($DEBUG);
-
 # Main loop
 do {
    # Wait for the next INTERVAL 
-   sleep ($INTERVAL-time() % $INTERVAL) if (!$DEBUG);
-   sleep ($INTERVAL) if ($DEBUG && $rate_ok);
+   sleep ($INTERVAL-time() % $INTERVAL);
 
    # Loop initializations
    $n_cols[$r]=0;
 
-   # Get Local time 
-   $timestamp[$r]=time();
-   ($sec,$min,$hour,$mday,$mon,$year,$yday[$r],$isdst)=localtime($timestamp[$r]);
+   # Get Local time & uptime
+   $timestamp=time();
+   ($sec,$min,$hour,$mday,$mon,$year,$yday,$isdst)=localtime($timestamp);
    $mon+=1;
    $year+=1900;
    $locltime=sprintf "%02d:%02d:%02d", $hour,$min,$sec;
-
-   # Get uptime
    open (F_UPTIME,"<$PROC/uptime");
    ($uptime)=split / +/,<F_UPTIME>;
    close (F_UPTIME);
       
    # insert in output table
-   put_output("timestamp",$timestamp[$r],"locltime",$locltime,"uptime",$uptime);
+   put_output("timestamp",$timestamp,"locltime",$locltime,"uptime",$uptime);
+
+   # Evaluate filename
+   $out_filename[$r]=sprintf "%s/proccol-%04d-%02d-%02d",$DEST_DIR, $year,$mon,$mday;
 
    # Read load average
    open (F_LOADAVG, "<$PROC/loadavg");
@@ -106,15 +71,12 @@
    while ( $line=<F_STAT> ) {
       chomp ($line);
       if ( $line=~/cpu[0-9]*/ ) { 
-         ($cpu[$r][$n_cpus], $usr[$r][$n_cpus], $nice[$r][$n_cpus], $sys[$r][$n_cpus], $idle[$r][$n_cpus], $wait [$r][$n_cpus], $hi [$r][$n_cpus], $si[$r][$n_cpus], $dumb )= split / +/,$line;
-	 ($wait [$r][$n_cpus], $hi [$r][$n_cpus], $si[$r][$n_cpus])= (0,0,0) if (!defined $wait [$r][$n_cpus] );
-	 $total[$r][$n_cpus]= $usr[$r][$n_cpus] + $nice[$r][$n_cpus] + $sys[$r][$n_cpus] + $idle[$r][$n_cpus] + $wait [$r][$n_cpus] + $hi [$r][$n_cpus] + $si[$r][$n_cpus];
-	 $sys[$r][$n_cpus] += $hi [$r][$n_cpus] + $si[$r][$n_cpus];
+         ($cpu[$r][$n_cpus], $usr[$r][$n_cpus], $nice[$r][$n_cpus], $sys[$r][$n_cpus], $idle[$r][$n_cpus])= split / +/,$line;
+	 $total[$r][$n_cpus]= $usr[$r][$n_cpus] + $nice[$r][$n_cpus] + $sys[$r][$n_cpus] + $idle[$r][$n_cpus];
          $n_cpus++;
       }
       if ( $line=~/page/) {
-	 ($dumb, $dsk_rio_t[$r], $dsk_wio_t[$r])= split / +/,$line;  # This is the real mean... Will only use on 2.2 kernels since it is calculated on 2.4 and above
-	 $page_in[$r] = $page_out[$r]=0;  # Ops ! This metric does not appear until kernel 2.6
+	 ($dumb, $page_in[$r], $page_out[$r])= split / +/,$line;
       }
       if ( $line=~/swap/) {
 	 ($dumb, $swap_in[$r], $swap_out[$r])= split / +/,$line;
@@ -122,10 +84,6 @@
       if ( $line=~/ctxt/) {
 	 ($dumb, $ctxt[$r])=  split / +/,$line;
       }
-      if ( $line=~/procs_blocked/) {
-	 ($dumb, $proc_block)=  split / +/,$line;
-	 put_output ( "#proc_blckd", $proc_block);
-      }
       if ( $line=~/intr/) {
 	 @dumb=split / /,$line;
 	 $intr[$r]=0;
@@ -157,13 +115,6 @@
 	    $dsk_rblk_t[$r]+=$dsk_rblk[$r][$i];
 	    $dsk_wio_t[$r] +=$dsk_wio[$r][$i];
 	    $dsk_wblk_t[$r]+=$dsk_wblk[$r][$i];
-	    $dumb="c$dsk_maj[$r][$i]_d$dsk_min[$r][$i]";
-   	    put_output("disk_op_$dumb/s",rate($dsk_stat[$r][$i],$dsk_stat[1-$r][$i]),
-		       "disk_rd_$dumb/s",rate($dsk_rio[$r][$i], $dsk_rio[1-$r][$i]),
-		       "disk_wr_$dumb/s",rate($dsk_wio[$r][$i], $dsk_wio[1-$r][$i]),
-		       "disk_rB_$dumb/s",rate($dsk_rblk[$r][$i],$dsk_rblk[1-$r][$i]),
-		       "disk_wB_$dumb/s",rate($dsk_wblk[$r][$i],$dsk_wblk[1-$r][$i])
-            );
             $i++;
 	 }
       }
@@ -222,9 +173,8 @@
       $nice_100[$i]=rate_prcnt($nice[$r][$i],$nice[1-$r][$i],$total[$r][$i],$total[1-$r][$i]);
       $sys_100 [$i]=rate_prcnt($sys [$r][$i],$sys [1-$r][$i],$total[$r][$i],$total[1-$r][$i]);
       $idle_100[$i]=rate_prcnt($idle[$r][$i],$idle[1-$r][$i],$total[$r][$i],$total[1-$r][$i]);
-      $wait_100[$i]=rate_prcnt($wait[$r][$i],$wait[1-$r][$i],$total[$r][$i],$total[1-$r][$i]);
       if ($i==0) {
-         put_output("ncpus",$n_cpus-1,"usr%",$usr_100 [$i],"nice%",$nice_100[$i],"sys%",$sys_100 [$i],"wait%",$wait_100[$i],"idle%",$idle_100[$i]);
+         put_output("ncpus",$n_cpus-1,"usr%",$usr_100 [$i],"nice%",$nice_100[$i],"sys%",$sys_100 [$i],"wait%",$idle_100[$i]);
       } else {
  	 if ($n_cpus>2) {
             put_output("usr_%_$i",$usr_100 [$i],"nice_%_$i",$nice_100[$i],"sys_%_$i",$sys_100 [$i],"wait_%_$i",$idle_100[$i]);
@@ -232,97 +182,8 @@
       }
    }
 
-   # In kernel 2.6 paging and swapping information must be computed on other file
-   if ( $version=~/^2\.6/ ) {
-   	open (F_VMSTAT, "<$PROC/vmstat");
-	   while ($line=<F_VMSTAT>) {
-		   # Not sure about the meaning of theese
-#		if ( $line=~/pgactivate/) {
-#	               ($dumb, $page_in[$r])= split / +/,$line;
-#		}
-#		if ( $line=~/pgdectivate/) {
-#	               ($dumb, $page_out[$r])= split / +/,$line;
-#		}
-		if ( $line=~/pswpin/) {
-		       ($dumb, $swap_in[$r])= split / +/,$line;
-		}
-		if ( $line=~/pswpout/) {
-		       ($dumb, $swap_out[$r])= split / +/,$line;
-		}
-	   }	
-  	   close (F_VMSTAT);
-   }
-
-   # Now lets get 2.4 /proc/partitions and 2.5 /proc/diskstats for acurate disk measurements
-   #
-   if ( $minor >=4 ) {
-           ($dsk_stat_t[$r],$dsk_rio_t[$r],$dsk_rblk_t[$r],$dsk_wio_t[$r],$dsk_wblk_t[$r])=(0,0,0,0);
-	   open (F_DSKSTAT, "<$PROC/partitions") if ($minor==4);
-	   open (F_DSKSTAT, "<$PROC/diskstats") if ($minor>4);
-
-	   $i=0;
-	   while ($line=<F_DSKSTAT>) {
-		   if ( $line =~ /sd|hd/ ) {  # just IDE or SCSI disks
-			   chomp $line;
-			   $line= " 0 ".$line if ($minor==6); # make 2.6 version look alike a 2.4 one
-			   ($dumb,$dumb,$dumb,$dumb,
-			   $name[$r][$i],
-			   $rdops[$r][$i],$rdops_seq[$r][$i],
-			   $rdsct[$r][$i],$rdtm[$r][$i],
-			   $wrops[$r][$i],$wrops_seq[$r][$i],
-			   $wrsct[$r][$i],$wrtm[$r][$i],
-			   $ioqueue[$r][$i],$iotm[$r][$i],$weightiotm[$r][$i]) = split / +/,$line;
-			   if ($name[$r][$i] !~ /[0-9]/ ) {
-				   $dsk_rio_t[$r]+=$rdops[$r][$i];
-				   $dsk_wio_t[$r]+=$wrops[$r][$i];
-				   $dsk_rblk_t[$r]+=$rdsct[$r][$i];
-				   $dsk_wblk_t[$r]+=$wrsct[$r][$i];
-   	    		   	   put_output(
-	  			       "disk_rd_$name[$r][$i]/s",rate($rdops[$r][$i],$rdops[1-$r][$i]),
-				       "disk_wr_$name[$r][$i]/s",rate($wrops[$r][$i],$wrops[1-$r][$i]),
-				       "disk_rB_$name[$r][$i]/s",rate($rdsct[$r][$i],$rdsct[1-$r][$i]),
-		       		       "disk_wB_$name[$r][$i]/s",rate($wrsct[$r][$i],$wrsct[1-$r][$i]),
-	  			       "disk_rdseq_$name[$r][$i]/s",rate($rdops_seq[$r][$i],$rdops_seq[1-$r][$i]),
-	  			       "disk_wrseq_$name[$r][$i]/s",rate($wrops_seq[$r][$i],$ops_seq[1-$r][$i]),
-				       "disk_rtm_$name[$r][$i]/s",rate($rdtm[$r][$i],$rdtm[1-$r][$i]),
-				       "disk_wtm_$name[$r][$i]/s",rate($wrtm[$r][$i],$wrtm[1-$r][$i]),
-				       "disk_iotm_$name[$r][$i]/s",rate($iotm[$r][$i],$iotm[1-$r][$i]),
-				       "disk_ioqueue_$name[$r][$i]/s",rate($ioqueue[$r][$i],$ioqueue[1-$r][$i]),
-				       "disk_weightiotm_$name[$r][$i]/s",rate($weightiotm[$r][$i],$weightiotm[1-$r][$i]),
-				   );
-			   } else {
-   		    		   put_output(	 # 2.6 has less metrics, wich  messes vars names
-  				       "part_rd_$name[$r][$i]/s",rate($rdops[$r][$i],$rdops[1-$r][$i]),
-				       "part_wr_$name[$r][$i]/s",rate($rdsct[$r][$i],$rdsct[1-$r][$i]),
-			       	       "part_rB_$name[$r][$i]/s",rate($rdops_seq[$r][$i],$rdops_seq[1-$r][$i]),
-			       	       "part_wB_$name[$r][$i]/s",rate($rdtm[$r][$i],$rdtm[1-$r][$i])
-				   ) if ($minor==6);
-   	    		   	   put_output(
-	  			       "part_rd_$name[$r][$i]/s",rate($rdops[$r][$i],$rdops[1-$r][$i]),
-				       "part_wr_$name[$r][$i]/s",rate($wrops[$r][$i],$wrops[1-$r][$i]),
-				       "part_rB_$name[$r][$i]/s",rate($rdsct[$r][$i],$rdsct[1-$r][$i]),
-		       		       "part_wB_$name[$r][$i]/s",rate($wrsct[$r][$i],$wrsct[1-$r][$i]),
-	  			       "part_rdseq_$name[$r][$i]/s",rate($rdops_seq[$r][$i],$rdops_seq[1-$r][$i]),
-	  			       "part_wrseq_$name[$r][$i]/s",rate($wrops_seq[$r][$i],$ops_seq[1-$r][$i]),
-				       "part_rtm_$name[$r][$i]/s",rate($rdtm[$r][$i],$rdtm[1-$r][$i]),
-				       "part_wtm_$name[$r][$i]/s",rate($wrtm[$r][$i],$wrtm[1-$r][$i]),
-				       "disk_iotm_$name[$r][$i]/s",rate($iotm[$r][$i],$iotm[1-$r][$i]),
-				       "part_ioqueue_$name[$r][$i]/s",rate($ioqueue[$r][$i],$ioqueue[1-$r][$i]),
-				       "part_weightiotm_$name[$r][$i]/s",rate($weightiotm[$r][$i],$weightiotm[1-$r][$i]),
-				   ) if ($minor==4);
-			   }
-		   	   $i++;
-		   }
-	   }
-	   #$n_parts=$i;
-	   $dsk_stat_t[$r]= $dsk_rio_t[$r]+$dsk_wio_t[$r];
-	   close (F_DSKSTAT);
-   }
-
-			  
-	   
-   put_output ( "mempages_in",rate(@page_in),
-		"mempages_out",rate(@page_out),
+   put_output ( "pages_in",rate(@page_in),
+		"pages_out",rate(@page_out),
 		"swap_in",rate(@swap_in),
 		"swap_out",rate(@swap_out),
 		"ctxt/s",rate(@ctxt),
@@ -336,48 +197,38 @@
 		"disk_wB/s",rate(@dsk_wblk_t)
    );
 
+   if ( $version=~/^2\.4/ ) {
+      for ($i=0; $i<$n_dsk; $i++) {
+	 $dumb="c$dsk_maj[$r][$i]_d$dsk_min[$r][$i]";
+	 put_output("disk_op_$dumb/s",rate($dsk_stat[$r][$i],$dsk_stat[1-$r][$i]),
+		    "disk_rd_$dumb/s",rate($dsk_rio[$r][$i], $dsk_rio[1-$r][$i]),
+		    "disk_wr_$dumb/s",rate($dsk_wio[$r][$i], $dsk_wio[1-$r][$i]),
+		    "disk_rB_$dumb/s",rate($dsk_rblk[$r][$i],$dsk_rblk[1-$r][$i]),
+		    "disk_wB_$dumb/s",rate($dsk_wblk[$r][$i],$dsk_wblk[1-$r][$i])
+         );
+      }
+   }
    close (F_STAT);
 
+   # Get filesystem ocupation
+   @df=`/bin/df -k`;
+   for ($i=1,$j=0;$df[$i];$i++)  {
+      if (!(($df[$i]=~/cdrom/)||($df[$i]=~/cdrom/))) {
+	 chomp $df[$i];
+	 ($dumb, $fs[2][$j], $fs[3][$j], $dumb, $dumb, $fs[0][$j])= split / +/,$df[$i];
+	 $fs[1][$j]=prcnt($fs[3][$j],$fs[2][$j]);
+	 put_output("mnt_$fs[0][$j]",$fs[1][$j]);
+	 $j++;
+      }
+   }
+   $n_fs=$j;
 
    # Get memory ocupation
    open (F_MEMINFO, "<$PROC/meminfo");
-   if ( $version!~/^2\.6/ ) {
-	   <F_MEMINFO>;
-	   ($dumb, $mem_total,$mem_used,$mem_free,$mem_shrd,$mem_buff,$mem_cchd)=split /[^0-9]+/,<F_MEMINFO>;
-	   ($dumb, $swp_total,$swp_used,$swp_free)=split /[^0-9]+/,<F_MEMINFO>;
-   } else {
-	   while ($line=<F_MEMINFO>) {
-                if ( $line=~/MemTotal/) {
-                	($dumb, $mem_total)= split / +/,$line;
-	        }
-                if ( $line=~/MemFree/) {
-                	($dumb, $mem_free)= split / +/,$line;
-	        }
-                if ( $line=~/Buffers/) {
-                	($dumb, $mem_buff)= split / +/,$line;
-	        }
-                if ( $line=~/Cached/) {
-                	($dumb, $mem_cchd)= split / +/,$line;
-	        }
-                if ( $line=~/Shared/) {
-                	($dumb, $mem_shrd)= split / +/,$line;  # It does not exist anymore -- maybe get will have to get from /proc/sysvipc/shm ?
-	        }
-		#if ( $line=~/SwapCached/) {
-		#	($dumb, $mem_swpcchd)= split / +/,$line;
-		#}
-                if ( $line=~/SwapTotal/) {
-                	($dumb, $swp_total)= split / +/,$line;
-	        }
-                if ( $line=~/SwapFree/) {
-                	($dumb, $swp_free)= split / +/,$line;
-	        }
-	  }
-	  $mem_used=$mem_total-$mem_free;
-	  $swp_used=$swp_total-$swp_free;
-   }
-
+   <F_MEMINFO>;
+   ($dumb, $mem_total,$mem_used,$mem_free,$mem_shrd,$mem_buff,$mem_cchd)=split /[^0-9]+/,<F_MEMINFO>;
+   ($dumb, $swp_total,$swp_used,$swp_free)=split /[^0-9]+/,<F_MEMINFO>;
    close (F_MEMINFO);
-
    put_output ( "mem_used%",prcnt($mem_used,$mem_total),
    		"mem_free%",prcnt($mem_free,$mem_total),
 		"mem_shrd%",prcnt($mem_shrd,$mem_total),
@@ -425,24 +276,9 @@
       }
    }
    $n_nets=$i;
-   close (F_NET_DEV);
 
    # Get TCP/IP statistics
-   #
-   for (my $k=0; $k<2; $k++) {
-      
-	   if ($k==1) {
-   	      if ($minor>=4) {
-		      open (F_SNMP, "<$PROC/net/netstat");
-	      } else {
-		      next;
-	      }
-	      
-      } else {
-	      open (F_SNMP, "<$PROC/net/snmp");
-      }
-	     
-   
+   open (F_SNMP, "<$PROC/net/snmp");
    $j=0;
    while ($line=<F_SNMP>) {
       $line2=<F_SNMP>;
@@ -474,7 +310,7 @@
 	    if ($cat=~/Tcp/) {
 	       if ($net_parm[0][$j]=~/Rto|Max/) { last SWITCH; }
 	       if ($net_parm[0][$j]=~/CurrEstab/) {
-	  	  put_output("$net_parm[0][$j]",$net_parm[2+$r][$j]); 
+	  	  put_output("g$net_parm[0][$j]",$net_parm[2+$r][$j]); 
 	          last SWITCH;
                }
                put_output("$net_parm[0][$j]",$net_parm[1][$j]);
@@ -483,9 +319,7 @@
 	 }
       }
    }
-   close (F_SNMP);
    $net_parms=$j;
-   }
 
    # Get NFS Client statistics
    if ( -f "$PROC/net/rpc/nfs") {
@@ -525,7 +359,7 @@
 			"nfs_c_p2_rmdir",	rate(@nfs_c_p2_rmdir),
 			"nfs_c_p2_readdir",	rate(@nfs_c_p2_readdir),
 			"nfs_c_p2_fsstat",	rate(@nfs_c_p2_fsstat)
-            ) if ($NFS_PROTO_DETAILS);
+            );
 	 }
 	 if ($line=~/proc3/) {
             ( $dumb,$dumb,$dumb,	$nfs_c_p3_getattr[$r],	$nfs_c_p3_setattr[$r],	$nfs_c_p3_lookup[$r],
@@ -557,68 +391,11 @@
                         "nfs_c_p3_fsinfo",	rate(@nfs_c_p3_fsinfo),
                         "nfs_c_p3_pathconf",	rate(@nfs_c_p3_pathconf),
                         "nfs_c_p3_commit",	rate(@nfs_c_p3_commit)
-            ) if ($NFS_PROTO_DETAILS);
-         }
-	 if ($line=~/proc4/) {
-            ( $dumb,$dumb,$dumb,	$nfs_c_p4_getattr[$r],	$nfs_c_p4_setattr[$r],	$nfs_c_p4_lookup[$r],
-              $nfs_c_p4_access[$r],	$nfs_c_p4_readlink[$r],	$nfs_c_p4_read[$r],	$nfs_c_p4_write[$r],
-              $nfs_c_p4_create[$r],	$nfs_c_p4_mkdir[$r],	$nfs_c_p4_symlink[$r],	$nfs_c_p4_mknod[$r],
-              $nfs_c_p4_remove[$r],	$nfs_c_p4_rmdir[$r],	$nfs_c_p4_rename[$r],	$nfs_c_p4_link[$r],
-              $nfs_c_p4_readdir[$r],	$nfs_c_p4_readdirplus[$r],$nfs_c_p4_fsstat[$r],	$nfs_c_p4_fsinfo[$r],
-	      $nfs_c_p4_pathconf[$r],	$nfs_c_p4_commit[$r]
-            )=split / +/,$line;
-	    
-            put_output( "nfs_c_p4_getattr",	rate(@nfs_c_p4_getattr),
-                        "nfs_c_p4_setattr",	rate(@nfs_c_p4_setattr),
-                        "nfs_c_p4_lookup",	rate(@nfs_c_p4_lookup),
-                        "nfs_c_p4_access",	rate(@nfs_c_p4_access),
-                        "nfs_c_p4_readlink",	rate(@nfs_c_p4_readlink),
-                        "nfs_c_p4_read",	rate(@nfs_c_p4_read),
-                        "nfs_c_p4_write",	rate(@nfs_c_p4_write),
-                        "nfs_c_p4_create",	rate(@nfs_c_p4_create),
-                        "nfs_c_p4_mkdir",	rate(@nfs_c_p4_mkdir),
-                        "nfs_c_p4_symlink",	rate(@nfs_c_p4_symlink),
-                        "nfs_c_p4_mknod",	rate(@nfs_c_p4_mknod),
-                        "nfs_c_p4_remove",	rate(@nfs_c_p4_remove),
-                        "nfs_c_p4_rmdir",	rate(@nfs_c_p4_rmdir),
-                        "nfs_c_p4_rename",	rate(@nfs_c_p4_rename),
-                        "nfs_c_p4_link",	rate(@nfs_c_p4_link),
-                        "nfs_c_p4_readdir",	rate(@nfs_c_p4_readdir),
-                        "nfs_c_p4_readdirplus",	rate(@nfs_c_p4_readdirplus),
-                        "nfs_c_p4_fsstat",	rate(@nfs_c_p4_fsstat),
-                        "nfs_c_p4_fsinfo",	rate(@nfs_c_p4_fsinfo),
-                        "nfs_c_p4_pathconf",	rate(@nfs_c_p4_pathconf),
-                        "nfs_c_p4_commit",	rate(@nfs_c_p4_commit)
-            ) if ($NFS_PROTO_DETAILS);
+            );
          }
       }
-      close (F_NFS);
-      
-      put_output( "nfs_c_t_getattr",	rate(@nfs_c_p2_getattr) +rate(@nfs_c_p3_getattr)	+rate(@nfs_c_p4_getattr),
-                  "nfs_c_t_setattr",	rate(@nfs_c_p2_setattr)	+rate(@nfs_c_p3_setattr)	+rate(@nfs_c_p4_setattr),
-                  "nfs_c_t_lookup",	rate(@nfs_c_p2_lookup)	+rate(@nfs_c_p3_lookup)		+rate(@nfs_c_p4_lookup),
-                  "nfs_c_t_access",				 rate(@nfs_c_p3_access)		+rate(@nfs_c_p4_access),
-                  "nfs_c_t_readlink",	rate(@nfs_c_p2_readlink)+rate(@nfs_c_p3_readlink)	+rate(@nfs_c_p4_readlink),
-                  "nfs_c_t_read",	rate(@nfs_c_p2_read)	+rate(@nfs_c_p3_read)		+rate(@nfs_c_p4_read),
-                  "nfs_c_t_write",	rate(@nfs_c_p2_write)	+rate(@nfs_c_p3_write)		+rate(@nfs_c_p4_write),
-                  "nfs_c_t_create",	rate(@nfs_c_p2_create)	+rate(@nfs_c_p3_create)		+rate(@nfs_c_p4_create),
-                  "nfs_c_t_mkdir",	rate(@nfs_c_p2_mkdir)	+rate(@nfs_c_p3_mkdir)		+rate(@nfs_c_p4_mkdir),
-                  "nfs_c_t_symlink",	rate(@nfs_c_p2_symlink)	+rate(@nfs_c_p3_symlink)	+rate(@nfs_c_p4_symlink),
-                  "nfs_c_t_mknod",				 rate(@nfs_c_p3_mknod)		+rate(@nfs_c_p4_mknod),
-                  "nfs_c_t_remove",	rate(@nfs_c_p2_remove)	+rate(@nfs_c_p3_remove)		+rate(@nfs_c_p4_remove),
-                  "nfs_c_t_rmdir",	rate(@nfs_c_p2_rmdir)	+rate(@nfs_c_p3_rmdir)		+rate(@nfs_c_p4_rmdir),
-                  "nfs_c_t_rename",	rate(@nfs_c_p2_rename)	+rate(@nfs_c_p3_rename)		+rate(@nfs_c_p4_rename),
-                  "nfs_c_t_link",	rate(@nfs_c_p2_link)	+rate(@nfs_c_p3_link)		+rate(@nfs_c_p4_link),
-                  "nfs_c_t_readdir",	rate(@nfs_c_p2_readdir)	+rate(@nfs_c_p3_readdir)	+rate(@nfs_c_p4_readdir),
-                  "nfs_c_t_readdirplus",			 rate(@nfs_c_p3_readdirplus)	+rate(@nfs_c_p4_readdirplus),
-                  "nfs_c_t_fsstat",	rate(@nfs_c_p2_fsstat)	+rate(@nfs_c_p3_fsstat)		+rate(@nfs_c_p4_fsstat),
-                  "nfs_c_t_fsinfo",				 rate(@nfs_c_p3_fsinfo)		+rate(@nfs_c_p4_fsinfo),
-                  "nfs_c_t_pathconf",				 rate(@nfs_c_p3_pathconf)	+rate(@nfs_c_p4_pathconf),
-                  "nfs_c_t_commit",				 rate(@nfs_c_p3_commit)		+rate(@nfs_c_p4_commit)
-      );
    }
 
-
    # Get NFS Server statistics
    if ( -f "$PROC/net/rpc/nfsd") {
       open (F_NFS, "<$PROC/net/rpc/nfsd");
@@ -661,7 +438,7 @@
 			"nfs_s_p2_rmdir",	rate(@nfs_s_p2_rmdir),
 			"nfs_s_p2_readdir",	rate(@nfs_s_p2_readdir),
 			"nfs_s_p2_fsstat",	rate(@nfs_s_p2_fsstat)
-            ) if ($NFS_PROTO_DETAILS);
+            );
 	 }
 	 if ($line=~/proc3/) {
             ( $dumb,$dumb,$dumb,	$nfs_s_p3_getattr[$r],	$nfs_s_p3_setattr[$r],	$nfs_s_p3_lookup[$r],
@@ -693,83 +470,19 @@
                         "nfs_s_p3_fsinfo",	rate(@nfs_s_p3_fsinfo),
                         "nfs_s_p3_pathconf",	rate(@nfs_s_p3_pathconf),
                         "nfs_s_p3_commit",	rate(@nfs_s_p3_commit)
-            ) if ($NFS_PROTO_DETAILS);
+            );
          }
-	 if ($line=~/proc4/) {
-            ( $dumb,$dumb,$dumb,	
-	      $nfs_s_p4_compound[$r]
-            )=split / +/,$line;
-
-            put_output( "nfs_s_p4_compound",	rate(@nfs_s_p4_compound)
-            ) if ($NFS_PROTO_DETAILS);
-          }
-      }
-      close (F_NFS);
-      put_output( "nfs_s_t_getattr",	rate(@nfs_s_p2_getattr) +rate(@nfs_s_p3_getattr),
-                  "nfs_s_t_setattr",	rate(@nfs_s_p2_setattr)	+rate(@nfs_s_p3_setattr),
-                  "nfs_s_t_lookup",	rate(@nfs_s_p2_lookup)	+rate(@nfs_s_p3_lookup)	,
-                  "nfs_s_t_access",				 rate(@nfs_s_p3_access)	,
-                  "nfs_s_t_readlink",	rate(@nfs_s_p2_readlink)+rate(@nfs_s_p3_readlink),
-                  "nfs_s_t_read",	rate(@nfs_s_p2_read)	+rate(@nfs_s_p3_read)	,
-                  "nfs_s_t_write",	rate(@nfs_s_p2_write)	+rate(@nfs_s_p3_write)	,
-                  "nfs_s_t_create",	rate(@nfs_s_p2_create)	+rate(@nfs_s_p3_create)	,
-                  "nfs_s_t_mkdir",	rate(@nfs_s_p2_mkdir)	+rate(@nfs_s_p3_mkdir)	,
-                  "nfs_s_t_symlink",	rate(@nfs_s_p2_symlink)	+rate(@nfs_s_p3_symlink),
-                  "nfs_s_t_mknod",				 rate(@nfs_s_p3_mknod)	,
-                  "nfs_s_t_remove",	rate(@nfs_s_p2_remove)	+rate(@nfs_s_p3_remove)	,
-                  "nfs_s_t_rmdir",	rate(@nfs_s_p2_rmdir)	+rate(@nfs_s_p3_rmdir)	,
-                  "nfs_s_t_rename",	rate(@nfs_s_p2_rename)	+rate(@nfs_s_p3_rename)	,
-                  "nfs_s_t_link",	rate(@nfs_s_p2_link)	+rate(@nfs_s_p3_link)	,
-                  "nfs_s_t_readdir",	rate(@nfs_s_p2_readdir)	+rate(@nfs_s_p3_readdir),
-                  "nfs_s_t_readdirplus",			 rate(@nfs_s_p3_readdirplus),
-                  "nfs_s_t_fsstat",	rate(@nfs_s_p2_fsstat)	+rate(@nfs_s_p3_fsstat)	,
-                  "nfs_s_t_fsinfo",				 rate(@nfs_s_p3_fsinfo)	,
-                  "nfs_s_t_pathconf",				 rate(@nfs_s_p3_pathconf),
-                  "nfs_s_t_commit",				 rate(@nfs_s_p3_commit)	,
-                  "nfs_s_t_compound",								 rate(@nfs_s_p4_compound)
-      );
-   }
-
-   # Get filesystem ocupation
-   @df=`/bin/df -klP`;
-   for ($i=1,$j=0;$df[$i];$i++)  {
-      if (!(($df[$i]=~/cdrom/)||($df[$i]=~/cdrom/))) {
-	 chomp $df[$i];
-	 ($dumb, $fs[2][$j], $fs[3][$j], $dumb, $dumb, $fs[0][$j])= split / +/,$df[$i];
-	 $fs[1][$j]=prcnt($fs[3][$j],$fs[2][$j]);
-	 put_output("mnt_$fs[0][$j]",$fs[1][$j]);
-	 $j++;
       }
    }
-   $n_fs=$j;
-   # Check if number of columns have changed
-   if ( $n_cols[$r] != $n_cols[1-$r] ) {
-     $num++;
-   }
-
-   # If year day has changed and is not first execution: zero output seq.
-   if (($rate_ok) && ( $yday[$r] != $yday[1-$r] )) {
-     $num=0;
-   }
 
-   # Evaluate filename
-   $out_filename[$r]=sprintf "%s/proccol-%04d-%02d-%02d-%03d",$DEST_DIR, $year,$mon,$mday,$num;
 
-   # on first execution check file existence
-   if (!$rate_ok) {
-     while ( -f $out_filename[$r] ) {
-       $num++;
-       $out_filename[$r]=sprintf "%s/proccol-%04d-%02d-%02d-%03d",$DEST_DIR, $year,$mon,$mday,$num;
-     }
-   }
- 
-   # flush output if not in Debug mode
-   flush_output() if (!$DEBUG);
+   # flush output
+   flush_output();
 
    $r=1-$r;
    $rate_ok=1;
 
-} while (!$DEBUG || $r);  # If in debug mode does only 2 iteractions
+} while (1);
 
 # to perl dont complain on unused vars
 ($os,$n_fs,$net_parms,$n_nets,$cpu,$yday,$isdst)=($os,$n_fs,$net_parms,$n_nets,$cpu,$yday,$isdst);
@@ -777,19 +490,12 @@
 sub rate {
    my ($a,$b) = @_;
    my $c;
-   my $d=$INTERVAL; #1; # abs($timestamp[$r]-$timestamp[1-$r]);
-   if (!defined $a || $a eq "") {$a=0} ; 
-   if (!defined $b || $b eq "") {$b=0} ; 
-
-   $c= ($rate_ok==1) ? ( ( (abs($a-$b)%$d) ==0 ) ? abs($a-$b) / $d : sprintf("%.3f",abs ($a-$b) / $d) ) : 0;
-
+   $c= (!($a&&$b))?0:((abs($a-$b)%$INTERVAL)==0)?abs($a-$b)/$INTERVAL:sprintf("%.3f",abs($a-$b)/$INTERVAL);
    return $c;
 }
 
 sub prcnt {
    my ($a,$b) = @_;
-   if (!defined $a || $a eq "") {$a=0} ; 
-   if (!defined $b || $b eq "") {$b=0} ; 
    return ($b==0) ? 0 : sprintf ("%.2f",100 * $a / $b);
 }
 
@@ -840,8 +546,5 @@
    for ($t=0;$a[$t];$t+=2,$n_cols[$r]+=1) {
       $out [0][$n_cols[$r]]=$a[$t];
       $out [1][$n_cols[$r]]=$a[$t+1];
-      if ($DEBUG) { 
-	 print $out[0][$n_cols[$r]].": ".$out [1][$n_cols[$r]]."\n";
-      }
    }
 }



More information about the Orca-checkins mailing list