| 21 |
|
# You'd be silly not to use this ;) |
| 22 |
|
use strict; |
| 23 |
|
|
| 24 |
< |
# Paths |
| 25 |
< |
my($topbin) = "/usr/local/sbin/top"; |
| 26 |
< |
my($dfbin) = "/usr/bin/df"; |
| 27 |
< |
my($usersbin) = "/usr/ucb/users"; |
| 28 |
< |
my($unamebin) = "/usr/bin/uname"; |
| 29 |
< |
my($uptimebin) = "/usr/bin/uptime"; |
| 24 |
> |
# Have to hope this will work really. |
| 25 |
> |
my($ostype) = `uname -s`; chop($ostype); |
| 26 |
|
|
| 27 |
+ |
# Decide which paths we should use. |
| 28 |
+ |
my($topbin); my($dfbin); my($usersbin); my($unamebin); my($uptimebin); |
| 29 |
+ |
|
| 30 |
+ |
if ($ostype eq "SunOS") { |
| 31 |
+ |
# covers: Solaris 8 |
| 32 |
+ |
$topbin = "/usr/local/sbin/top"; |
| 33 |
+ |
$dfbin = "/usr/bin/df"; |
| 34 |
+ |
$usersbin = "/usr/ucb/users"; |
| 35 |
+ |
$unamebin = "/usr/bin/uname"; |
| 36 |
+ |
$uptimebin = "/usr/bin/uptime"; |
| 37 |
+ |
} |
| 38 |
+ |
elsif ($ostype eq "Linux") { |
| 39 |
+ |
# covers: Debian r2.2 |
| 40 |
+ |
$topbin = "/usr/bin/top"; |
| 41 |
+ |
$dfbin = "/bin/df"; |
| 42 |
+ |
$usersbin = "/usr/bin/users"; |
| 43 |
+ |
$unamebin = "/bin/uname"; |
| 44 |
+ |
$uptimebin = "/usr/bin/uptime"; |
| 45 |
+ |
} |
| 46 |
+ |
elsif ($ostype eq "FreeBSD") { |
| 47 |
+ |
# covers: FreeBSD 4.2-STABLE |
| 48 |
+ |
$topbin = "/usr/bin/top"; |
| 49 |
+ |
$dfbin = "/bin/df"; |
| 50 |
+ |
$usersbin = "/usr/bin/users"; |
| 51 |
+ |
$unamebin = "/usr/bin/uname"; |
| 52 |
+ |
$uptimebin = "/usr/bin/uptime"; |
| 53 |
+ |
} |
| 54 |
+ |
else { |
| 55 |
+ |
print "statgrab.pl Error: Unable to identify system type - \"$ostype\".\n"; |
| 56 |
+ |
print "\"uname -s\" does not report one of the following known types;\n"; |
| 57 |
+ |
print " SunOS, Linux, FreeBSD\n"; |
| 58 |
+ |
exit(1); |
| 59 |
+ |
} |
| 60 |
+ |
|
| 61 |
|
# Run the following components: - |
| 62 |
|
&print_ident(); |
| 63 |
|
&include_osver(); |
| 68 |
|
|
| 69 |
|
# End the program normally. |
| 70 |
|
exit(0); |
| 41 |
– |
|
| 42 |
– |
|
| 43 |
– |
|
| 44 |
– |
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|