NAME

Schedule::Load::Hosts - Return host loading information across a network

SYNOPSIS

    use Schedule::Load::Hosts;

    my $hosts = Schedule::Load::Hosts->fetch();
    $hosts->print_machines();
    $hosts->print_top();

    # Overall machine status
    my $hosts = Schedule::Load::Hosts->fetch();
    (my $FORMAT =    "%-12s    %4s     %4s   %6s%%       %5s    %s\n") =~ s/\s\s+/ /g;
    printf ($FORMAT, "HOST", "CPUs", "FREQ", "TotCPU", "LOAD", "ARCH/OS");
    foreach my $host ($hosts->hosts) {
	printf STDOUT ($FORMAT,
		       $host->hostname, 
		       $host->cpus, 
		       $host->max_clock, 
		       sprintf("%3.1f", $host->total_pctcpu), 
		       $host->adj_load, 
		       $host->archname ." ". $host->osvers, 
		       );
    }

    # Top processes
    (my $FORMAT =    "%-12s   %6s    %-8s      %-5s    %6s     %5s%%    %s\n") =~ s/\s\s+/ /g;
    printf ($FORMAT, "HOST", "PID", "USER",  "STATE", "RUNTM", "CPU","COMMAND"); 
    foreach my $host ($hosts->hosts) {
	foreach $p ($host->top_processes) {
	    printf($FORMAT, 
		   $host->hostname,
		   $p->pid, 		$p->uname,		
		   $p->state, 		$p->time_hhmm,
		   $p->pctcpu,		$p->fname);
	}
    }

DESCRIPTION

This package provides information about host loading and top processes from many machines across a entire network.

fetch ()

Fetch the data structures from across the network. This also creates a new object. Accepts the port and host parameters.

restart ()

Restart all daemons, loading their code from the executables again. Use sparingly. chooser parameter if true (default) restarts chooser, reporter parameter if true (default) restarts reporter.

hosts ()

Returns the host objects, accessible with Schedule::Load::Hosts::Host. In an array context, returns a list; In a a scalar context, returns a reference to a list.

hosts_match (...)

Returns Schedule::Load::Hosts::Host objects for every host that matches the specified criteria. Criteria are named parameters, as described in Schedule::Load::Schedule, of the following: classes specifies an arrayref of allowed classes. match_cb is a routine returning true if this host matches. allow_reserved=>0 disables returning of reserved hosts.

idle_host_names (...)

Returns a list of host cpu names which are presently idle. Multiple free CPUs on a given host will result in that name being returned multiple times.

ping

Return true if the slchoosed server is up.

get_host ($hostname)

Returns a reference to a host object with the specified hostname, or undef if not found.

classes ()

Returns all class_ variables under all hosts. In an array context, returns a list; In a a scalar context, returns a reference to a list.

Returns a string with the list of machines and classes that may run on them in a printable format.

Returns a string with the list of host machines and loading in a printable format.

Returns a string with the top jobs on all machines in a printable format, ala the top program.

Returns a string with the top jobs command lines, including any jobs with a fixed loading.

PARAMETERS

dhost

List of daemon hosts that may be running the slchoosed server. The second host is only used if the first is down, and so on down the list.

port

The port number of slchoosed. Defaults to 'slchoosed' looked up via /etc/services, else 1752.

SEE ALSO

Schedule::Load::Hosts::Host, Schedule::Load::Hosts::Proc

Schedule::Load, rschedule

DISTRIBUTION

The latest version is available from CPAN.

AUTHORS

Wilson Snyder <wsnyder@wsnyder.org>