#!/usr/cs/bin/perl @Machines = ( "adder: Interactive Server
50MHz SuperSPARC 10", "cobra: Interactive Server
360MHz UltraSPARC II", "mamba: Interactive Server
360MHz UltraSPARC II", "viper: Interactive Server
360MHz UltraSPARC II", "altair: Compute Server
167MHz UltraSPARC 1", "alto: Compute Server
167MHz UltraSPARC 1", "casper: Compute Server
167MHz UltraSPARC 1", "univac: Compute Server
167MHz UltraSPARC 1", "ace: Compute Server
50MHz SuperSPARC 20", "edvac: Compute Server
50MHz SuperSPARC 20", "whirlwind: Compute Server
50MHz SuperSPARC 20", "apollo: File Server
50MHz SuperSPARC 10", "www: Web Server
50MHz SuperSPARC 10"); @tips = ( "Do not run CPU-intensive jobs on the interactive servers. The compute servers are better-suited for these tasks.", "Use /tmp or /usr/tmp for I/O when using the compute servers. These are on local disks that can be accessed faster.", "The /tmp directories local to a specific machine are erased whenever the machine goes down.", "Multiple jobs on a single-CPU compute server compete with each other and degrade their own performance. Run multiple jobs on multi-CPU machines.", "Using -pipe when compiling with GCC opens memory-to-memory pipes between compiler stages, rather than temporary files. This reduces compile time by reducing file I/O.", "Users may run at most 2 jobs on a compute server, with a maximum of 4 jobs on all compute servers.", "The Sun \"CC\" and \"cc\" compilers have many options for optimising programs. Run \"CC -flags\" or \"cc -flags\" to find out more.", "If you run 4 compute jobs, please don't use all 4 UltraSPARCs. Leave one open for other people.", "To get faster compiles, use \"gmake -j 4\" on a multi-CPU compute server. It will run up to 4 simultaneous compilations, if 4 dependencies are simultaneously satisfied.", "Use \"purify\" to help find memory leaks and memory-related errors. Simply link your code with the command \"purify\" as the first thing on the command line.", "Use \"quantify\" to help you determine where your program spends all its time executing. Re-link your program with \"quantify\" as the first thing on the command line. It will show you call-graphs and execution times per function.", "The department has recently bought new, updated C and C++ compilers for Solaris. They include a graphical debugger named \"debugger\" and many new options.", "Use a debugger. vi + printf != debugger.", "Edit your code on an interactive server, not a compute server.", "Compile and run your code on a compute server, not an interactive server."); @config = ("8fbc8f", "b5a642", "cococo", "d8bfd8", "d9d9f3", "ebc79e", "ffffff"); $histtimes = 25; srand; @appendage = @oldtimes = (); open(OLD, "/users/an4m/public_html/usage.html"); @oldtimes = ; close(OLD); @oldtimes = reverse((reverse(@oldtimes))[0..$#Machines+1]); $nowtime = `/usr/bin/date +"%R %A, %B %d, %Y"`; $backcolour = $config[rand(@config)]; @readings = split(/\s+/, @oldtimes[$#oldtimes]); pop(@oldtimes); shift(@readings); pop(@readings); shift(@readings); for ($j = $histtimes-$#readings-1; $j > 0; $j--) { unshift(@readings, "--"); } for ($j = $#readings-$histtimes+1; $j > 0; $j--) { shift(@readings); } @oldtimes[$#Machines+1] = "\nDepartment Computer Usage" . "" . "" . "

Current CPU Usage

" . "Last update: $nowtime; Next update: 5 minutes later" . "
"; chop($nowtime); $nowtime =~ s/ .*//g; @oldtimes[$#Machines+1] .= "\t$nowtime\t-->\n"; $secondrow = ""; $thirdrow = ""; for ($i = 0; $i <= $#Machines; $i++) { ($mach, $type) = split(/: /, @Machines[$i]); print NEW ""; eval { local $SIG{ALRM} = sub { die "DEAD"; }; alarm 20; @output = `/users/an4m/bin/usage $mach 2> /dev/null`; alarm 0; }; if ($@ =~ /DEAD/) { @output[0] = ":0 :0 :0\n"; @output[3] = "Oops! $mach doesn't respond!\n"; } ($junk, $cpu, $load, $total) = split(/ *: */, @output[0]); $back = ($cpu <= 50) ? sprintf("bgcolor=#%02xff00", int(0xff*$cpu/50)) : sprintf("bgcolor=#ff%02x00", 0xff-int(0xff*($cpu-50)/50)); $secondrow .= ""; $thirdrow .= ""; shift(@output); shift(@output); shift(@output); push(@appendage, "
" . "MACHINE
$readings[0]" . "
  H
U I
S S
A T
" . "G O
E R
  Y

" . "$nowtime
Jobs/CPU$mach"; @times = split(/\s+/, @oldtimes[$i]); shift(@times); pop(@times); shift(@times); for ($j = $histtimes-$#times-1; $j > 0; $j--) { unshift(@times, "0"); } for ($j = $#times-$histtimes+1; $j > 0; $j--) { shift(@times); } @oldtimes[$i] = "\n"; $secondrow .= "
$load/$total
" . "

" . "$mach

$type
" . "" . "" . "" . "" . ""); foreach $line (@output) { $_ = $line; s/^\s+//; ($user, $jobs, $percpu, $memory) = split; if ($user ne "Oops!") { $user = "$user";} push(@appendage, "" . "" . "" . ""); } push(@appendage, "
User#Jobs%CPUMemory

$user$jobs$percpu$memory
" . "" . "" . "" . "
%CPU$cpu
Load$load
#CPU$total
"); } print NEW "$secondrow$thirdrow" . "" . "Live Printer Status
$tips[rand(@tips)]
"; foreach $line (@appendage) { print NEW $line; } # print NEW "
$tips[rand(@tips)]

Current Disk Usage

" # . "
" # . "" # . "" # . "" # . ""; # @output = `/users/an4m/bin/disk 2> /dev/null`; # shift(@output); # foreach $line (@output) # { # $_ = $line; s/^\s+//; @components = split; # print NEW "" # . "" # . "" # . ""; # } # print NEW "
ServerDisk%UsedResidents
$components[0]$components[1]$components[2]"; # shift(@components); shift(@components); shift(@components); # foreach $user (@components) # { print NEW "$user " } # print NEW "
"; print NEW "
Maintained by Nuts\n"; foreach $line (@oldtimes) { print NEW $line; } close(NEW); system("mv", "/users/an4m/public_html/.usage.html.$$", "/users/an4m/public_html/usage.html");