root/lib/Core/Load.pm

Revision 5affb812cb6eddcc393591898efac3840e859cd2, 1.2 kB (checked in by Mark Harrison <mark@omniti.com>, 4 years ago)

Load average module

git-svn-id: https://labs.omniti.com/resmon/branches/resmon2@304 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55

  • Property mode set to 100644
Line 
1 package Core::Load;
2
3 use strict;
4 use warnings;
5
6 use base 'Resmon::Module';
7
8 use Resmon::ExtComm qw(run_command);
9
10 =pod
11
12 =head1 NAME
13
14 Core::Load - monitor system load
15
16 =head1 SYNOPSIS
17
18  Core::Load {
19      load: noop
20  }
21
22  Core::Load {
23      load: uptime_path => /bin/uptime
24  }
25
26 =head1 DESCRIPTION
27
28 This module monitors system load using the uptime command.
29
30 =head1 CONFIGURATION
31
32 =over
33
34 =item check_name
35
36 The check name is descriptive only in this check. It is not used for anything.
37
38 =item uptime_path
39
40 Specify an alternate path to the uptime command. Default: uptime
41
42 =back
43
44 =head1 METRICS
45
46 =over
47
48 =item 1m
49
50 The system load average over the past minute.
51
52 =item 5m
53
54 The system load average over the past five minutes.
55
56 =item 15m
57
58 The system load average over the past fifteen minutes.
59
60 =back
61
62 =cut
63
64 sub handler {
65     my $self = shift;
66     my $config = $self->{config}; # All configuration is in here
67     my $uptime_path = $self->{uptime_path} || 'uptime';
68
69     my $output = run_command($uptime_path);
70     chomp $output;
71
72     my ($l1, $l5, $l15) =
73         $output =~ /load averages?: ([0-9.]+), ([0-9.]+), ([0-9.]+)/;
74
75     return {
76         "1m" =>  [$l1,  "n"],
77         "5m" =>  [$l5,  "n"],
78         "15m" => [$l15, "n"],
79     };
80 };
81
82 1;
Note: See TracBrowser for help on using the browser.