LSF::Hosts - Retrieve information about LSF hosts.


LSF-Hosts documentation Contained in the LSF-Hosts distribution.

Index


Code Index:

NAME

Top

LSF::Hosts - Retrieve information about LSF hosts.

VERSION

Top

 0.1

SYNOPSIS

Top

use LSF::Hosts;

use LSF::Hosts RaiseError => 0, PrintError => 1, PrintOutput => 0;

($hinfo) = LSF::Hosts->new( [HOST_NAME] );

@hosts = LSF::Hosts->new();

DESCRIPTION

Top

LSF::Hosts is a wrapper arround the LSF 'bhosts' command used to obtain information about lsf hosts. The hash keys of the object are LSF bhosts header values. See the 'bhosts' man page for more information.

INHERITS FROM

Top

LSF

CONSTRUCTOR

Top

new( [ [HOST_NAME] ] );

With a valid hostname, creates a new LSF::Hosts object. Without a hostname returns a list of LSF::Hosts objects for all the hosts in the system. Takes no arguments (jet).

HISTORY

Top

Based on (read ripped from) LSF::Queues by Mark Southern (mark_southern@merck.com).

SEE ALSO

Top

LSF, bhosts

AUTHOR

Top

Aukjan van Belkum (aukjan@cpan.org)

COPYRIGHT

Top


LSF-Hosts documentation Contained in the LSF-Hosts distribution.
package LSF::Hosts;

use strict;
use warnings;
use base qw( LSF );
use IPC::Run qw( run );
our $VERSION = '0.01';

sub import
{
  my ( $self, %p ) = @_;
  $p{RaiseError}  ||= 1;
  $p{PrintOutput} ||= 1;
  $p{PrintError}  ||= 1;
  $self->PrintOutput( $p{PrintOutput} ) if exists $p{PrintOutput};
  $self->PrintError( $p{PrintError} )   if exists $p{PrintError};
  $self->RaiseError( $p{RaiseError} )   if exists $p{RaiseError};
}

sub new
{
  my ( $class, @params ) = @_;
  my @output = $class->do_it( 'bhosts', '-l' );
  return unless @output;
  my @hosts;
  my $host;
  my @keys = qw(STATUS CPUF JL/U MAX NJOBS RUN SSUSP USUSP RSV DISPATCH_WINDOW);
  foreach ( split( /\n/, $output[0] ) ) {
    if ( /HOST/ .. /^\s*$/ ) {
      my $hostline = $_;
      if (/HOST\s+(\S+)/) {
        $host = {};
        $host->{HOST_NAME} = $1;
      }
      if ( !( /HOST/ || /STATUS/ || /^\s*$/ ) ) {
        my @values = split /\s+/, $hostline;
        for ( 0 .. @keys - 1 ) { $host->{ $keys[$_] } = $values[$_]; }
        bless $host, $class;
        push @hosts, $host;
      }
    }
  }
  return @hosts;
}

1;

__END__