#!/usr/local/bin/perl # A small and tidy script to show the current system status # set these to point to the actual programs: # ------------------------------------------ $w_cmd="/usr/bin/w"; $df_cmd="/bin/df -k"; =comment To set these two values above, issue the commands "which df" and "which w" in your shell acount: [dzs ~]# which df /bin/df [dzs ~]# which w /usr/bin/w [dzs ~/]# Then, enter the results into the variables above. =cut # forward declarations sub showrc5log; sub showcommand; # here starts the script... print < Current Status of $ENV{SERVER_NAME} EOT # display the various elements... showcommand("Current Users", $w_cmd); showcommand("Disk Status", $df_cmd); # if you're running the RC5 client, uncomment # the following and change the path and filename... #showrc5log("/home/dzs/rc5/log"); # that's all print "\n"; exit 0; # usage: # showcommand "title", "command to run" # # runs the command and displays the output as html sub showcommand { my($header,$command)=@_; print "

$header

\n";
    open F, "$command |" or print "Can't run $command\n";
    foreach () {
	# replace < and >
	s//>/g;
	# display it
	print; 
    }
    close F;
    print "


"; } # usage: # showrc5log "filename" # # displays a small summary of the log from the client program # for the rc5 distributed computing project # http://www.distributed.net sub showrc5log { my (@a,$i,$sum,$c,$t,$last,$p,$n); # open the logfile and read it into @a open (F, shift); @a=; close F; $sum=0; $c=0; $last=0; foreach (@a) { # search for the keys/sec count if (/([0-9]+\.[0-9]*) keys\/sec/i) { $sum+=$1; $last=$1; $c++; } # look for the current time if (/^\[(.+?)\]/) { $t=$1; } } print <Current RC5 Client Status - $t EOT # display current and average rate if ($c) { printf "", $sum/$c; printf "", $last; } # see if the last line looks like ....10%... if ($a[$#a]=~/([0-9]{2})%(\.*?)$/) { $p=$1+length($2)*2; } elsif ($a[$#a]=~/^(\.+)$/) { $p=length($1)*2; } else { $p=0; } $n=100-$p; # display the bar graph for the current block if ($p) { print < EOT } print "
Average Rate:". "%1.2f keys/sec\n
Current Rate:". "%1.2f keys/sec\n
Current Block:
   
$p%


"; } # ------------------------------------------------------------ # Revision 1: 10/6/97 - dzs - modified showcommand and added # a simpler way to run the programs. # ------------------------------------------------------------