| 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); |
| 47 |
|
} |
| 48 |
|
|
| 49 |
|
# Run the following components: - |
| 48 |
– |
&print_ident(); |
| 50 |
|
&include_top(); |
| 51 |
|
|
| 52 |
|
# End the program normally. |
| 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 |
| 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; |