summaryrefslogtreecommitdiffstats
path: root/check_load
diff options
context:
space:
mode:
Diffstat (limited to 'check_load')
-rwxr-xr-xcheck_load48
1 files changed, 10 insertions, 38 deletions
diff --git a/check_load b/check_load
index 802839c..8a3b2c8 100755
--- a/check_load
+++ b/check_load
@@ -58,31 +58,6 @@ sub parse_thresholds($) {
return undef;
}
-sub get_load($$) {
- my $n = shift;
- my $context = shift;
-
- my $proc = VServer::get_proc_dir($context);
- unless ($proc) {
- $n->nagios_exit(UNKNOWN, "vserver not running");
- }
-
- open(my $cvirt, "<", "$proc/cvirt") ||
- $n->nagios_exit(UNKNOWN, "could not open '$proc/cvirt'");
-
- my @load = undef;
- while (<$cvirt>) {
- if ($_ =~ m/^loadavg:\s*([0-9.]+)\s*([0-9.]+)\s*([0-9.]+)$/) {
- @load = ($1, $2, $3);
- last;
- }
- }
-
- close($cvirt);
-
- return @load;
-}
-
# fix taint mode
if ($0 =~ m/(\w[\w\/]*\w)/) {
@@ -119,30 +94,27 @@ unless ($context) {
$n->nagios_exit(UNKNOWN, "vserver '$vserver' not found");
}
-my @load = get_load($n, $context);
+my $load = VServer::get_loadavg($id);
if (@load) {
- my %values;
- ($values{'load1'}, $values{'load5'}, $values{'load15'}) = @load;
-
my @status = [ UNKNOWN ];
my $output = "";
- for my $load (qw( load1 load5 load15 )) {
- $n->add_perfdata(label => $load,
- value => $values{$load},
- warning => $warn{$load},
- critical => $crit{$load},
+ for my $key (qw( load1 load5 load15 )) {
+ $n->add_perfdata(label => $key,
+ value => $load->{$key},
+ warning => $warn{$key},
+ critical => $crit{$key},
min => 0,
);
push(@status,
- $n->check_threshold(check => $values{$load},
- warning => $warn{$load},
- critical => $crit{$load}
+ $n->check_threshold(check => $load->{$key},
+ warning => $warn{$key},
+ critical => $crit{$key}
)
);
- $output .= " $values{$load}";
+ $output .= " $load->{$key}";
}
$n->nagios_exit($n->max_state(@status), "load average:$output");