% cat try_sysinfo
: # use perl
eval 'exec perl -S $0 "$@"'
if 0;
require "getopts.pl" ;
if ( ! &Getopts('nv') || @ARGV != 0 )
{ die ( "Usage: $0\n" ) ; }
use lib "$ENV{ANTELOPE}/data/perl" ;
use Datascope ;
use sysinfo ;
&elog_init("try_sysinfo");
$hardware = my_hardware() ;
$os = my_os() ;
print "hardware: $hardware os: $os\n" ;
$short_hostname = my_hostname() ;
($hostname, $ip) = my_ip() ;
print "$short_hostname $hostname ($ip)\n" ;
@mounts = sysmounted() ;
printf ( "\n%-25s %-8s %-8s %-25s\n",
"mount point", "fstype", "host", "remote dir" ) ;
foreach $mount ( @mounts ) {
($mountpt, $fstype, $host, $source ) = split ( "\t", $mount ) ;
printf ( "%-25s %-8s %-8s %-25s\n",
$mountpt, $fstype, $host, $source ) ;
%statvfs = statvfs($mountpt) ;
foreach $key ( sort keys %statvfs ) {
printf "\t%-16s %12.3f\n", $key, $statvfs{$key} ;
}
}
for ( $i = 0 ; $i<1 ; $i++ ) {
($ncpu, $idle, $user, $kernel, $iowait, $swap, @the_rest)
= syscpu() ;
print "\n" ;
print "cpu usage: $ncpu cpu's\n" ;
print " idle user kernel iowait swap\n" ;
printf " %5.2f %5.2f %5.2f %5.2f %5.2f\n",
$idle, $user, $kernel, $iowait, $swap ;
open (SWAP, "swap -s |" ) ;
@swap = <SWAP> ;
close SWAP ;
print "\n@swap" ;
%vminfo = sysmem() ;
foreach $key ( sort keys %vminfo ) {
printf "%-8s %s\n", $key, $vminfo{$key} ;
}
%loadavg = sysloadavg() ;
print "\n" ;
foreach $key ( sort keys %loadavg ) {
printf "%-15s %s\n", "loadavg{$key}", $loadavg{$key} ;
}
%psinfo = pidinfo($$) ;
print "\n pid: $$\n" ;
foreach $key ( sort keys %psinfo ) {
printf "%-8s %s\n", $key, $psinfo{$key} ;
}
$execname = pidexecname($$) ;
$cmdline = pidcmdline($$) ;
$pwd = pidpwd($$) ;
print "\n$pwd: $execname : $cmdline\n" ;
sleep 1 ;
print "\n" ;
}
$ip = name2ip ( "castle.brtt.com" ) ;
$name = ip2name ($ip) ;
print "castle.brtt.com -> $ip -> $name\n" ;
$ip2 = ip($ip) ;
$name = ip2name ($ip2) ;
print "$ip -> $ip2 -> $name\n" ;
printf "\n" ;
$found = 0 ;
for ( $decade = 0x1 ; $decade < 0x80000000 ; $decade *= 0x10 ) {
foreach $x ( (1,2,4,8) ) {
$address = $x * $decade ;
if ( nomem ( $address, 1 ) ) {
printf "*NO* memory at %8x\n", $address ;
} else {
printf " %8x ok\n", $address ;
$found++ ;
}
}
}
% try_sysinfo
hardware: sun4u os: SunOS
castle castle.brtt.com (207.174.76.135)
mount point fstype host remote dir
/ ufs /dev/dsk/c0t0d0s0
Mb_avail 656.396
Mb_total 3140.069
id 35651584.000
inodes 396800.000
inodes_avail 300367.000
inodes_used 0.243
used 0.791
.
.
.
cpu usage: 1 cpu's
idle user kernel iowait swap
76.50 11.88 10.20 1.41 0.00
total: 1221872k bytes allocated + 27512k reserved = 1249384k used, 164448k available
physmem 512
total 1380.6953125
used 1219.96875
loadavg{avg15m} 0.28125
loadavg{avg1m} 0.28515625
loadavg{avg5m} 0.30078125
loadavg{nproc} 119
pid: 26480
ccputime 0.01
cputime 0.36
pcpu 1.72124393444624
ppid 22110
rss 4560
size 5808
started 1031337485
state run
uid 2752
/opt/antelope/tests/bin/datascope/perlsysinfo: perl : perl -S ./try_sysinfo
castle.brtt.com -> 207.174.76.135 -> castle.brtt.com
207.174.76.135 -> -810660729 -> castle.brtt.com
*NO* memory at 1
*NO* memory at 2
.
.
10000 ok
20000 ok
40000 ok
80000 ok
*NO* memory at 100000
200000 ok
*NO* memory at 400000
*NO* memory at 800000
.
.
.