Skip to content
Snippets Groups Projects
Commit 3721d2a6 authored by Gavin Sandie's avatar Gavin Sandie
Browse files

Add support for counting Linux Process types

Uses ps to count the amount of processes on a system. I've placed this
into the Linux area as I've only tested it on a Linux system (Ubuntu
11.04).
parent bf8bc6d4
No related branches found
No related tags found
No related merge requests found
package Core::Linux::Processes;
use strict;
use warnings;
use base 'Resmon::Module';
use Resmon::ExtComm qw(run_command cache_command);
=pod
=head1 NAME
Core::Linux::Processes - a procesess state module
=head1 SYNOPSIS
Core::Linux::Processes {
local : noop
}
=head1 DESCRIPTION
This module returns information on the state of the proceses on a running system.
=head1 CONFIGURATION
=over
=item check_name
The check name is descriptive only in this check. It is not used for anything.
=back
=head1 METRICS
=over
=item blocked
Processes in an uninterruptible sleep.
=item zombies
Defunct processes, terminated but not reaped by their parent.
=item running
Running or runnable processes.
=item sleeping
Processes in an interruptible sleep.
=item stopped
Stopped processes.
=back
=cut
sub handler {
my $self = shift;
my $config = $self->{config}; # All configuration is in here
my $check_name = $self->{check_name}; # The check name is in here
my $ps_cmd = 'ps ax -o state';
my $processes = run_command($ps_cmd);
my @processes = split(/\n/, $processes);
my $sleeping = grep(/S/, @processes);
my $blocked = grep(/D/, @processes);
my $zombies = grep(/Z/, @processes);
my $running = grep(/R/, @processes);
my $stopped = grep(/T/, @processes);
return {
"blocked" => [$blocked, "i"],
"zombies" => [$zombies, "i"],
"running" => [$running, "i"],
"stopped" => [$stopped, "i"],
"sleeping" => [$sleeping, "i"]
};
};
1;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment