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

Comparing projects/cms/source/host/ihost-perl/plugins/perl/i-scream_top.pl (file contents):
Revision 1.1 by tdb, Mon Nov 19 21:42:11 2001 UTC vs.
Revision 1.4 by tdb, Wed Mar 6 21:23:49 2002 UTC

# Line 18 | Line 18 | $| = 1;
18   # You'd be silly not to use this ;)
19   use strict;
20  
21 < # Have to hope this will work really.
22 < my($ostype) = `uname -s`; chomp($ostype);
21 > # Get the OS type from the args, or try towork it out
22 > my($ostype) = $ARGV[0];
23 > $ostype = `uname -s` if not defined $ostype;
24 > chomp($ostype);
25  
26   # Decide which paths we should use.
27   my($topbin);
# Line 30 | Line 32 | if ($ostype eq "SunOS") {
32   }
33   elsif ($ostype eq "Linux") {
34      # covers: Debian r2.2
35 <    $topbin = "/usr/bin/top -d1 -n2 -b -p0";
35 >    $topbin = "/usr/bin/top -d1 -n2 -b";
36   }
37   elsif ($ostype eq "FreeBSD") {
38      # covers: FreeBSD 4.X
# Line 45 | Line 47 | else {
47   }
48  
49   # Run the following components: -
48 &print_ident();
50   &include_top();
51  
52   # End the program normally.
# Line 54 | Line 55 | exit(0);
55  
56  
57  
57 # prints out an identifier for this version of the script
58 # this could be used in checks further downstream
59 sub print_ident() {
60    print 'packet.plugins.ident.i-scream_top i-scream_top.pl $Revision$';
61    print "\n";
62 }
63
58   # sub to print pairs of data, separated by a single space character.
59   # If the second argument is undefined, then the pair is still printed,
60   # however, the value shall be displayed as the the 'default' value
# Line 152 | Line 146 | sub include_top() {
146          
147          # get RAM slightly differently
148          my($real) = `$sysctlbin -n hw.physmem`;
149 <        my($free) = $real - `$sysctlbin -n hw.usermem`;
149 >        my($v_free_count) = `$sysctlbin -n vm.stats.vm.v_free_count`;
150 >        my($v_page_size) = `$sysctlbin -n vm.stats.vm.v_page_size`;
151 >        my($free) = $v_free_count * $v_page_size;
152          
153          # turn bytes to megabytes
154          $real = ($real / 1024) / 1024;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines