add colubris snmp plugin
This commit is contained in:
parent
f411610468
commit
c6ac9e90f2
|
@ -0,0 +1,256 @@
|
|||
#
|
||||
# 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::colubris::snmp::mode::apusage;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
my $instance_mode;
|
||||
|
||||
sub custom_status_threshold {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'ok';
|
||||
my $message;
|
||||
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($instance_mode->{option_results}->{critical_ap_status}) && $instance_mode->{option_results}->{critical_ap_status} ne '' &&
|
||||
eval "$instance_mode->{option_results}->{critical_ap_status}") {
|
||||
$status = 'critical';
|
||||
} elsif (defined($instance_mode->{option_results}->{warning_ap_status}) && $instance_mode->{option_results}->{warning_ap_status} ne '' &&
|
||||
eval "$instance_mode->{option_results}->{warning_ap_status}") {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $msg = 'Operational State : ' . $self->{result_values}->{state};
|
||||
return $msg;
|
||||
}
|
||||
|
||||
sub custom_status_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'};
|
||||
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0 },
|
||||
{ name => 'ap', type => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All access points are OK' },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'total-ap', set => {
|
||||
key_values => [ { name => 'total_ap' } ],
|
||||
output_template => 'Total AP : %s',
|
||||
perfdatas => [
|
||||
{ label => 'total_ap', value => 'total_ap_absolute', template => '%s', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'total-users', set => {
|
||||
key_values => [ { name => 'total_users' } ],
|
||||
output_template => 'Total Users : %s',
|
||||
perfdatas => [
|
||||
{ label => 'total_users', value => 'total_users_absolute', template => '%s', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{ap} = [
|
||||
{ label => 'ap-status', threshold => 0, set => {
|
||||
key_values => [ { name => 'state' }, { name => 'display' } ],
|
||||
closure_custom_calc => $self->can('custom_status_calc'),
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => $self->can('custom_status_threshold'),
|
||||
}
|
||||
},
|
||||
{ label => 'ap-users', set => {
|
||||
key_values => [ { name => 'users' }, { name => 'display' } ],
|
||||
output_template => 'Current Users: %s',
|
||||
perfdatas => [
|
||||
{ label => 'ap_users', value => 'users_absolute', template => '%s',
|
||||
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_ap_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "AP '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
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 =>
|
||||
{
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
"warning-ap-status:s" => { name => 'warning_ap_status', default => '' },
|
||||
"critical-ap-status:s" => { name => 'critical_ap_status', default => '%{state} eq "disconnected"' },
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub change_macros {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (('warning_ap_status', 'critical_ap_status')) {
|
||||
if (defined($self->{option_results}->{$_})) {
|
||||
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros();
|
||||
$instance_mode = $self;
|
||||
}
|
||||
|
||||
my %map_device_state = (
|
||||
1 => 'disconnected', 2 => 'authorized', 3 => 'join', 4 => 'firmware',
|
||||
5 => 'security', 6 => 'configuration', 7 => 'running'
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
coDevDisState => { oid => '.1.3.6.1.4.1.8744.5.23.1.2.1.1.5', map => \%map_device_state },
|
||||
coDevDisSystemName => { oid => '.1.3.6.1.4.1.8744.5.23.1.2.1.1.6' },
|
||||
};
|
||||
|
||||
my $mapping2 = {
|
||||
coDevWirCliStaMACAddress => { oid => '.1.3.6.1.4.1.8744.5.25.1.7.1.1.2' },
|
||||
};
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{cache_name} = "colubris_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
|
||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
|
||||
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
|
||||
|
||||
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
|
||||
{ oid => $mapping->{coDevDisState}->{oid} },
|
||||
{ oid => $mapping->{coDevDisSystemName}->{oid} },
|
||||
{ oid => $mapping2->{coDevWirCliStaMACAddress}->{oid} },
|
||||
], nothing_quit => 1, return_type => 1);
|
||||
|
||||
$self->{ap} = {};
|
||||
$self->{global} = { total_ap => 0, total_users => 0 };
|
||||
foreach my $oid (sort keys %{$snmp_result}) {
|
||||
next if ($oid !~ /^$mapping->{coDevDisSystemName}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$result->{coDevDisSystemName} !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $result->{coDevDisSystemName} . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
$self->{global}->{total_ap}++;
|
||||
$self->{ap}->{$instance} = {
|
||||
display => $result->{coDevDisSystemName},
|
||||
state => $result->{coDevDisState},
|
||||
users => 0,
|
||||
};
|
||||
}
|
||||
|
||||
foreach my $oid (sort keys %{$snmp_result}) {
|
||||
next if ($oid !~ /^$mapping2->{coDevWirCliStaMACAddress}->{oid}\.(.*?)\./);
|
||||
my $instance = $1;
|
||||
|
||||
next if (!defined($self->{ap}->{$instance}));
|
||||
|
||||
$self->{global}->{total_users}++;
|
||||
$self->{ap}->{$instance}->{users}++;
|
||||
}
|
||||
|
||||
if (scalar(keys %{$self->{ap}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No access point found.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check AP status and users connected.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter ap name with regexp.
|
||||
|
||||
=item B<--warning-*>
|
||||
|
||||
Threshold warning.
|
||||
Can be: 'total-ap', 'total-users', 'ap-users'.
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Threshold critical.
|
||||
Can be: 'total-ap', 'total-users', 'ap-users'.
|
||||
|
||||
=item B<--warning-ap-status>
|
||||
|
||||
Set warning threshold for status.
|
||||
Can used special variables like: %{state}, %{display}
|
||||
|
||||
=item B<--critical-ap-status>
|
||||
|
||||
Set critical threshold for status (Default: '%{state} eq "disconnected"').
|
||||
Can used special variables like: %{state}, %{display}
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,139 @@
|
|||
#
|
||||
# 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::colubris::snmp::mode::cpu;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_cpu_output' },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'current', set => {
|
||||
key_values => [ { name => 'usage_now' } ],
|
||||
output_template => '%.2f %% (current)',
|
||||
perfdatas => [
|
||||
{ label => 'cpu_current', value => 'usage_now_absolute', template => '%.2f',
|
||||
unit => '%', min => 0, max => 100 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => '5s', set => {
|
||||
key_values => [ { name => 'usage_5s' } ],
|
||||
output_template => '%.2f %% (5sec)',
|
||||
perfdatas => [
|
||||
{ label => 'cpu_5s', value => 'usage_5s_absolute', template => '%.2f',
|
||||
unit => '%', min => 0, max => 100 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => '10s', set => {
|
||||
key_values => [ { name => 'usage_10s' } ],
|
||||
output_template => '%.2f %% (10sec)',
|
||||
perfdatas => [
|
||||
{ label => 'cpu_10s', value => 'usage_10s_absolute', template => '%.2f',
|
||||
unit => '%', min => 0, max => 100 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => '20s', set => {
|
||||
key_values => [ { name => 'usage_20s' } ],
|
||||
output_template => '%.2f %% (5sec)',
|
||||
perfdatas => [
|
||||
{ label => 'cpu_20s', value => 'usage_20s_absolute', template => '%.2f',
|
||||
unit => '%', min => 0, max => 100 },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_cpu_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "CPU ";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $oid_coUsInfoCpuUseNow = '.1.3.6.1.4.1.8744.5.21.1.1.5.0';
|
||||
my $oid_coUsInfoCpuUse5Sec = '.1.3.6.1.4.1.8744.5.21.1.1.6.0';
|
||||
my $oid_coUsInfoCpuUse10Sec = '.1.3.6.1.4.1.8744.5.21.1.1.7.0';
|
||||
my $oid_coUsInfoCpuUse20Sec = '.1.3.6.1.4.1.8744.5.21.1.1.8.0';
|
||||
my $snmp_result = $options{snmp}->get_leef(oids => [$oid_coUsInfoCpuUseNow,
|
||||
$oid_coUsInfoCpuUse5Sec, $oid_coUsInfoCpuUse10Sec, $oid_coUsInfoCpuUse20Sec], nothing_quit => 1);
|
||||
|
||||
$self->{global} = {
|
||||
usage_now => $snmp_result->{$oid_coUsInfoCpuUseNow},
|
||||
usage_5s => $snmp_result->{$oid_coUsInfoCpuUse5Sec},
|
||||
usage_10s => $snmp_result->{$oid_coUsInfoCpuUse10Sec},
|
||||
usage_20s => $snmp_result->{$oid_coUsInfoCpuUse20Sec},
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check CPU usage.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-counters>
|
||||
|
||||
Only display some counters (regexp can be used).
|
||||
Example: --filter-counters='20s'
|
||||
|
||||
=item B<--warning-*>
|
||||
|
||||
Threshold warning.
|
||||
Can be: 'current', '5s', '10s', '20s'.
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Threshold critical.
|
||||
Can be: 'current', '5s', '10s', '20s'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,125 @@
|
|||
#
|
||||
# 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::colubris::snmp::mode::load;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_load_output' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => '1min', set => {
|
||||
key_values => [ { name => 'load1' } ],
|
||||
output_template => '%s',
|
||||
perfdatas => [
|
||||
{ label => 'load1', value => 'load1_absolute', template => '%s', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => '5min', set => {
|
||||
key_values => [ { name => 'load5' } ],
|
||||
output_template => '%s',
|
||||
perfdatas => [
|
||||
{ label => 'load5', value => 'load5_absolute', template => '%s', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => '1min', set => {
|
||||
key_values => [ { name => 'load15' } ],
|
||||
output_template => '%s',
|
||||
perfdatas => [
|
||||
{ label => 'load15', value => 'load15_absolute', template => '%s', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_load_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Load average: ";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $oid_coUsInfoLoadAverage1Min = '.1.3.6.1.4.1.8744.5.21.1.1.5.0';
|
||||
my $oid_coUsInfoLoadAverage5Min = '.1.3.6.1.4.1.8744.5.21.1.1.6.0';
|
||||
my $oid_coUsInfoLoadAverage15Min = '.1.3.6.1.4.1.8744.5.21.1.1.7.0';
|
||||
my $snmp_result = $options{snmp}->get_leef(oids => [$oid_coUsInfoLoadAverage1Min,
|
||||
$oid_coUsInfoLoadAverage5Min, $oid_coUsInfoLoadAverage15Min], nothing_quit => 1);
|
||||
|
||||
$self->{global} = {
|
||||
load1 => $snmp_result->{$oid_coUsInfoLoadAverage1Min},
|
||||
load5 => $snmp_result->{$oid_coUsInfoLoadAverage5Min},
|
||||
load15 => $snmp_result->{$oid_coUsInfoLoadAverage15Min},
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check load-average.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-counters>
|
||||
|
||||
Only display some counters (regexp can be used).
|
||||
Example: --filter-counters='15min'
|
||||
|
||||
=item B<--warning-*>
|
||||
|
||||
Threshold warning.
|
||||
Can be: '1min', '5min', '15min'.
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Threshold critical.
|
||||
Can be: '1min', '5min', '15min'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,129 @@
|
|||
#
|
||||
# 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::colubris::snmp::mode::memory;
|
||||
|
||||
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 =>
|
||||
{
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_coUsInfoRamTotal = '.1.3.6.1.4.1.8744.5.21.1.1.9.0';
|
||||
my $oid_coUsInfoRamFree = '.1.3.6.1.4.1.8744.5.21.1.1.10.0';
|
||||
my $oid_coUsInfoRamBuffer = '.1.3.6.1.4.1.8744.5.21.1.1.11.0';
|
||||
my $oid_coUsInfoRamCached = '.1.3.6.1.4.1.8744.5.21.1.1.12.0';
|
||||
|
||||
my $result = $self->{snmp}->get_leef(oids => [
|
||||
$oid_coUsInfoRamTotal, $oid_coUsInfoRamFree,
|
||||
$oid_coUsInfoRamBuffer, $oid_coUsInfoRamCached
|
||||
], nothing_quit => 1);
|
||||
|
||||
my $cached_used = $result->{$oid_coUsInfoRamCached};
|
||||
my $buffer_used = $result->{$oid_coUsInfoRamBuffer};
|
||||
my $physical_used = ($result->{$oid_coUsInfoRamTotal}) - ($result->{$oid_coUsInfoRamFree});
|
||||
my $nobuf_used = $physical_used - $buffer_used - $cached_used;
|
||||
|
||||
my $total_size = $result->{$oid_coUsInfoRamTotal};
|
||||
|
||||
my $prct_used = $nobuf_used * 100 / $total_size;
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
my ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $total_size);
|
||||
my ($nobuf_value, $nobuf_unit) = $self->{perfdata}->change_bytes(value => $nobuf_used);
|
||||
my ($buffer_value, $buffer_unit) = $self->{perfdata}->change_bytes(value => $buffer_used);
|
||||
my ($cached_value, $cached_unit) = $self->{perfdata}->change_bytes(value => $cached_used);
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Ram Total: %s, Used (-buffers/cache): %s (%.2f%%), Buffer: %s, Cached: %s",
|
||||
$total_value . " " . $total_unit,
|
||||
$nobuf_value . " " . $nobuf_unit, $prct_used,
|
||||
$buffer_value . " " . $buffer_unit,
|
||||
$cached_value . " " . $cached_unit));
|
||||
|
||||
$self->{output}->perfdata_add(label => "cached", unit => 'B',
|
||||
value => $cached_used,
|
||||
min => 0);
|
||||
$self->{output}->perfdata_add(label => "buffer", unit => 'B',
|
||||
value => $buffer_used,
|
||||
min => 0);
|
||||
$self->{output}->perfdata_add(label => "used", unit => 'B',
|
||||
value => $nobuf_used,
|
||||
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();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check memory usage.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Threshold warning in percent.
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Threshold critical in percent.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,108 @@
|
|||
#
|
||||
# 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::colubris::snmp::mode::storage;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'storage', type => 0 }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{storage} = [
|
||||
{ label => 'permanent-usage', set => {
|
||||
key_values => [ { name => 'perm_used' } ],
|
||||
output_template => 'Permanent Storage Used: %.2f%%',
|
||||
perfdatas => [
|
||||
{ label => 'storage_permanent_used', value => 'perm_used_absolute', template => '%.2f',
|
||||
min => 0, max => 100, unit => '%' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'temporary-usage', set => {
|
||||
key_values => [ { name => 'temp_used' } ],
|
||||
output_template => 'Temporary Storage Used: %.2f%%',
|
||||
perfdatas => [
|
||||
{ label => 'storage_temporary_used', value => 'temp_used_absolute', template => '%.2f',
|
||||
min => 0, max => 100, unit => '%' },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $oid_coUsInfoStorageUsePermanent = '.1.3.6.1.4.1.8744.5.21.1.1.13.0';
|
||||
my $oid_coUsInfoStorageUseTemporary = '.1.3.6.1.4.1.8744.5.21.1.1.14.0';
|
||||
my $snmp_result = $options{snmp}->get_leef(oids => [
|
||||
$oid_coUsInfoStorageUsePermanent, $oid_coUsInfoStorageUseTemporary,
|
||||
], nothing_quit => 1);
|
||||
|
||||
$self->{storage} = {
|
||||
perm_used => $snmp_result->{$oid_coUsInfoStorageUsePermanent},
|
||||
temp_used => $snmp_result->{$oid_coUsInfoStorageUseTemporary},
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check storage usage.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-*>
|
||||
|
||||
Threshold warning.
|
||||
Can be: 'permanent-usage' (%), 'temporary-usage' (%).
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Threshold critical.
|
||||
Can be: 'permanent-usage' (%), 'temporary-usage' (%).
|
||||
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,54 @@
|
|||
#
|
||||
# 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::colubris::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}} = (
|
||||
'ap-usage' => 'network::colubris::snmp::mode::apusage',
|
||||
'cpu' => 'network::colubris::snmp::mode::cpu',
|
||||
'interfaces' => 'snmp_standard::mode::interfaces',
|
||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||
'load' => 'network::colubris::snmp::mode::load',
|
||||
'memory' => 'network::colubris::snmp::mode::memory',
|
||||
'storage' => 'network::colubris::snmp::mode::storage',
|
||||
);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Colubris equipments in SNMP.
|
||||
|
||||
=cut
|
Loading…
Reference in New Issue