| Schedule-Load documentation | Contained in the Schedule-Load distribution. |
Schedule::Load::Hosts::Proc - Return process information
See Schedule::Load::Hosts
This package provides accessors for information about a specific process obtained via the Schedule::Load::Hosts package.
Returns all information fields for this process.
Returns true if a specific field exists for this process.
Returns the value of a specific field for this process.
A accessor exists for each field returned by the fields() call. Typical elements are described below. All fields that Proc::ProcessTable supports are also accessible.
Nice value with 0 being normal and 19 maximum nice.
Returns the runtime of the process in mmm:ss or hh.hH format, whichever is appropriate.
Texual user name running this process.
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.
Wilson Snyder <wsnyder@wsnyder.org>
| Schedule-Load documentation | Contained in the Schedule-Load distribution. |
# Schedule::Load::Hosts::Proc.pm -- Process information # See copyright, etc in below POD section. ###################################################################### package Schedule::Load::Hosts::Proc; require 5.004; require Exporter; require AutoLoader; @ISA = qw(Exporter AutoLoader); use Schedule::Load; use strict; use vars qw($VERSION $AUTOLOAD); use Carp; ###################################################################### #### Configuration Section # Other configurable settings. $VERSION = '3.064'; ###################################################################### #### Globals ###################################################################### #### Special accessors sub fields { my $self = shift; ($self && ref($self)) or croak 'usage: '.__PACKAGE__.'->hosts)'; return (keys %{$self}); } sub exists { my $self = shift; ($self && ref($self)) or croak 'usage: '.__PACKAGE__.'->get(field))'; my $field = shift; return (exists ($self->{$field})); } sub get { my $self = shift; ($self && ref($self)) or croak 'usage: '.__PACKAGE__.'->get(field))'; my $field = shift; if (exists ($self->{$field})) { return $self->{$field}; } else { croak __PACKAGE__.'->get($field): Unknown field'; } } sub time_hhmm { my $self = shift; ($self && ref($self)) or croak 'usage: '.__PACKAGE__.'->get(field))'; return undef if (!defined $self->{time}); return $self->format_hhmm($self->time); } sub format_hhmm { my $self = shift; my $runtime = shift; if ($runtime >= 2*3600) { return sprintf "%3.1fH", int($runtime/360)/10; } else { return sprintf "%3d:%02d", int($runtime/60), $runtime%60; } } ###################################################################### #### Accessors sub AUTOLOAD { my $self = shift; my $type = ref($self) or croak "$self is not an ".__PACKAGE__." object"; (my $field = $AUTOLOAD) =~ s/.*://; # Remove package if (exists ($self->{$field})) { eval "sub $field { return \$_[0]->{$field}; }"; return $self->{$field}; } else { croak "$type->$field: Unknown ".__PACKAGE__." field $field"; } } sub DESTROY {} ###################################################################### #### Package return 1; ###################################################################### __END__