#!/usr/local/bin/perl 
#
# Copyright (C) 1992 by Gustaf Neumann, Stefan Nusser
#
#      Wirtschaftsuniversitaet Wien,
#      Abteilung fuer Wirtschaftsinformatik
#      Augasse 2-6,
#      A-1090 Vienna, Austria
#      neumann@wu-wien.ac.at, nusser@wu-wien.ac.at
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
# that the above copyright notice appears in all copies and that both that
# copyright notice and this permission notice appear in all supporting
# documentation.  This software is provided "as is" without expressed or
# implied warranty.
#
# Date: Mon, Apr 13 1992
# Author: Gustaf Neumann
# Version: 0.91
#

$options = "u:";
$WafeLib = $ENV{'WAFELIB'} || "/usr/lib/X11/wafe";
require "$WafeLib/perl/wafe.pl";

$opt_u = $opt_u ||  90; # 90 seconds per default

$ARGV[0] = $ENV{'HOST'} if !@ARGV;
for ($[ .. $#ARGV) { $ARGV[$_] = $1 if $ARGV[$_] =~ m/([^.]*)/;}

$ruleColor="highlight $1" if $sbColors =~ /background\s+(\S+)/; 
&Xui("Form top topLevel defaultDistance 0 translations {<Key>q: exec(quit)}");

foreach $host (@ARGV) {
    &Xui(<<"__");
    Label label_$host top label $host borderWidth 0 width 80 $horiz
    StripChart $host top {
	borderWidth 0 $ruleColor $horiz
	fromVert label_$host width 80 height 35 update $opt_u
__
    $horiz = "fromHoriz $host";
}
&Xui("realize;deleteWindowProtocol quit");

while (1) {
    open(RUPTIME,"ruptime|");
    while(<RUPTIME>) {
	if (/(\S+) +.+load (\d+\.\d+)/) { $load{$1} = $2; } 
	if (/(\S+) +down/ && grep(/$1/,@ARGV)) { $load{$1} = 0; }
    }
    close(RUPTIME);

    foreach $host (@ARGV) {
	&Xui("scSet $host $load{$host}") if $load{$host} ne '';
    }

    select(undef, undef, undef, $opt_u);
}









