AnyEvent-Monitor-CPU
view release on metacpan or search on metacpan
lib/AnyEvent/Monitor/CPU.pm view on Meta::CPAN
The following parameters are accepted:
=over 4
=item cb
cb => sub {
my ($monitor, $high_low_flag) = @_;
say $high_low_flag? "I'm bored..." : "I'm high as a kite!";
},
The callback to be used when the CPU usage rises above or lowers below
the defined thresholds.
This parameter is B<required> and it should be a coderef.
The callback will be called with two parameters:
=over 4
lib/AnyEvent/Monitor/CPU.pm view on Meta::CPAN
$usage = $monitor->usage()
Returns the last sampled CPU usage.
The value returned is between 0 and 1.
=head2 is_high()
if ($monitor->is_high()) {
say "Your eggs will be ready in a minute";
}
Returns true if the CPU usage is over the defined limits.
=head2 is_low()
if ($monitor->is_low()) {
say "Its chilly in here, wanna generate some heat?";
}
Returns true if the CPU usage is below the defined limits.
=head2 stats()
my $stats = $monitor->stats;
my $count = $stats->{usage_count};
say "Average usage was $stats->{usage_avg} over the last $count samples"
if $count;
Returns a hashref with statistics. The following keys are available:
=over 4
=item usage
The last usage sample taken. Its the same as C<< $monitor->usage >>.
lib/AnyEvent/Monitor/CPU.pm view on Meta::CPAN
=head2 start()
$monitor->start();
Starts the polling process for the CPU monitor.
=head2 is_running()
if ($monitor->is_running()) {
say "Big brother is watching, play it cool";
}
else {
say "Bring on the bacon and eggs, lets make breakfast!";
}
Returns true if the monitor is polling the CPU usage.
=head1 SEE ALSO
L<Proc::CPUUsage|Proc::CPUUsage>.
( run in 0.761 second using v1.01-cache-2.11-cpan-483215c6ad5 )