Skip to content

Commit

Permalink
Merge pull request #592 from cgagnaire/master
Browse files Browse the repository at this point in the history
Add raisecom plugin
  • Loading branch information
qgarnier committed Aug 10, 2017
2 parents 5530a6c + 8c64575 commit 4dabc51
Show file tree
Hide file tree
Showing 7 changed files with 675 additions and 0 deletions.
78 changes: 78 additions & 0 deletions network/raisecom/snmp/mode/components/fan.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#
# Copyright 2017 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::raisecom::snmp::mode::components::fan;

use strict;
use warnings;

my %map_fan_state = (
1 => 'normal',
2 => 'abnormal',
);

my $mapping = {
raisecomFanSpeedValue => { oid => '.1.3.6.1.4.1.8886.1.1.5.2.2.1.2' },
raisecomFanWorkState => { oid => '.1.3.6.1.4.1.8886.1.1.5.2.2.1.3', map => \%map_fan_state },
};
my $oid_raisecomFanMonitorStateEntry = '.1.3.6.1.4.1.8886.1.1.5.2.2.1';

sub load {
my ($self) = @_;

push @{$self->{request}}, { oid => $oid_raisecomFanMonitorStateEntry };
}

sub check {
my ($self) = @_;

$self->{output}->output_add(long_msg => "Checking fans");
$self->{components}->{fan} = {name => 'fan', total => 0, skip => 0};
return if ($self->check_filter(section => 'fan'));

foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raisecomFanMonitorStateEntry}})) {
next if ($oid !~ /^$mapping->{raisecomFanWorkState}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_raisecomFanMonitorStateEntry}, instance => $instance);

next if ($self->check_filter(section => 'fan', instance => $instance));

$self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance = %s]",
$instance, $result->{raisecomFanWorkState}, $instance));
my $exit = $self->get_severity(section => 'fan', value => $result->{raisecomFanWorkState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan '%s' status is '%s'", $instance, $result->{raisecomFanWorkState}));
}
my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'fan.speed', instance => $instance, value => $result->{raisecomFanSpeedValue});
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit2,
short_msg => sprintf("Fan speed '%s' is %s rpm", $instance, $result->{raisecomFanSpeedValue}));
$self->{output}->perfdata_add(label => 'fan_speed_' . $instance, unit => 'rpm',
value => $result->{raisecomFanSpeedValue},
warning => $warn,
critical => $crit,
);
}
}
}

1;
83 changes: 83 additions & 0 deletions network/raisecom/snmp/mode/components/temperature.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#
# Copyright 2017 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::raisecom::snmp::mode::components::temperature;

use strict;
use warnings;

my $mapping = {
raisecomTemperatureValue => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.1' },
raisecomTemperatureThresholdLow => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.5' },
raisecomTemperatureThresholdHigh => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.6' },
};
my $oid_raisecomTemperatureEntry = '.1.3.6.1.4.1.8886.1.1.4.2';

sub load {
my ($self) = @_;

push @{$self->{request}}, { oid => $oid_raisecomTemperatureEntry };
}

sub check {
my ($self) = @_;

$self->{output}->output_add(long_msg => "Checking temperatures");
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
return if ($self->check_filter(section => 'temperature'));

foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raisecomTemperatureEntry}})) {
next if ($oid !~ /^$mapping->{raisecomTemperatureValue}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_raisecomTemperatureEntry}, instance => $instance);

next if ($self->check_filter(section => 'temperature', instance => $instance));
$self->{components}->{temperature}->{total}++;

$self->{output}->output_add(long_msg => sprintf("temperature '%s' is %.2f C [instance: %s].",
$instance, $result->{raisecomTemperatureValue}, $instance
));

my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{raisecomTemperatureValue});
if ($checked == 0) {
my $warn_th = ':' . $result->{raisecomTemperatureThresholdLow};
my $crit_th = ':' . $result->{raisecomTemperatureThresholdHigh};
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th);
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th);

$exit = $self->{perfdata}->threshold_check(value => $result->{raisecomTemperatureValue}, threshold => [ { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' },
{ label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } ]);
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance);
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance);
}

if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Temperature '%s' is %.2f C", $instance, $result->{raisecomTemperatureValue}));
}
$self->{output}->perfdata_add(label => 'temp_' . $instance, unit => 'C',
value => $result->{raisecomTemperatureValue},
warning => $warn,
critical => $crit,
);
}
}

1;
83 changes: 83 additions & 0 deletions network/raisecom/snmp/mode/components/voltage.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#
# Copyright 2017 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::raisecom::snmp::mode::components::voltage;

use strict;
use warnings;

my $mapping = {
raisecomVoltValue => { oid => '.1.3.6.1.4.1.8886.1.1.4.3.1.1.3' },
raisecomVoltThresholdLow => { oid => '.1.3.6.1.4.1.8886.1.1.4.3.1.1.7' },
raisecomVoltThresholdHigh => { oid => '.1.3.6.1.4.1.8886.1.1.4.3.1.1.8' },
};
my $oid_raisecomVoltEntry = '.1.3.6.1.4.1.8886.1.1.4.3.1.1';

sub load {
my ($self) = @_;

push @{$self->{request}}, { oid => $oid_raisecomVoltEntry };
}

sub check {
my ($self) = @_;

$self->{output}->output_add(long_msg => "Checking voltages");
$self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0};
return if ($self->check_filter(section => 'voltage'));

foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raisecomVoltEntry}})) {
next if ($oid !~ /^$mapping->{raisecomVoltValue}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_raisecomVoltEntry}, instance => $instance);

next if ($self->check_filter(section => 'voltage', instance => $instance));
$self->{components}->{voltage}->{total}++;

$self->{output}->output_add(long_msg => sprintf("voltage '%s' is %.2f V [instance: %s].",
$instance, $result->{raisecomVoltValue}, $instance
));

my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{raisecomVoltValue});
if ($checked == 0) {
my $warn_th = ':' . $result->{raisecomVoltThresholdLow};
my $crit_th = ':' . $result->{raisecomVoltThresholdHigh};
$self->{perfdata}->threshold_validate(label => 'warning-voltage-instance-' . $instance, value => $warn_th);
$self->{perfdata}->threshold_validate(label => 'critical-voltage-instance-' . $instance, value => $crit_th);

$exit = $self->{perfdata}->threshold_check(value => $result->{raisecomVoltValue}, threshold => [ { label => 'critical-voltage-instance-' . $instance, exit_litteral => 'critical' },
{ label => 'warning-voltage-instance-' . $instance, exit_litteral => 'warning' } ]);
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-voltage-instance-' . $instance);
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-voltage-instance-' . $instance);
}

if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Voltage '%s' is %.2f V", $instance, $result->{raisecomVoltValue}));
}
$self->{output}->perfdata_add(label => 'volt_' . $instance, unit => 'V',
value => $result->{raisecomVoltValue},
warning => $warn,
critical => $crit,
);
}
}

1;
Loading

0 comments on commit 4dabc51

Please sign in to comment.