Wilson Snyder > Schedule-Load > Schedule::Load::Hosts

Download:
Schedule-Load-3.064.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 3.064   Source  

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_sorted) {
        printf STDOUT ($FORMAT,
                       $host->hostname,
                       $host->cpus_slash,
                       $host->max_clock,
                       sprintf("%3.1f", $host->total_pctcpu),
                       sprintf("%2.2f", $host->adj_load),
                       $host->archname ." ". $host->osvers,
                       );
    }

    # Top processes
    (my $FORMAT =    "%-12s   %6s    %-10s     %-5s    %6s     %5s%%    %s\n") =~ s/\s\s+/ /g;
    printf ($FORMAT, "HOST", "PID", "USER",  "STATE", "RUNTM", "CPU","COMMAND");
    foreach my $host ($hosts->hosts_sorted) {
        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.

$self->fetch ()

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

$self->format_table(formats=>[...], data=>[...]);

Used internally by the print routines, but may be useful for external use also. Return a table as a string. Named format argument must be an array reference containing sprintf strings, plus '^' may be used as the width of the widest data column. Named data argument must be two dimmensional array reference of the data table to be printed.

$self->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.

$self->hosts ()

Returns the host objects in name sorted order, accessible with Schedule::Load::Hosts::Host. In an array context, returns a list; In a a scalar context, returns a reference to a list. This function is historical, using hosts_sorted or hosts_unsorted is faster.

$self->hosts_sorted ()

Returns array of host objects in name sorted order, accessible with Schedule::Load::Hosts::Host.

$self->hosts_unsorted ()

Returns array of host objects in unsorted order, accessible with Schedule::Load::Hosts::Host.

$self->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.

$self->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.

$self->ping

Return true if the slchoosed server is up.

$self->get_host ($hostname)

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

$self->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.

$self->print_classes

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

$self->print_hosts

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

$self->print_top

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

$self->print_loads

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.

DISTRIBUTION ^

The latest version is available from CPAN and from http://www.veripool.org/.

Copyright 1998-2011 by Wilson Snyder. This package is free software; you can redistribute it and/or modify it under the terms of either the GNU Lesser General Public License Version 3 or the Perl Artistic License Version 2.0.

AUTHORS ^

Wilson Snyder <wsnyder@wsnyder.org>

SEE ALSO ^

Schedule::Load, rschedule

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

syntax highlighting: