Proc::LoadMonitor - Load monitoring for worker processes
use Proc::LoadMonitor; # get monitor, starts in 'idle' state my $lmon = Proc::LoadMonitor->new; # some job queue with timeout (e.g redis BLPOP) which # blocks until a new job is available, or times out. # while ( my $job = $some_queue->get_next_job() ) { if ($job) { $lmon->busy; # set monitor to 'busy'; $job->do_it(); } $lmon->idle; # set monitor to 'idle', increment loop count my $report = $lmon->report; # $report = { # loops => 781, # number of loops # jobs => 674, # number of processed jobs # load_05 => 0.650, # 5 min. load avg. # load_10 => 0.510, # 10 min. load avg. # load_15 => 0.414, # 15 min. load avg. # state => 'idle', # 'busy'/'idle' # total => 110566.19 # total run time # } }
This module keeps track of idle and busy times in a worker process and calculates 5, 10 and 15 minutes load averages.
Set state to busy.
state
busy
Set state to idle and increment the loop counter.
idle
loop
Returns the state which may be busy or idle.
Returns the loop count.
Returns the number of jobs processed so far.
jobs
Returns a report (hash) containing loops, jobs, total (total run time in sec.), load_05 (5 min. load average), load_10 (10 min. load average) and load_15 (15 min. load average).
loops
total
load_05
load_10
load_15
Michael Langner (cpan:MILA)
Copyright (c) 2015 the Proc::LoadMonitor "AUTHOR".
This library is free software and may be distributed under the same terms as perl itself. See http://dev.perl.org/licenses/.
To install Proc::LoadMonitor, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Proc::LoadMonitor
CPAN shell
perl -MCPAN -e shell install Proc::LoadMonitor
For more information on module installation, please visit the detailed CPAN module installation guide.