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.6 by tdb, Tue May 21 16:47:12 2002 UTC

# Line 1 | Line 1
1   #!/usr/bin/perl -w
2  
3 + #
4 + # i-scream central monitoring system
5 + # http://www.i-scream.org.uk
6 + # Copyright (C) 2000-2002 i-scream
7 + #
8 + # This program is free software; you can redistribute it and/or
9 + # modify it under the terms of the GNU General Public License
10 + # as published by the Free Software Foundation; either version 2
11 + # of the License, or (at your option) any later version.
12 + #
13 + # This program is distributed in the hope that it will be useful,
14 + # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 + # GNU General Public License for more details.
17 + #
18 + # You should have received a copy of the GNU General Public License
19 + # along with this program; if not, write to the Free Software
20 + # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21 + #
22 +
23   #-----------------------------------------------------------------
24   # i-scream host plugin - top parsing (cpu, proc, mem, & swap)
25   #     $Author$
# Line 18 | Line 38 | $| = 1;
38   # You'd be silly not to use this ;)
39   use strict;
40  
41 < # Have to hope this will work really.
42 < my($ostype) = `uname -s`; chomp($ostype);
41 > # Get the OS type from the args, or try towork it out
42 > my($ostype) = $ARGV[0];
43 > $ostype = `uname -s` if not defined $ostype;
44 > chomp($ostype);
45  
46   # Decide which paths we should use.
47   my($topbin);
# Line 30 | Line 52 | if ($ostype eq "SunOS") {
52   }
53   elsif ($ostype eq "Linux") {
54      # covers: Debian r2.2
55 <    $topbin = "/usr/bin/top -d1 -n2 -b -p0";
55 >    $topbin = "/usr/bin/top -d1 -n2 -b";
56   }
57   elsif ($ostype eq "FreeBSD") {
58      # covers: FreeBSD 4.X
# Line 45 | Line 67 | else {
67   }
68  
69   # Run the following components: -
48 &print_ident();
70   &include_top();
71  
72   # End the program normally.
# Line 54 | Line 75 | exit(0);
75  
76  
77  
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
78   # sub to print pairs of data, separated by a single space character.
79   # If the second argument is undefined, then the pair is still printed,
80   # however, the value shall be displayed as the the 'default' value
# Line 152 | Line 166 | sub include_top() {
166          
167          # get RAM slightly differently
168          my($real) = `$sysctlbin -n hw.physmem`;
169 <        my($free) = $real - `$sysctlbin -n hw.usermem`;
169 >        my($v_free_count) = `$sysctlbin -n vm.stats.vm.v_free_count`;
170 >        my($v_page_size) = `$sysctlbin -n vm.stats.vm.v_page_size`;
171 >        my($free) = $v_free_count * $v_page_size;
172          
173          # turn bytes to megabytes
174          $real = ($real / 1024) / 1024;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines