This commit is contained in:
garnier-quentin 2014-05-05 19:57:31 +02:00
parent 34383a4c6f
commit fa22e61ae6
4 changed files with 34 additions and 37 deletions

View File

@ -119,8 +119,8 @@ sub run {
$self->{output}->perfdata_add(label => "used",
value => $physical_used,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1),
min => 0, max => $total_size);
$self->{output}->display();

View File

@ -119,8 +119,8 @@ sub run {
$self->{output}->perfdata_add(label => "used",
value => $swap_used,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1),
min => 0, max => $total_size);
$self->{output}->display();

View File

@ -86,9 +86,9 @@ sub run {
$cpu += $result->{$key};
$self->{output}->output_add(long_msg => sprintf("CPU $i Usage is %.2f%%", $result->{$key}));
$self->{output}->perfdata_add(label => 'cpu' . $i,
value => sprintf("%.2f", $result->{$key}),
min => 0, max => 100);
$self->{output}->perfdata_add(label => 'cpu' . $i, unit => '%',
value => sprintf("%.2f", $result->{$key}),
min => 0, max => 100);
$i++;
}
@ -97,7 +97,7 @@ sub run {
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit_code,
short_msg => sprintf("CPU(s) average usage is: %.2f%%", $avg_cpu));
$self->{output}->perfdata_add(label => 'total_cpu_avg',
$self->{output}->perfdata_add(label => 'total_cpu_avg', unit => '%',
value => sprintf("%.2f", $avg_cpu),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),

View File

@ -100,6 +100,8 @@ sub run {
my $oid_CpuLoad15m = '.1.3.6.1.4.1.2021.10.1.3.3';
my $result = $self->{snmp}->get_leef(oids => [$oid_CpuLoad1m, $oid_CpuLoad5m, $oid_CpuLoad15m], nothing_quit => 1);
my ($msg, $cpu_load1, $cpu_load5, $cpu_load15);
if (defined($self->{option_results}->{average})) {
my $result2 = $self->{snmp}->get_table(oid => $oid_CountCpu);
@ -112,47 +114,42 @@ sub run {
my $countCpu = scalar(keys %$result2);
my $avgCpuLoad1m = sprintf ("%0.2f", $result->{$oid_CpuLoad1m} / $countCpu);
my $avgCpuLoad5m = sprintf ("%0.2f", $result->{$oid_CpuLoad5m} / $countCpu);
my $avgCpuLoad15m = sprintf ("%0.2f", $result->{$oid_CpuLoad15m} / $countCpu);
my $exit1 = $self->{perfdata}->threshold_check(value => $avgCpuLoad1m,
threshold => [ { label => 'crit1', 'exit_litteral' => 'critical' }, { label => 'warn1', exit_litteral => 'warning' } ]);
my $exit2 = $self->{perfdata}->threshold_check(value => $avgCpuLoad5m,
threshold => [ { label => 'crit5', 'exit_litteral' => 'critical' }, { label => 'warn5', exit_litteral => 'warning' } ]);
my $exit3 = $self->{perfdata}->threshold_check(value => $avgCpuLoad15m,
threshold => [ { label => 'crit15', 'exit_litteral' => 'critical' }, { label => 'warn15', exit_litteral => 'warning' } ]);
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3 ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Load average: %s [%s/%s CPUs], %s [%s/%s CPUs], %s [%s/%s CPUs]", $avgCpuLoad1m, $result->{$oid_CpuLoad1m}, $countCpu,
$avgCpuLoad5m, $result->{$oid_CpuLoad5m}, $countCpu,
$avgCpuLoad15m, $result->{$oid_CpuLoad15m}, $countCpu));
$cpu_load1 = sprintf("%0.2f", $result->{$oid_CpuLoad1m} / $countCpu);
$cpu_load5 = sprintf("%0.2f", $result->{$oid_CpuLoad5m} / $countCpu);
$cpu_load15 = sprintf("%0.2f", $result->{$oid_CpuLoad15m} / $countCpu);
$msg = sprintf("Load average: %s [%s/%s CPUs], %s [%s/%s CPUs], %s [%s/%s CPUs]", $cpu_load1, $result->{$oid_CpuLoad1m}, $countCpu,
$cpu_load5, $result->{$oid_CpuLoad5m}, $countCpu,
$cpu_load15, $result->{$oid_CpuLoad15m}, $countCpu);
} else {
my $exit1 = $self->{perfdata}->threshold_check(value => $result->{$oid_CpuLoad1m},
threshold => [ { label => 'crit1', 'exit_litteral' => 'critical' }, { label => 'warn1', exit_litteral => 'warning' } ]);
my $exit2 = $self->{perfdata}->threshold_check(value => $result->{$oid_CpuLoad5m},
threshold => [ { label => 'crit5', 'exit_litteral' => 'critical' }, { label => 'warn5', exit_litteral => 'warning' } ]);
my $exit3 = $self->{perfdata}->threshold_check(value => $result->{$oid_CpuLoad15m},
threshold => [ { label => 'crit15', 'exit_litteral' => 'critical' }, { label => 'warn15', exit_litteral => 'warning' } ]);
$cpu_load1 = $result->{$oid_CpuLoad1m};
$cpu_load5 = $result->{$oid_CpuLoad5m};
$cpu_load15 = $result->{$oid_CpuLoad15m};
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3 ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Load average: %s, %s, %s", $result->{$oid_CpuLoad1m}, $result->{$oid_CpuLoad5m}, $result->{$oid_CpuLoad15m}));
$msg = sprintf("Load average: %s, %s, %s", $cpu_load1, $cpu_load5, $cpu_load15);
}
my $exit1 = $self->{perfdata}->threshold_check(value => $cpu_load1,
threshold => [ { label => 'crit1', 'exit_litteral' => 'critical' }, { label => 'warn1', exit_litteral => 'warning' } ]);
my $exit2 = $self->{perfdata}->threshold_check(value => $cpu_load5,
threshold => [ { label => 'crit5', 'exit_litteral' => 'critical' }, { label => 'warn5', exit_litteral => 'warning' } ]);
my $exit3 = $self->{perfdata}->threshold_check(value => $cpu_load15,
threshold => [ { label => 'crit15', 'exit_litteral' => 'critical' }, { label => 'warn15', exit_litteral => 'warning' } ]);
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3 ]);
$self->{output}->output_add(severity => $exit,
short_msg => $msg);
$self->{output}->perfdata_add(label => 'load1',
value => $result->{$oid_CpuLoad1m},
value => $cpu_load1,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn1'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1'),
min => 0);
$self->{output}->perfdata_add(label => 'load5',
value => $result->{$oid_CpuLoad5m},
value => $cpu_load5,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5'),
min => 0);
$self->{output}->perfdata_add(label => 'load15',
value => $result->{$oid_CpuLoad15m},
value => $cpu_load15,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn15'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit15'),
min => 0);