Mikrotik Implementation (#1077)

* Added Mikrotik support, including cpu and memory. Others still in dev

* Added signal to noise, ssid, temps, voltages, frequencies and signal stength for mikrotik devices

* Small fi

* Signal Fix

* QA testing

* Added messages to frequenct and ssid

* Fixed values for signals

* Forgot semi-colon

* Added CPU specific temps to mikrotik temperatures

* Added warnings and criticals for mikrotik

* Delete .gitignore

Must be removed for pull request

* undoing change for different pull request

* Restructured mikrotik for pull request

* Removed head elements for memory swap mikrotik

* Added mode type to signals

* Changing temperatures for hardware and adding fan component

* Changing voltage for hardware and adding fan component

* Added fan component to hardware mode and fixed heads for parameters

* fix mikrotik pluin
This commit is contained in:
Luc Fauvel 2018-12-11 07:51:59 -05:00 committed by Colin Gagnaire
parent 63732422cc
commit 605d55d8ec
11 changed files with 1044 additions and 0 deletions

View File

@ -0,0 +1,66 @@
#
# Copyright 2018 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::mikrotik::snmp::mode::components::current;
use strict;
use warnings;
my $mapping = {
mtxrHlCurrent => { oid => '.1.3.6.1.4.1.14988.1.1.3.13' },
};
my $oid_mtxrHealth = '.1.3.6.1.4.1.14988.1.1.3';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_mtxrHealth };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking current");
$self->{components}->{current} = {name => 'current', total => 0, skip => 0};
return if ($self->check_filter(section => 'current'));
my $instance = 0;
my ($exit, $warn, $crit, $checked);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_mtxrHealth}, instance => $instance);
if (defined($result->{mtxrHlCurrent}) && $result->{mtxrHlCurrent} =~ /[0-9]+/) {
$self->{output}->output_add(long_msg => sprintf("Current is '%s' A", $result->{mtxrHlCurrent} / 100));
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'current', instance => $instance, value => $result->{mtxrHlCurrent} / 100);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Current is '%s' A", $result->{mtxrHlCurrent} / 100));
}
$self->{output}->perfdata_add(label => 'current', unit => 'A',
value => $result->{mtxrHlCurrent} / 100,
warning => $warn,
critical => $crit);
$self->{components}->{current}->{total}++;
}
}
1;

View File

@ -0,0 +1,82 @@
#
# Copyright 2018 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::mikrotik::snmp::mode::components::fan;
use strict;
use warnings;
my $mapping = {
mtxrHlFanSpeed1 => { oid => '.1.3.6.1.4.1.14988.1.1.3.17' },
mtxrHlFanSpeed2 => { oid => '.1.3.6.1.4.1.14988.1.1.3.18' },
};
my $oid_mtxrHealth = '.1.3.6.1.4.1.14988.1.1.3';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_mtxrHealth };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking fans");
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
return if ($self->check_filter(section => 'fan'));
my $instance = 0;
my ($exit, $warn, $crit, $checked);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_mtxrHealth}, instance => $instance);
if (defined($result->{mtxrHlFanSpeed1}) && $result->{mtxrHlFanSpeed1} =~ /[0-9]+/) {
$self->{output}->output_add(long_msg => sprintf("Fan '1' speed is '%s' RPM", $result->{mtxrHlFanSpeed1}));
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => '1', value => $result->{mtxrHlFanSpeed1});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan '1' speed is '%s' RPM", $result->{mtxrHlFanSpeed1}));
}
$self->{output}->perfdata_add(label => 'fan_speed_1', unit => 'RPM',
value => $result->{mtxrHlFanSpeed1},
warning => $warn,
critical => $crit);
$self->{components}->{fan}->{total}++;
}
if (defined($result->{mtxrHlFanSpeed2}) && $result->{mtxrHlFanSpeed2} =~ /[0-9]+/) {
$self->{output}->output_add(long_msg => sprintf("Fan '2' speed is '%s' RPM", $result->{mtxrHlFanSpeed2}));
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => '2', value => $result->{mtxrHlFanSpeed2});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan '2' speed is '%s' RPM", $result->{mtxrHlFanSpeed2}));
}
$self->{output}->perfdata_add(label => 'fan_speed_2', unit => 'RPM',
value => $result->{mtxrHlFanSpeed2},
warning => $warn,
critical => $crit);
$self->{components}->{fan}->{total}++;
}
}
1;

View File

@ -0,0 +1,66 @@
#
# Copyright 2018 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::mikrotik::snmp::mode::components::power;
use strict;
use warnings;
my $mapping = {
mtxrHlPower => { oid => '.1.3.6.1.4.1.14988.1.1.3.12' },
};
my $oid_mtxrHealth = '.1.3.6.1.4.1.14988.1.1.3';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_mtxrHealth };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking power");
$self->{components}->{power} = {name => 'power', total => 0, skip => 0};
return if ($self->check_filter(section => 'power'));
my $instance = 0;
my ($exit, $warn, $crit, $checked);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_mtxrHealth}, instance => $instance);
if (defined($result->{mtxrHlPower}) && $result->{mtxrHlPower} =~ /[0-9]+/) {
$self->{output}->output_add(long_msg => sprintf("Power is '%s' W", $result->{mtxrHlPower}));
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'power', instance => $instance, value => $result->{mtxrHlPower});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power is '%s' W", $result->{mtxrHlPower}));
}
$self->{output}->perfdata_add(label => 'power', unit => 'W',
value => $result->{mtxrHlPower},
warning => $warn,
critical => $crit);
$self->{components}->{power}->{total}++;
}
}
1;

View File

@ -0,0 +1,82 @@
#
# Copyright 2018 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::mikrotik::snmp::mode::components::temperature;
use strict;
use warnings;
my $mapping = {
mtxrHlTemperature => { oid => '.1.3.6.1.4.1.14988.1.1.3.10' },
mtxrHlProcessorTemperature => { oid => '.1.3.6.1.4.1.14988.1.1.3.11' },
};
my $oid_mtxrHealth = '.1.3.6.1.4.1.14988.1.1.3';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_mtxrHealth };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking temperature");
$self->{components}->{temperature} = {name => 'temperature', total => 0, skip => 0};
return if ($self->check_filter(section => 'temperature'));
my $instance = 0;
my ($exit, $warn, $crit, $checked);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_mtxrHealth}, instance => $instance);
if (defined($result->{mtxrHlTemperature}) && $result->{mtxrHlTemperature} =~ /[0-9]+/) {
$self->{output}->output_add(long_msg => sprintf("Temperature is '%s' C", $result->{mtxrHlTemperature} / 10));
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => '1', value => $result->{mtxrHlTemperature} / 10);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Temperature is '%s' C", $result->{mtxrHlTemperature} / 10));
}
$self->{output}->perfdata_add(label => 'temperature', unit => 'C',
value => $result->{mtxrHlTemperature} / 10,
warning => $warn,
critical => $crit);
$self->{components}->{temperature}->{total}++;
}
if (defined($result->{mtxrHlProcessorTemperature}) && $result->{mtxrHlProcessorTemperature} =~ /[0-9]+/) {
$self->{output}->output_add(long_msg => sprintf("Processor temperature is '%s' C", $result->{mtxrHlProcessorTemperature} / 10));
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => '2', value => $result->{mtxrHlProcessorTemperature} / 10);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Processor temperature is '%s' C", $result->{mtxrHlProcessorTemperature} / 10));
}
$self->{output}->perfdata_add(label => 'temperature_processor', unit => 'C',
value => $result->{mtxrHlProcessorTemperature} / 10,
warning => $warn,
critical => $crit);
$self->{components}->{temperature}->{total}++;
}
}
1;

View File

@ -0,0 +1,66 @@
#
# Copyright 2018 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::mikrotik::snmp::mode::components::voltage;
use strict;
use warnings;
my $mapping = {
mtxrHlVoltage => { oid => '.1.3.6.1.4.1.14988.1.1.3.8' },
};
my $oid_mtxrHealth = '.1.3.6.1.4.1.14988.1.1.3';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_mtxrHealth };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking voltage");
$self->{components}->{voltage} = {name => 'voltage', total => 0, skip => 0};
return if ($self->check_filter(section => 'voltage'));
my $instance = 0;
my ($exit, $warn, $crit, $checked);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_mtxrHealth}, instance => $instance);
if (defined($result->{mtxrHlVoltage}) && $result->{mtxrHlVoltage} =~ /[0-9]+/) {
$self->{output}->output_add(long_msg => sprintf("Voltage is '%s' V", $result->{mtxrHlVoltage} / 10));
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{mtxrHlVoltage} / 10);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Voltage is '%s' V", $result->{mtxrHlVoltage} / 10));
}
$self->{output}->perfdata_add(label => 'voltage', unit => 'V',
value => $result->{mtxrHlVoltage} / 10,
warning => $warn,
critical => $crit);
$self->{components}->{voltage}->{total}++;
}
}
1;

View File

@ -0,0 +1,102 @@
#
# Copyright 2018 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::mikrotik::snmp::mode::environment;
use base qw(centreon::plugins::templates::hardware);
use strict;
use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|voltage|fan|current|power)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{components_path} = 'network::mikrotik::snmp::mode::components';
$self->{components_module} = ['current', 'fan', 'power', 'temperature', 'voltage'];
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
1;
__END__
=head1 MODE
Check hardware.
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'voltage', 'temperature', 'fan'.
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=fan --filter=voltage)
Can also exclude specific instance: --filter=fan,1.1
=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=fan,1
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--warning>
Set warning threshold for 'temperature', 'fan', 'voltage' (syntax: type,regexp,threshold)
Example: --warning='temperature,.*,40'
=item B<--critical>
Set critical threshold for 'temperature', 'fan', 'voltage' (syntax: type,regexp,threshold)
Example: --critical='temperature,.*,50'
=back
=cut

View File

@ -0,0 +1,113 @@
#
# Copyright 2018 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::mikrotik::snmp::mode::listfrequencies;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"oid-filter:s" => { name => 'oid_filter', default => 'ifname' },
"oid-display:s" => { name => 'oid_display', default => 'ifname' },
});
$self->{oids_label} = {
'ifdesc' => '.1.3.6.1.2.1.2.2.1.2',
'ifalias' => '.1.3.6.1.2.1.31.1.1.1.18',
'ifname' => '.1.3.6.1.2.1.31.1.1.1.1',
};
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
sub run {
my ($self, %options) = @_;
my $oids = [{ oid => $self->{oids_label}->{'ifname'} }];
$self->{snmp} = $options{snmp};
my $interfaceTables = $self->{snmp}->get_multiple_table(oids => $oids);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %{$interfaceTables->{ $self->{oids_label}->{'ifname'} }})) {
next if ($key !~ /^$self->{oids_label}->{'ifname'}\.(.*)$/);
$self->{datas}->{'ifname' . "_" . $1} = $self->{output}->to_utf8($interfaceTables->{$self->{oids_label}->{'ifname'} }->{$key});
push @{$self->{datas}->{all_ids}}, $1;
}
if (scalar(@{$self->{datas}->{all_ids}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "Can't get interfaces...");
$self->{output}->option_exit();
}
if (scalar(@{$self->{datas}->{all_ids}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No entry found");
$self->{output}->option_exit();
}
my $mktFrequenOid = '.1.3.6.1.4.1.14988.1.1.1.3.1.7.';
foreach (sort @{$self->{datas}->{all_ids}}) {
my $display_value = $self->get_display_value(id => $_);
my $oid = $mktFrequenOid . $_;
my $snmp_result = $options{snmp}->get_leef(oids => [$oid]);
if(defined($snmp_result->{$oid})){
$self->{output}->output_add(long_msg => $display_value . " : " . $snmp_result->{$oid} . " Mhz");
}
}
$self->{output}->output_add(severity => 'OK',
short_msg => 'Frequencies:');
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
sub get_display_value {
my ($self, %options) = @_;
my $value = $self->{datas}->{"ifname_" . $options{id}};
return $value;
}
1;
__END__
=head1 MODE
List frequencies for each interface.
=over 8
=cut

View File

@ -0,0 +1,113 @@
#
# Copyright 2018 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::mikrotik::snmp::mode::listssids;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"oid-filter:s" => { name => 'oid_filter', default => 'ifname' },
"oid-display:s" => { name => 'oid_display', default => 'ifname' },
});
$self->{oids_label} = {
'ifdesc' => '.1.3.6.1.2.1.2.2.1.2',
'ifalias' => '.1.3.6.1.2.1.31.1.1.1.18',
'ifname' => '.1.3.6.1.2.1.31.1.1.1.1',
};
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
sub run {
my ($self, %options) = @_;
my $oids = [{ oid => $self->{oids_label}->{'ifname'} }];
$self->{snmp} = $options{snmp};
my $interfaceTables = $self->{snmp}->get_multiple_table(oids => $oids);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %{$interfaceTables->{ $self->{oids_label}->{'ifname'} }})) {
next if ($key !~ /^$self->{oids_label}->{'ifname'}\.(.*)$/);
$self->{datas}->{'ifname' . "_" . $1} = $self->{output}->to_utf8($interfaceTables->{$self->{oids_label}->{'ifname'} }->{$key});
push @{$self->{datas}->{all_ids}}, $1;
}
if (scalar(@{$self->{datas}->{all_ids}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "Can't get interfaces...");
$self->{output}->option_exit();
}
if (scalar(@{$self->{datas}->{all_ids}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No entry found");
$self->{output}->option_exit();
}
my $mktFrequenOid = '.1.3.6.1.4.1.14988.1.1.1.3.1.4';
foreach (sort @{$self->{datas}->{all_ids}}) {
my $display_value = $self->get_display_value(id => $_);
my $oid = $mktFrequenOid . $_;
my $snmp_result = $options{snmp}->get_leef(oids => [$oid]);
if(defined($snmp_result->{$oid})){
$self->{output}->output_add(long_msg => $display_value . " : " . $snmp_result->{$oid});
}
}
$self->{output}->output_add(severity => 'OK',
short_msg => 'SSIDs:');
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
sub get_display_value {
my ($self, %options) = @_;
my $value = $self->{datas}->{"ifname_" . $options{id}};
return $value;
}
1;
__END__
=head1 MODE
List SSIDs for each interface.
=over 8
=cut

View File

@ -0,0 +1,104 @@
#
# Copyright 2018 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::mikrotik::snmp::mode::memory;
use base qw(snmp_standard::mode::storage);
use strict;
use warnings;
sub default_storage_type {
my ($self, %options) = @_;
return '^(hrStorageRam|hrStorageFlashMemory)';
}
sub prefix_storage_output {
my ($self, %options) = @_;
return "RAM '" . $options{instance_value}->{display} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
return $self;
}
1;
__END__
=head1 MODE
Check memory.
=over 8
=item B<--warning-usage>
Threshold warning.
=item B<--critical-usage>
Threshold critical.
=item B<--units>
Units of thresholds (Default: '%') ('%', 'B').
=item B<--free>
Thresholds are on free space left.
=item B<--storage>
Set the storage (number expected) ex: 1, 2,... (empty means 'check all storage').
=item B<--name>
Allows to use storage name with option --storage instead of storage oid index.
=item B<--regexp>
Allows to use regexp to filter storage (with option --name).
=item B<--regexp-isensitive>
Allows to use regexp non case-sensitive (with --regexp).
=item B<--reload-cache-time>
Time in minutes before reloading cache file (default: 180).
=item B<--show-cache>
Display cache storage datas.
=item B<--filter-storage-type>
Filter storage types with a regexp (Default: '^(hrStorageRam|hrStorageFlashMemory)$').
=back
=cut

View File

@ -0,0 +1,195 @@
#
# Copyright 2018 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::mikrotik::snmp::mode::signal;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'signalstrength', type => 1, cb_prefix_output => 'prefix_mac_output', message_multiple => 'All signals are ok' },
{ name => 'signalnoise', type => 1, cb_prefix_output => 'prefix_mac_output', message_multiple => 'All signals are ok' }
];
$self->{maps_counters}->{signalstrength} = [
{ label => 'rx-strength', set => {
key_values => [ { name => 'rx' }, { name => 'display' } ],
output_template => 'Signal Strength Rx : %s',
perfdatas => [
{ label => 'signal_rx', value => 'rx_absolute', template => '%s',
min => -90, max => -20, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'tx-strength', set => {
key_values => [ { name => 'tx' }, { name => 'display' } ],
output_template => 'Signal Strength Tx : %s',
perfdatas => [
{ label => 'signal_tx', value => 'tx_absolute', template => '%s',
min => -90, max => -20, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
}
];
$self->{maps_counters}->{signalnoise} = [
{ label => 'signal2noise', set => {
key_values => [ { name => 'regs2n' }, { name => 'display' } ],
output_template => 'Signal To Noise : %s',
perfdatas => [
{ label => 'signal_noise', value => 'regs2n_absolute', template => '%s',
min => 20, max => 80, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"strength" => { name => "strength" },
"noise" => { name => "noise" }
});
return $self;
}
sub prefix_mac_output {
my ($self, %options) = @_;
return "MAC '" . $options{instance_value}->{display} . "' ";
}
my $mapping = {
regmac => { oid => '.1.3.6.1.4.1.14988.1.1.1.2.1.1' },
rx => { oid => '.1.3.6.1.4.1.14988.1.1.1.2.1.3' },
tx => { oid => '.1.3.6.1.4.1.14988.1.1.1.2.1.19' },
regs2n => { oid => '.1.3.6.1.4.1.14988.1.1.1.2.1.12' },
};
sub manage_selection {
my ($self, %options) = @_;
if ($options{snmp}->is_snmpv1()) {
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
$self->{output}->option_exit();
}
my $oids = [ $mapping->{regmac} ];
if(defined($self->{option_results}->{strength})){
push @{$oids}, ($mapping->{rx}, $mapping->{tx});
}
if(defined($self->{option_results}->{noise})){
push @{$oids}, $mapping->{regs2n};
}
$self->{snmp} = $options{snmp};
$self->{signalstrength} = {};
my $interfaceTables = $self->{snmp}->get_multiple_table(oids => $oids);
my @KeyMac = $self->{snmp}->oid_lex_sort(keys %{$interfaceTables->{ $mapping->{regmac}->{oid} }});
my (@KeysRx, @KeysTx, @Keys2n);
if (defined($self->{option_results}->{strength})) {
@KeysRx = $self->{snmp}->oid_lex_sort(keys %{$interfaceTables->{ $mapping->{rx}->{oid} }});
@KeysTx = $self->{snmp}->oid_lex_sort(keys %{$interfaceTables->{ $mapping->{tx}->{oid} }});
} elsif (defined($self->{option_results}->{noise})){
@Keys2n = $self->{snmp}->oid_lex_sort(keys %{$interfaceTables->{ $mapping->{regs2n}->{oid} }});
}
foreach my $index (0 .. $#KeyMac) {
next if ($KeyMac[$index] !~ /^$mapping->{regmac}->{oid}\.(.*)$/);
next if (defined($self->{option_results}->{strength}) &&
$KeysRx[$index] !~ /^$mapping->{rx}->{oid}\.(.*)$/ &&
$KeysTx[$index] !~ /^$mapping->{tx}->{oid}\.(.*)$/);
next if (defined($self->{option_results}->{noise}) && $Keys2n[$index] !~ /^$mapping->{regs2n}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping,
results => $interfaceTables,
instance => $instance);
my $mac = unpack('H*', $interfaceTables->{$mapping->{regmac}->{oid}}->{$KeyMac[$index]});
$mac =~ s/..\K\B/:/g;
if(defined($self->{option_results}->{strength})) {
$self->{signalstrength}->{$instance} = { display => $mac,
%$result
};
}
if(defined($self->{option_results}->{noise})) {
$self->{signalnoise}->{$instance} = { display => $mac,
%$result
};
}
}
if (scalar(keys %{$self->{signalstrength}}) <= 0 && scalar(keys %{$self->{signalnoise}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No signal found.");
$self->{output}->option_exit();
}
$self->{cache_name} = "mikrotik_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port();
}
1;
__END__
=head1 MODE
Check signal strength and signal to noise.
=over 8
=item B<--noise>
Gets values for signal to noise
=item B<--strength>
Gets values for signal strength
=item B<--warning-*>
Can be rx-strength, tx-strength or signal2noise
=item B<--critical-*>
Can be rx-strength, tx-strength or signal2noise
=back
=cut

View File

@ -0,0 +1,55 @@
#
# Copyright 2018 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::mikrotik::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
'cpu' => 'snmp_standard::mode::cpu',
'environment' => 'network::mikrotik::snmp::mode::environment',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'list-frequencies' => 'network::mikrotik::snmp::mode::listfrequencies',
'list-ssids' => 'network::mikrotik::snmp::mode::listssids',
'memory' => 'network::mikrotik::snmp::mode::memory',
'signal' => 'network::mikrotik::snmp::mode::signal',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Mikrotik equipments in SNMP.
=cut