ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/generic/statgrab.pl
(Generate patch)

Comparing projects/cms/source/host/generic/statgrab.pl (file contents):
Revision 1.40 by tdb, Mon Mar 19 23:05:55 2001 UTC vs.
Revision 1.46 by tdb, Wed Nov 14 15:18:25 2001 UTC

# Line 38 | Line 38 | if ($ostype eq "SunOS") {
38   }
39   elsif ($ostype eq "Linux") {
40      # covers: Debian r2.2
41 <    $topbin = "/usr/bin/top -d1 -n0 -b";
41 >    $topbin = "/usr/bin/top -d1 -n2 -b -p0";
42      $dfbin = "/bin/df";
43      $usersbin = "/usr/bin/users";
44      $unamebin = "/bin/uname";
# Line 78 | Line 78 | exit(0);
78   # the host should check this when reading data
79   # means the host must be checked and updated to work with newer versions.
80   sub print_ident() {
81 <    print 'version statgrab.pl $Revision$';
81 >    print 'packet.version statgrab.pl $Revision$';
82      print "\n";
83   }
84  
# Line 105 | Line 105 | sub print_pair($$$) {
105   sub include_disk() {
106      
107      # Run the df program.
108 <    my(@df) = `$dfbin -ak`;
108 >    my(@df) = `$dfbin -akl`;
109  
110      # Go through each line of the program, looking for each thing we want.
111      my($partition_no) = 0;
# Line 150 | Line 150 | sub include_top() {
150      # Find out some numbers from top.
151      my(@top) = `$topbin`;
152      my($top) = join(" ", @top);
153 <    $top =~ s/\n//g;
153 >    $top =~ s/\n/ /g;
154  
155      if($ostype eq "SunOS") {
156          &print_pair(0, "packet.processes.total", $top =~ /([0-9]+?) processes:/);
# Line 191 | Line 191 | sub include_top() {
191          $swap_free/=1024 if $2 eq "K";
192          &print_pair(0, "packet.swap.free", $swap_free);
193          
194        # AJ requested total swap instead of swap_in_use, so here we go!
194          &print_pair(0, "packet.swap.total", $swap_free + $swap_in_use);
195      }
196      elsif ($ostype eq "FreeBSD") {
# Line 244 | Line 243 | sub include_top() {
243          &print_pair(0, "packet.load.load15", $3);
244      }
245      elsif ($ostype eq "Linux") {
246 +        my ($top) = "";
247 +        foreach my $line (@top) {
248 +            $top = $line . $top;
249 +        }
250 +        $top =~ s/\n/ /g;
251 +
252          &print_pair(0, "packet.processes.total", $top =~ /([0-9]+?) processes:/);
253          &print_pair(0, "packet.processes.sleeping", $top =~ /([0-9]+?) sleeping/);
254          &print_pair(0, "packet.processes.zombie", $top =~ /([0-9]+?) zombie/);
255          &print_pair(0, "packet.processes.stopped", $top =~ /([0-9]+?) stopped/);
256          &print_pair(0, "packet.processes.cpu", $top =~ /([0-9]+?)\s*running/);
257          &print_pair(0, "packet.cpu.idle", $top =~ /([^\s]+?)% idle/);
253        &print_pair(0, "packet.cpu.user", $top =~ /([^\s]+?)% user/);
258          &print_pair(0, "packet.cpu.kernel", $top =~ /([^\s]+?)% system/);
259          &print_pair(0, "packet.cpu.iowait", $top =~ /([^\s]+?)% interrupt/);
260          &print_pair(0, "packet.cpu.swap", $top =~ /([^\s]+?)% swap/);
261 +
262 +        # FreeBSD is a bit different, we need to get user and nice.
263 +        my($user) = 0;
264 +        if($top =~ /([^\s]+?)% user/) { $user += $1; }
265 +        if($top =~ /([^\s]+?)% nice/) { $user += $1; }
266 +        &print_pair(0, "packet.cpu.user", $user);
267          
268          # The following need to be specified in megabytes.
269          # If they are preceeded by a G, then multiply by 1024.  
270          
271 <        $top =~ / ([0-9]+?)([KMG]) av/;
271 >        $top =~ /Mem:.*?([0-9]+)([KMG])\s+(av|total)/;
272          my($real) = $1;
273          $real*=1024 if $2 eq "G";
274          $real/=1024 if $2 eq "K";
275          &print_pair(0, "packet.memory.total", int($real));
276          
277 <        $top =~ / ([0-9]+?)([KMG]) free/;
277 >        $top =~ /Mem:.*?([0-9]+)([KMG])\s+free/;
278          my($free) = $1;
279          $free*=1024 if $2 eq "G";
280          $free/=1024 if $2 eq "K";
281          &print_pair(0, "packet.memory.free", int($free));
282          
283 <        $top =~ /Swap:\s+([0-9]]+?)([KMG]) av/;
283 >        $top =~ /Swap:.*?([0-9]+)([KMG])\s+(av|total)/;
284          my($swap_total) = $1;
285          $swap_total*=1024 if $2 eq "G";
286          $swap_total/=1024 if $2 eq "K";
287          &print_pair(0, "packet.swap.total", int($swap_total));
288          
289 <        $top =~ /Swap:.*, ([0-9]+?)([KMG]) free/;
289 >        $top =~ /Swap:.*?([0-9]+)([KMG])\s+free/;
290          my($swap_free) = $1;
291          $swap_free*=1024 if $2 eq "G";
292          $swap_free/=1024 if $2 eq "K";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines