+ fix bluecoat issue
This commit is contained in:
parent
dc877d1da4
commit
0ba8eb1a16
|
@ -0,0 +1,81 @@
|
|||
#
|
||||
# Copyright 2015 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package network::bluecoat::mode::components::disk;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_status = (
|
||||
1 => 'present',
|
||||
2 => 'initializing',
|
||||
3 => 'inserted',
|
||||
4 => 'offline',
|
||||
5 => 'removed',
|
||||
6 => 'notpresent',
|
||||
7 => 'empty',
|
||||
8 => 'ioerror',
|
||||
9 => 'unusable',
|
||||
10 => 'unknown',
|
||||
);
|
||||
|
||||
# In MIB 'BLUECOAT-SG-DISK-MIB'
|
||||
my $mapping = {
|
||||
deviceDiskStatus => { oid => '.1.3.6.1.4.1.3417.2.2.1.1.1.1.3', map => \%map_status },
|
||||
deviceDiskSerialN => { oid => '.1.3.6.1.4.1.3417.2.2.1.1.1.1.8' },
|
||||
};
|
||||
my $oid_deviceDiskValueEntry = '.1.3.6.1.4.1.3417.2.2.1.1.1.1';
|
||||
|
||||
sub load {
|
||||
my (%options) = @_;
|
||||
|
||||
push @{$options{request}}, { oid => $oid_deviceDiskValueEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking disks");
|
||||
$self->{components}->{disk} = {name => 'disks', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'disk'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_deviceDiskValueEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{deviceSensorStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_deviceDiskValueEntry}, instance => $instance);
|
||||
|
||||
next if ($result->{deviceDiskStatus} !~ /notpresent/i &&
|
||||
$self->absent_problem(section => 'disk', instance => $instance));
|
||||
next if ($self->check_filter(section => 'disk', instance => $instance));
|
||||
$self->{components}->{disk}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Disk '%s' status is '%s' [instance: %s]",
|
||||
$result->{deviceDiskSerialN}, $result->{deviceDiskStatus},
|
||||
$instance));
|
||||
my $exit = $self->get_severity(section => 'disk', value => $result->{deviceDiskStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Sensor '%s' operational status is %s",
|
||||
$result->{deviceDiskSerialN}, $result->{deviceDiskStatus}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,121 @@
|
|||
#
|
||||
# Copyright 2015 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package network::bluecoat::mode::components::sensor;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_status = (
|
||||
1 => 'ok',
|
||||
2 => 'unavailable',
|
||||
3 => 'nonoperational',
|
||||
);
|
||||
my %map_code = (
|
||||
1 => 'ok',
|
||||
2 => 'unknown',
|
||||
3 => 'notInstalled',
|
||||
4 => 'voltageLowWarning',
|
||||
5 => 'voltageLowCritical',
|
||||
6 => 'noPower',
|
||||
7 => 'voltageHighWarning',
|
||||
8 => 'voltageHighCritical',
|
||||
9 => 'voltageHighSevere',
|
||||
10 => 'temperatureHighWarning',
|
||||
11 => 'temperatureHighCritical',
|
||||
12 => 'temperatureHighSevere',
|
||||
13 => 'fanSlowWarning',
|
||||
14 => 'fanSlowCritical',
|
||||
15 => 'fanStopped',
|
||||
);
|
||||
my %map_units = (
|
||||
1 => '', # other
|
||||
2 => '', # truthvalue
|
||||
3 => '', # specialEnum
|
||||
4 => 'V', # volts
|
||||
5 => 'C', # celsius
|
||||
6 => 'rpm'
|
||||
);
|
||||
|
||||
# In MIB 'BLUECOAT-SG-SENSOR-MIB'
|
||||
my $mapping = {
|
||||
deviceSensorUnits => { oid => '.1.3.6.1.4.1.3417.2.1.1.1.1.1.3', map => \%map_units },
|
||||
deviceSensorScale => { oid => '.1.3.6.1.4.1.3417.2.1.1.1.1.1.4' },
|
||||
deviceSensorValue => { oid => '.1.3.6.1.4.1.3417.2.1.1.1.1.1.5' },
|
||||
deviceSensorCode => { oid => '.1.3.6.1.4.1.3417.2.1.1.1.1.1.6', map => \%map_code },
|
||||
deviceSensorStatus => { oid => '.1.3.6.1.4.1.3417.2.1.1.1.1.1.7', map => \%map_status },
|
||||
deviceSensorName => { oid => '.1.3.6.1.4.1.3417.2.1.1.1.1.1.9' },
|
||||
};
|
||||
my $oid_deviceSensorValueEntry = '.1.3.6.1.4.1.3417.2.1.1.1.1.1';
|
||||
|
||||
sub load {
|
||||
my (%options) = @_;
|
||||
|
||||
push @{$options{request}}, { oid => $oid_deviceSensorValueEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking sensors");
|
||||
$self->{components}->{sensor} = {name => 'sensors', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'sensor'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_deviceSensorValueEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{deviceSensorStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_deviceSensorValueEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'sensor', instance => $instance));
|
||||
$self->{components}->{sensor}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Sensor '%s' status is '%s' [instance: %s, operational status: %s, value: %s, scale: %s, unit: %s]",
|
||||
$result->{deviceSensorName}, $result->{deviceSensorCode},
|
||||
$instance, $result->{deviceSensorStatus}, $result->{deviceSensorValue}, $result->{deviceSensorScale},
|
||||
$result->{deviceSensorUnits}));
|
||||
my $exit = $self->get_severity(section => 'sensor_opstatus', value => $result->{deviceSensorStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Sensor '%s' operational status is %s",
|
||||
$result->{deviceSensorName}, $result->{deviceSensorStatus}));
|
||||
}
|
||||
$exit = $self->get_severity(section => 'sensor', value => $result->{deviceSensorCode});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Sensor '%s' status is %s",
|
||||
$result->{deviceSensorName}, $result->{deviceSensorCode}));
|
||||
}
|
||||
|
||||
if (defined($result->{deviceSensorValue}) && $result->{deviceSensorValue} =~ /[0-9]/ && $result->{deviceSensorUnits} ne '') {
|
||||
my $value = ($result->{deviceSensorValue} * (10 ** $result->{deviceSensorScale}));
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'sensor', instance => $instance, value => $value);
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit2,
|
||||
short_msg => sprintf("Sensor '%s' value is %s %s", $result->{deviceSensorName}, $value, $result->{deviceSensorUnits}));
|
||||
}
|
||||
$self->{output}->perfdata_add(label => $result->{deviceSensorName}, unit => $result->{deviceSensorUnits},
|
||||
value => $value,
|
||||
warning => $warn,
|
||||
critical => $crit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -78,13 +78,19 @@ sub run {
|
|||
my $result = $self->{snmp}->get_table(oid => '.1.3.6.1.4.1.3417.2.11.2.4.1', nothing_quit => 1);
|
||||
$old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
|
||||
$new_datas->{last_timestamp} = time();
|
||||
for (my $i = 1; defined($result->{'.1.3.6.1.4.1.3417.2.11.2.4.1.3.' . $i}); $i++) {
|
||||
$new_datas->{'cpu_' . $i . '_busy'} = $result->{'.1.3.6.1.4.1.3417.2.11.2.4.1.3.' . $i};
|
||||
$new_datas->{'cpu_' . $i . '_idle'} = $result->{'.1.3.6.1.4.1.3417.2.11.2.4.1.4.' . $i};
|
||||
|
||||
my $oid_sgProxyCpuCoreBusyTime = '.1.3.6.1.4.1.3417.2.11.2.4.1.3';
|
||||
my $oid_sgProxyCpuCoreIdleTime = '.1.3.6.1.4.1.3417.2.11.2.4.1.4';
|
||||
my $i = 0;
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$result})) {
|
||||
next if ($oid !~ /^$oid_sgProxyCpuCoreBusyTime\.(\d+)/);
|
||||
my $instance = $1;
|
||||
|
||||
if (!defined($old_timestamp)) {
|
||||
next;
|
||||
}
|
||||
$i++;
|
||||
$new_datas->{'cpu_' . $i . '_busy'} = $result->{$oid};
|
||||
$new_datas->{'cpu_' . $i . '_idle'} = $result->{$oid_sgProxyCpuCoreIdleTime . '.' . $instance};
|
||||
|
||||
next if (!defined($old_timestamp));
|
||||
|
||||
my $old_cpu_busy = $self->{statefile_value}->get(name => 'cpu_' . $i . '_busy');
|
||||
my $old_cpu_idle = $self->{statefile_value}->get(name => 'cpu_' . $i . '_idle');
|
||||
|
|
|
@ -61,13 +61,16 @@ sub run {
|
|||
|
||||
my $disk_num = 1;
|
||||
my $result = $self->{snmp}->get_table(oid => '.1.3.6.1.4.1.3417.2.4.1.1.1');
|
||||
for (my $i = 1; defined($result->{'.1.3.6.1.4.1.3417.2.4.1.1.1.3.' . $i}); $i++) {
|
||||
if ($result->{'.1.3.6.1.4.1.3417.2.4.1.1.1.3.' . $i} !~ /^DISK$/i) {
|
||||
next;
|
||||
}
|
||||
my $oid_deviceUsageName = '.1.3.6.1.4.1.3417.2.4.1.1.1.3';
|
||||
my $oid_deviceUsagePercent = '.1.3.6.1.4.1.3417.2.4.1.1.1.4';
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$result})) {
|
||||
next if ($oid !~ /^$oid_deviceUsageName\.(\d+)/);
|
||||
my $instance = $1;
|
||||
next if ($result->{$oid} !~ /^DISK/i);
|
||||
|
||||
my $disk_usage = $result->{'.1.3.6.1.4.1.3417.2.4.1.1.1.4.' . $i};
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $disk_usage, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
my $disk_usage = $result->{$oid_deviceUsagePercent . '.' . $instance};
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $disk_usage, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Disk $disk_num usage is %.2f%%", $disk_usage));
|
||||
$self->{output}->perfdata_add(label => 'disk_' . $disk_num, unit => '%',
|
||||
|
|
|
@ -24,39 +24,44 @@ use base qw(centreon::plugins::mode);
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
|
||||
my %device_status_msg = (2 => "unaivalable", 3 => "non operationnal");
|
||||
my %device_units = (
|
||||
1 => '', # other
|
||||
2 => '', # truthvalue
|
||||
3 => '', # specialEnum
|
||||
4 => 'volts',
|
||||
5 => 'celsius',
|
||||
6 => 'rpm'
|
||||
);
|
||||
my %device_code = (
|
||||
1 => ["The device sensor '%s' is ok", 'OK'], 2 => ["The device sensor '%s' is unknown", 'UNKNOWN'], 3 => ["The device sensor '%s' is not installed", 'UNKNOWN'],
|
||||
4 => ["The device sensor '%s' has a low voltage", 'WARNING'], 5 => ["The device sensor '%s' has a low voltage", 'CRITICAL'],
|
||||
6 => ["The device sensor '%s' has no power", 'CRITICAL'],
|
||||
7 => ["The device sensor '%s' has a high voltage", 'WARNING'],
|
||||
8 => ["The device sensor '%s' has a high voltage", 'CRITICAL'],
|
||||
9 => ["The device sensor '%s' has a very (!!!) high voltage", 'CRITICAL'],
|
||||
10 => ["The device sensor '%s' has a high temperature", 'WARNING'],
|
||||
11 => ["The device sensor '%s' has a high temperature", 'CRITICAL'],
|
||||
12 => ["The device sensor '%s' has a very high (!!!) temperature", 'CRITICAL'],
|
||||
13 => ["The fan '%s' is slow", 'WARNING'],
|
||||
14 => ["The fan '%s' is slow", 'CRITICAL'],
|
||||
15 => ["The fan '%s' is stopped", 'CRITICAL'],
|
||||
);
|
||||
my %disk_status = (
|
||||
1 => ["Disk '%s' is present", 'OK'], 2 => ["Disk '%s' is initializing", 'OK'], 3 => ["Disk '%s' is inserted", 'OK'],
|
||||
4 => ["Disk '%s' is offline", 'WARNING'], 5 => ["Disk '%s' is removed", 'WARNING'],
|
||||
6 => ["Disk '%s' is not present", 'WARNING'],
|
||||
7 => ["Disk '%s' is empty", 'WARNING'],
|
||||
8 => ["Disk '%s' has io errors", 'CRITICAL'],
|
||||
9 => ["Disk '%s' is unusable", 'CRITICAL'],
|
||||
10 => ["Disk status '%s' is unknown", 'UNKNOWN'],
|
||||
);
|
||||
my $thresholds = {
|
||||
sensor_opstatus => [
|
||||
['ok', 'OK'],
|
||||
['unavailable', 'UNKNOWN'],
|
||||
['nonoperational', 'UNKNOWN'],
|
||||
],
|
||||
sensor => [
|
||||
['ok', 'OK'],
|
||||
['unknown', 'UNKNOWN'],
|
||||
['nonInstalled', 'OK'],
|
||||
['voltageLowWarning', 'WARNING'],
|
||||
['voltageLowCritical', 'CRITICAL'],
|
||||
['noPower', 'CRITICAL'],
|
||||
['voltageHighWarning', 'WARNING'],
|
||||
['voltageHighCritical', 'CRITICAL'],
|
||||
['voltageHighSevere', 'CRITICAL'],
|
||||
['temperatureHighWarning', 'WARNING'],
|
||||
['temperatureHighCritical', 'CRITICAL'],
|
||||
['temperatureHighSevere', 'CRITICAL'],
|
||||
['fanSlowWarning', 'WARNING'],
|
||||
['fanSlowCritical', 'CRITICAL'],
|
||||
['fanStopped', 'CRITICAL'],
|
||||
],
|
||||
disk => [
|
||||
['present', 'OK'],
|
||||
['initializing', 'OK'],
|
||||
['inserted', 'OK'],
|
||||
['offline', 'WARNING'],
|
||||
['removed', 'WARNING'],
|
||||
['notpresent', 'OK'],
|
||||
['empty', 'WARNING'],
|
||||
['ioerror', 'CRITICAL'],
|
||||
['unusable', 'CRITICAL'],
|
||||
['unknown', 'UNKNOWN'],
|
||||
],
|
||||
};
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
|
@ -66,86 +71,285 @@ sub new {
|
|||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"skip" => { name => 'skip' },
|
||||
"filter:s@" => { name => 'filter' },
|
||||
"absent-problem:s@" => { name => 'absent_problem' },
|
||||
"component:s" => { name => 'component', default => '.*' },
|
||||
"no-component:s" => { name => 'no_component' },
|
||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||
"warning:s@" => { name => 'warning' },
|
||||
"critical:s@" => { name => 'critical' },
|
||||
});
|
||||
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (defined($self->{option_results}->{no_component})) {
|
||||
if ($self->{option_results}->{no_component} ne '') {
|
||||
$self->{no_components} = $self->{option_results}->{no_component};
|
||||
} else {
|
||||
$self->{no_components} = 'critical';
|
||||
}
|
||||
}
|
||||
|
||||
$self->{filter} = [];
|
||||
foreach my $val (@{$self->{option_results}->{filter}}) {
|
||||
next if (!defined($val) || $val eq '');
|
||||
my @values = split (/,/, $val);
|
||||
push @{$self->{filter}}, { filter => $values[0], instance => $values[1] };
|
||||
}
|
||||
|
||||
$self->{absent_problem} = [];
|
||||
foreach my $val (@{$self->{option_results}->{absent_problem}}) {
|
||||
next if (!defined($val) || $val eq '');
|
||||
my @values = split (/,/, $val);
|
||||
push @{$self->{absent_problem}}, { filter => $values[0], instance => $values[1] };
|
||||
}
|
||||
|
||||
$self->{overload_th} = {};
|
||||
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
|
||||
next if (!defined($val) || $val eq '');
|
||||
my @values = split (/,/, $val);
|
||||
if (scalar(@values) < 3) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my ($section, $instance, $status, $filter);
|
||||
if (scalar(@values) == 3) {
|
||||
($section, $status, $filter) = @_;
|
||||
$instance = '.*';
|
||||
} else {
|
||||
($section, $instance, $status, $filter) = @_;
|
||||
}
|
||||
if ($section !~ /^sensor$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wronghreshold-overload section '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if ($self->{output}->is_litteral_status(status => $status) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
|
||||
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status, instance => $instance };
|
||||
}
|
||||
|
||||
$self->{numeric_threshold} = {};
|
||||
foreach my $option (('warning', 'critical')) {
|
||||
foreach my $val (@{$self->{option_results}->{$option}}) {
|
||||
next if (!defined($val) || $val eq '');
|
||||
if ($val !~ /^(.*?),(.*?),(.*)$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my ($section, $instance, $value) = ($1, $2, $3);
|
||||
if ($section !~ /^sensor$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my $position = 0;
|
||||
if (defined($self->{numeric_threshold}->{$section})) {
|
||||
$position = scalar(@{$self->{numeric_threshold}->{$section}});
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section}));
|
||||
push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, instance => $instance };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "All disks and sensors are ok.");
|
||||
|
||||
my $oid_DeviceSensorValueEntry = '.1.3.6.1.4.1.3417.2.1.1.1.1.1';
|
||||
my $result = $self->{snmp}->get_table(oid => $oid_DeviceSensorValueEntry, nothing_quit => 1);
|
||||
|
||||
for (my $i = 0; defined($result->{'.1.3.6.1.4.1.3417.2.1.1.1.1.1.9.' . $i}); $i++) {
|
||||
my $sensor_name = $result->{'.1.3.6.1.4.1.3417.2.1.1.1.1.1.9.' . $i};
|
||||
my $sensor_status = $result->{'.1.3.6.1.4.1.3417.2.1.1.1.1.1.7.' . $i};
|
||||
my $sensor_units = $result->{'.1.3.6.1.4.1.3417.2.1.1.1.1.1.3.' . $i};
|
||||
my $sensor_code = $result->{'.1.3.6.1.4.1.3417.2.1.1.1.1.1.4.' . $i};
|
||||
my $sensor_value = $result->{'.1.3.6.1.4.1.3417.2.1.1.1.1.1.5.' . $i};
|
||||
my $sensor_scale = $result->{'.1.3.6.1.4.1.3417.2.1.1.1.1.1.4.' . $i};
|
||||
|
||||
$self->{output}->output_add(long_msg => "Device sensor '" . $sensor_name . "' status = '" . $sensor_status . "', code = '" . $sensor_code . "'");
|
||||
|
||||
# Check 'nonoperationnal' and 'unavailable'
|
||||
if ($sensor_status == 2 || $sensor_status == 3) {
|
||||
if (!defined($self->{option_results}->{skip})) {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => "Device sensor '" . $sensor_name . "' is " . $sensor_status);
|
||||
}
|
||||
next;
|
||||
|
||||
my $snmp_request = [];
|
||||
my @components = ('sensor', 'disk');
|
||||
foreach (@components) {
|
||||
if (/$self->{option_results}->{component}/) {
|
||||
my $mod_name = "network::bluecoat::mode::components::$_";
|
||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name,
|
||||
error_msg => "Cannot load module '$mod_name'.");
|
||||
my $func = $mod_name->can('load');
|
||||
$func->(request => $snmp_request);
|
||||
}
|
||||
|
||||
if ($sensor_code != 1) {
|
||||
$self->{output}->output_add(severity => ${$device_code{$sensor_code}}[1],
|
||||
short_msg => sprintf(${$device_code{$sensor_code}}[0], $sensor_name));
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(label => $sensor_name, unit => $device_units{sensor_units},
|
||||
value => ($sensor_value * (10 ** $sensor_scale)));
|
||||
}
|
||||
|
||||
$result = $self->{snmp}->get_table(oid => '.1.3.6.1.4.1.3417.2.2.1.1.1.1');
|
||||
for (my $i = 0; defined($result->{'.1.3.6.1.4.1.3417.2.2.1.1.1.1.8.' . $i}); $i++) {
|
||||
my $disk_serial = $result->{'.1.3.6.1.4.1.3417.2.2.1.1.1.1.8.' . $i};
|
||||
my $disk_status = $result->{'.1.3.6.1.4.1.3417.2.2.1.1.1.1.3.' . $i};
|
||||
|
||||
if ($disk_status > 3) {
|
||||
$self->{output}->output_add(severity => ${$disk_status{$disk_status}}[1],
|
||||
short_msg => sprintf(${$disk_status{$disk_status}}[0], $disk_serial));
|
||||
if (scalar(@{$snmp_request}) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request);
|
||||
|
||||
foreach (@components) {
|
||||
if (/$self->{option_results}->{component}/) {
|
||||
my $mod_name = "network::bluecoat::mode::components::$_";
|
||||
my $func = $mod_name->can('check');
|
||||
$func->($self);
|
||||
}
|
||||
$self->{output}->output_add(long_msg => sprintf(${$disk_status{$disk_status}}[0], $disk_serial));
|
||||
}
|
||||
|
||||
my $total_components = 0;
|
||||
my $display_by_component = '';
|
||||
my $display_by_component_append = '';
|
||||
foreach my $comp (sort(keys %{$self->{components}})) {
|
||||
# Skipping short msg when no components
|
||||
next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
|
||||
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name};
|
||||
$display_by_component_append = ', ';
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %s components are ok [%s].",
|
||||
$total_components,
|
||||
$display_by_component)
|
||||
);
|
||||
|
||||
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
|
||||
$self->{output}->output_add(severity => $self->{no_components},
|
||||
short_msg => 'No components are checked.');
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub absent_problem {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (@{$self->{absent_problem}}) {
|
||||
if ($options{section} =~ /$_->{filter}/) {
|
||||
if (!defined($_->{instance}) || $options{instance} =~ /$_->{instance}/) {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("Component '%s' instance '%s' is not present",
|
||||
$options{section}, $options{instance}));
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance (not present)"));
|
||||
$self->{components}->{$options{section}}->{skip}++;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub check_filter {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (@{$self->{filter}}) {
|
||||
if ($options{section} =~ /$_->{filter}/) {
|
||||
if (!defined($options{instance}) && !defined($_->{instance})) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
|
||||
return 1;
|
||||
} elsif (defined($options{instance}) && $options{instance} =~ /$_->{instance}/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub get_severity_numeric {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'OK'; # default
|
||||
my $thresholds = { warning => undef, critical => undef };
|
||||
my $checked = 0;
|
||||
|
||||
if (defined($self->{numeric_threshold}->{$options{section}})) {
|
||||
my $exits = [];
|
||||
foreach (@{$self->{numeric_threshold}->{$options{section}}}) {
|
||||
if ($options{instance} =~ /$_->{instance}/) {
|
||||
push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]);
|
||||
$thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label});
|
||||
$checked = 1;
|
||||
}
|
||||
}
|
||||
$status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0);
|
||||
}
|
||||
|
||||
return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked);
|
||||
}
|
||||
|
||||
sub get_severity {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'UNKNOWN'; # default
|
||||
|
||||
if (defined($self->{overload_th}->{$options{section}})) {
|
||||
foreach (@{$self->{overload_th}->{$options{section}}}) {
|
||||
if ($options{value} =~ /$_->{filter}/i) {
|
||||
$status = $_->{status};
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
}
|
||||
my $label = defined($options{label}) ? $options{label} : $options{section};
|
||||
foreach (@{$thresholds->{$label}}) {
|
||||
if ($options{value} =~ /$$_[0]/i) {
|
||||
$status = $$_[1];
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check bluecoat hardware sensors and disks.
|
||||
Check Hardware (Sensors, Disks).
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--skip>
|
||||
=item B<--component>
|
||||
|
||||
Skip 'nonoperationnal' and 'unavailable' sensors.
|
||||
Which component to check (Default: '.*').
|
||||
Can be: 'sensor', 'disk'.
|
||||
|
||||
=item B<--filter>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --filter=disk --filter=sensor)
|
||||
Can also exclude specific instance: --filter=rmsVoltage,I1
|
||||
|
||||
=item B<--absent-problem>
|
||||
|
||||
Return an error if an entity is not 'present' (default is skipping) (comma seperated list)
|
||||
Can be specific or global: --absent-problem=disk,1
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
Return an error if no compenents are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=item B<--threshold-overload>
|
||||
|
||||
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
|
||||
It used before default thresholds (order stays).
|
||||
Example: --threshold-overload='sensor,CRITICAL,^(?!(ok)$)'
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Set warning threshold for temperatures (syntax: type,instance,threshold)
|
||||
Example: --warning='sensor,.*,30'
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Set critical threshold for temperatures (syntax: type,instance,threshold)
|
||||
Example: --critical='sensor,.*,40'
|
||||
=back
|
||||
|
||||
=cut
|
||||
=cut
|
Loading…
Reference in New Issue