mpegman has asked for the wisdom of the Perl Monks concerning the following question:

I'm currently working for a school, which just bought 10 brand new 1.4ghz machine (running linux) on which the students can browse the web, check email, etc. Since this is the only thing the students do, these machines have a lot of CPU cycles left over. I was wondering if there is a (semi-secure) way i can monitor each machine's load so I can tell the CS department on which machines they can run their CPU intensive programs.

Replies are listed 'Best First'.
•Re: Getting the load of a remote mashine
by merlyn (Sage) on May 13, 2002 at 20:08 UTC
      ruptime has been ported to linux. Debian makes it available in the ruptime package. Other distros probably have it too.
Re: Getting the load of a remote mashine
by DamnDirtyApe (Curate) on May 14, 2002 at 07:57 UTC

    Here's something you might find useful. It's almost straight out of the Ram book, adapted to collect uptimes from little Perl uptime servers.

    Here's the server that runs on each of the reporting machines...

    #! /usr/bin/perl -w # # loadserv.pl # use strict ; use warnings ; use IO::Socket ; my $server_port = 2048 ; my $server = IO::Socket::INET->new( LocalPort => $server_port, Type => SOCK_STREAM, Reuse => 1, Listen => 10 ) or die "Couldn't be a TCP server on port $server_port: $@\n" ; while ( my $client = $server->accept() ) { print $client `uptime` ; } close( $server ) ;

    ...and here's the client that collects the uptime information from the various servers.

    #! /usr/bin/perl -w # # loadclient.pl # use strict ; use warnings ; use IO::Socket ; my @remote_hosts = ( { addr => '127.0.0.1' }, { addr => '123.123.123.123' } ) ; my $remote_port = 2048 ; foreach my $host ( @remote_hosts ) { my $socket = IO::Socket::INET->new( PeerAddr => $host->{ addr }, PeerPort => $remote_port, Proto => 'tcp', Type => SOCK_STREAM ) or die "Couldn't connect to $host->{ addr }:$remote_port: $@\n" +; $host->{ uptime } = <$socket> ; } # The anonymous hashes in @remote_hosts now also contain # the uptimes of the servers listed.

    This worked for me when I ran the server on my local machine as well as a remote machine. Hope this helps. Also, I'd really appreciate knowing what people think of this approach.


    _______________
    D a m n D i r t y A p e
    Home Node | Email
Re: Getting the load of a remote mashine
by thor (Priest) on May 14, 2002 at 01:28 UTC
    Have the CS department run their stuff on all the machines. Just set the priority low (or high, depending on how you look at it) so that it won't contend with the students' stuff. That way, should the load shift to another machine, you don't have to re-evaluate your solution.
Re: Getting the load of a remote mashine
by yodabjorn (Monk) on May 14, 2002 at 04:34 UTC
    Along the lines of runing processes on all nodes I would suggest the most excelent MOSIX project to build a simple yet effective cluster.