add(plugin): netgear sseries snmp (#3305)

This commit is contained in:
qgarnier 2021-12-08 10:28:13 +01:00 committed by GitHub
parent 412bead426
commit 7e84d0d26a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 701 additions and 11 deletions

View File

@ -30,14 +30,14 @@ my %map_fan_status = (
my $mapping = {
boxServicesFanItemState => { oid => '.1.3.6.1.4.1.4526.10.43.1.6.1.3', map => \%map_fan_status },
boxServicesFanSpeed => { oid => '.1.3.6.1.4.1.4526.10.43.1.6.1.4' },
boxServicesFanSpeed => { oid => '.1.3.6.1.4.1.4526.10.43.1.6.1.4' }
};
my $oid_boxServicesFansEntry = '.1.3.6.1.4.1.4526.10.43.1.6.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_boxServicesFansEntry, begin => $mapping->{boxServicesFanItemState}->{oid}, end => $mapping->{boxServicesFanSpeed}->{oid} };
push @{$self->{request}}, { oid => $oid_boxServicesFansEntry, start => $mapping->{boxServicesFanItemState}->{oid}, end => $mapping->{boxServicesFanSpeed}->{oid} };
}
sub check {

View File

@ -25,19 +25,19 @@ use warnings;
my %map_temp_status = (
0 => 'low', 1 => 'normal', 2 => 'warning', 3 => 'critical',
4 => 'shutdown', 5 => 'notpresent', 6 => 'notoperational',
4 => 'shutdown', 5 => 'notpresent', 6 => 'notoperational'
);
my $mapping = {
boxServicesTempSensorState => { oid => '.1.3.6.1.4.1.4526.10.43.1.8.1.4', map => \%map_temp_status },
boxServicesTempSensorTemperature => { oid => '.1.3.6.1.4.1.4526.10.43.1.8.1.5' },
boxServicesTempSensorTemperature => { oid => '.1.3.6.1.4.1.4526.10.43.1.8.1.5' }
};
my $oid_boxServicesTempSensorsEntry = '.1.3.6.1.4.1.4526.10.43.1.8.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_boxServicesTempSensorsEntry, begin => $mapping->{boxServicesTempSensorState}->{oid}, end => $mapping->{boxServicesTempSensorTemperature}->{oid} };
push @{$self->{request}}, { oid => $oid_boxServicesTempSensorsEntry, start => $mapping->{boxServicesTempSensorState}->{oid}, end => $mapping->{boxServicesTempSensorTemperature}->{oid} };
}
sub check {

View File

@ -28,7 +28,7 @@ use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan)$';
$self->{regexp_threshold_numeric_check_section_option} = '^(?:temperature|fan)$';
$self->{cb_hook2} = 'snmp_execute';
@ -40,7 +40,7 @@ sub set_system {
['notpowering', 'WARNING'],
['powering', 'OK'],
['nopower', 'OK'],
['incompatible', 'WARNING'],
['incompatible', 'WARNING']
],
temperature => [
['low', 'OK'],
@ -49,8 +49,8 @@ sub set_system {
['critical', 'CRITICAL'],
['notpresent', 'OK'],
['shutdown', 'OK'],
['notoperational', 'WARNING'],
],
['notoperational', 'WARNING']
]
};
$self->{components_path} = 'network::netgear::mseries::snmp::mode::components';

View File

@ -0,0 +1,100 @@
#
# Copyright 2021 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::netgear::sseries::snmp::mode::components::fan;
use strict;
use warnings;
my %map_fan_status = (
1 => 'notpresent', 2 => 'operational', 3 => 'failed', 4 => 'powering',
5 => 'nopower', 6 => 'notpowering', 7 => 'incompatible'
);
my $mapping = {
boxServicesFanItemState => { oid => '.1.3.6.1.4.1.4526.11.43.1.6.1.3', map => \%map_fan_status },
boxServicesFanSpeed => { oid => '.1.3.6.1.4.1.4526.11.43.1.6.1.4' },
};
my $oid_boxServicesFansEntry = '.1.3.6.1.4.1.4526.11.43.1.6.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_boxServicesFansEntry, start => $mapping->{boxServicesFanItemState}->{oid}, end => $mapping->{boxServicesFanSpeed}->{oid} };
}
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 ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_boxServicesFansEntry}})) {
next if ($oid !~ /^$mapping->{boxServicesFanItemState}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_boxServicesFansEntry}, instance => $instance);
next if ($self->check_filter(section => 'fan', instance => $instance));
if ($result->{boxServicesFanItemState} =~ /notpresent/i) {
$self->absent_problem(section => 'fan', instance => $instance);
next;
}
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"fan '%s' status is '%s' [instance: %s, speed: %s]",
$instance,
$result->{boxServicesFanItemState}, $instance,
defined($result->{boxServicesFanSpeed}) ? $result->{boxServicesFanSpeed} : 'unknown'
)
);
$exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{boxServicesFanItemState});
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->{boxServicesFanItemState})
);
}
next if (!defined($result->{boxServicesFanSpeed}) || $result->{boxServicesFanSpeed} !~ /[0-9]+/);
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{boxServicesFanSpeed});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Fan '%s' is '%s' rpm", $instance, $result->{boxServicesFanSpeed})
);
}
$self->{output}->perfdata_add(
nlabel => 'hardware.fan.speed.rpm',
unit => 'rpm',
instances => $instance,
value => $result->{boxServicesFanSpeed},
warning => $warn,
critical => $crit, min => 0
);
}
}
1;

View File

@ -0,0 +1,77 @@
#
# Copyright 2021 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::netgear::sseries::snmp::mode::components::psu;
use strict;
use warnings;
my %map_psu_status = (
1 => 'notpresent', 2 => 'operational', 3 => 'failed', 4 => 'powering',
5 => 'nopower', 6 => 'notpowering', 7 => 'incompatible'
);
my $mapping = {
boxServicesPowSupplyItemState => { oid => '.1.3.6.1.4.1.4526.11.43.1.7.1.3', map => \%map_psu_status }
};
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $mapping->{boxServicesPowSupplyItemState}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking power supplies");
$self->{components}->{psu} = {name => 'psu', total => 0, skip => 0};
return if ($self->check_filter(section => 'psu'));
my ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{boxServicesPowSupplyItemState}->{oid}}})) {
next if ($oid !~ /^$mapping->{boxServicesPowSupplyItemState}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{boxServicesPowSupplyItemState}->{oid}}, instance => $instance);
next if ($self->check_filter(section => 'psu', instance => $instance));
if ($result->{boxServicesPowSupplyItemState} =~ /notpresent/i) {
$self->absent_problem(section => 'psu', instance => $instance);
next;
}
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"power supply '%s' status is '%s' [instance: %s]",
$instance, $result->{boxServicesPowSupplyItemState}, $instance
)
);
$exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{boxServicesPowSupplyItemState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Power supply '%s' status is '%s'", $instance, $result->{boxServicesPowSupplyItemState})
);
}
}
}
1;

View File

@ -0,0 +1,100 @@
#
# Copyright 2021 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::netgear::sseries::snmp::mode::components::temperature;
use strict;
use warnings;
my %map_temp_status = (
0 => 'low', 1 => 'normal', 2 => 'warning', 3 => 'critical',
4 => 'shutdown', 5 => 'notpresent', 6 => 'notoperational',
);
my $mapping = {
boxServicesTempSensorState => { oid => '.1.3.6.1.4.1.4526.11.43.1.8.1.4', map => \%map_temp_status },
boxServicesTempSensorTemperature => { oid => '.1.3.6.1.4.1.4526.11.43.1.8.1.5' }
};
my $oid_boxServicesTempSensorsEntry = '.1.3.6.1.4.1.4526.11.43.1.8.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_boxServicesTempSensorsEntry, start => $mapping->{boxServicesTempSensorState}->{oid}, end => $mapping->{boxServicesTempSensorTemperature}->{oid} };
}
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'));
my ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_boxServicesTempSensorsEntry}})) {
next if ($oid !~ /^$mapping->{boxServicesTempSensorState}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_boxServicesTempSensorsEntry}, instance => $instance);
next if ($self->check_filter(section => 'temperature', instance => $instance));
if ($result->{boxServicesTempSensorState} =~ /notpresent/i) {
$self->absent_problem(section => 'temperature', instance => $instance);
next;
}
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"temperature '%s' status is '%s' [instance: %s, temperature: %s]",
$instance,
$result->{boxServicesTempSensorState},
$instance,
defined($result->{boxServicesTempSensorTemperature}) ? $result->{boxServicesTempSensorTemperature} : 'unknown'
)
);
$exit = $self->get_severity(section => 'temperature', value => $result->{boxServicesTempSensorState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Temperature '%s' status is '%s'", $instance, $result->{boxServicesTempSensorState})
);
}
next if (!defined($result->{boxServicesTempSensorTemperature}) || $result->{boxServicesTempSensorTemperature} !~ /[0-9]+/);
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{boxServicesTempSensorTemperature});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Temperature '%s' is '%s' C", $instance, $result->{boxServicesTempSensorTemperature})
);
}
$self->{output}->perfdata_add(
nlabel => 'hardware.temperature.celsius',
unit => 'C',
instances => $instance,
value => $result->{boxServicesTempSensorTemperature},
warning => $warn,
critical => $crit
);
}
}
1;

View File

@ -0,0 +1,112 @@
#
# Copyright 2021 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::netgear::sseries::snmp::mode::cpu;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub prefix_cpu_output {
my ($self, %options) = @_;
return 'cpu average usage: ';
}
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 => 'cpu-utilization-5s', nlabel => 'cpu.utilization.5s.percentage', set => {
key_values => [ { name => 'usage_5s' } ],
output_template => '%.2f %% (5s)',
perfdatas => [
{ template => '%.2f', unit => '%', min => 0, max => 100 }
]
}
},
{ label => 'cpu-utilization-1m', nlabel => 'cpu.utilization.1m.percentage', set => {
key_values => [ { name => 'usage_1m' } ],
output_template => '%.2f %% (1m)',
perfdatas => [
{ template => '%.2f', unit => '%', min => 0, max => 100 }
]
}
},
{ label => 'cpu-utilization-5m', nlabel => 'cpu.utilization.5m.percentage', set => {
key_values => [ { name => 'usage_5m' } ],
output_template => '%.2f %% (5m)',
perfdatas => [
{ template => '%.2f', unit => '%', min => 0, max => 100 }
]
}
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {});
return $self;
}
sub manage_selection {
my ($self, %options) = @_;
# STRING: " 5 Secs ( 43.2625%) 60 Secs ( 13.9157%) 300 Secs ( 8.9274%)"
my $oid_agentSwitchCpuProcessTotalUtilization = '.1.3.6.1.4.1.4526.11.1.1.4.9.0';
my $snmp_result = $options{snmp}->get_leef(oids => [$oid_agentSwitchCpuProcessTotalUtilization], nothing_quit => 1);
$snmp_result->{$oid_agentSwitchCpuProcessTotalUtilization} =~ /\s*5\s*Secs\s*\(\s*(.*?)%\s*\)\s*60\s*Secs\s*\(\s*(.*?)%\s*\)\s*300\s*Secs\s*\(\s*(.*?)%\s*\)/i;
$self->{global} = { usage_5s => $1, usage_1m => $2, usage_5m => $3 };
}
1;
__END__
=head1 MODE
Check cpu usage.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='5m'
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'cpu-utilization-1s', 'cpu-utilization-1m', 'cpu-utilization-5m'.
=back
=cut

View File

@ -0,0 +1,125 @@
#
# Copyright 2021 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::netgear::sseries::snmp::mode::hardware;
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|fan)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
default => [
['notPresent', 'OK'],
['operational', 'OK'],
['failed', 'CRITICAL'],
['notpowering', 'WARNING'],
['powering', 'OK'],
['nopower', 'OK'],
['incompatible', 'WARNING']
],
temperature => [
['low', 'OK'],
['normal', 'OK'],
['warning', 'WARNING'],
['critical', 'CRITICAL'],
['notpresent', 'OK'],
['shutdown', 'OK'],
['notoperational', 'WARNING']
]
};
$self->{components_path} = 'network::netgear::sseries::snmp::mode::components';
$self->{components_module} = ['fan', 'psu', 'temperature'];
}
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, force_new_perfdata => 1);
bless $self, $class;
$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: 'fan', 'psu', 'temperature'.
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu)
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<--threshold-overload>
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='psu,CRITICAL,^(?!(operational)$)'
=item B<--warning>
Set warning threshold for 'temperature', 'fan' (syntax: type,regexp,threshold)
Example: --warning='temperature,.*,40'
=item B<--critical>
Set critical threshold for 'temperature', 'fan' (syntax: type,regexp,threshold)
Example: --critical='temperature,.*,50'
=back
=cut

View File

@ -0,0 +1,124 @@
#
# Copyright 2021 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::netgear::sseries::snmp::mode::memory;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub custom_memory_usage_output {
my ($self, %options) = @_;
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
return sprintf(
"memory usage total: %s used: %s (%.2f%%) free: %s (%.2f%%)",
$total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}
);
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, skipped_code => { -10 => 1 } }
];
$self->{maps_counters}->{global} = [
{ label => 'memory-usage', nlabel => 'memory.usage.bytes', set => {
key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
closure_custom_output => $self->can('custom_memory_usage_output'),
perfdatas => [
{ template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }
]
}
},
{ label => 'memory-usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => {
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
closure_custom_output => $self->can('custom_memory_usage_output'),
perfdatas => [
{ template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }
]
}
},
{ label => 'memory-usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => {
key_values => [ { name => 'prct_used' }, { name => 'free' }, { name => 'used' }, { name => 'prct_free' }, { name => 'total' } ],
closure_custom_output => $self->can('custom_memory_usage_output'),
perfdatas => [
{ template => '%.2f', min => 0, max => 100, unit => '%' }
]
}
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
});
return $self;
}
sub manage_selection {
my ($self, %options) = @_;
my $oid_mem_free = '.1.3.6.1.4.1.4526.11.1.1.4.1.0'; # agentSwitchCpuProcessMemFree
my $oid_mem_total = '.1.3.6.1.4.1.4526.11.1.1.4.2.0'; # agentSwitchCpuProcessMemAvailable
my $snmp_result = $options{snmp}->get_leef(
oids => [$oid_mem_free, $oid_mem_total],
nothing_quit => 1
);
$self->{global} = {
total => $snmp_result->{$oid_mem_total} * 1024,
free => $snmp_result->{$oid_mem_free} * 1024
};
$self->{global}->{used} = $self->{global}->{total} - $self->{global}->{free};
$self->{global}->{prct_used} = $self->{global}->{used} * 100 / $self->{global}->{total};
$self->{global}->{prct_free} = 100 - $self->{global}->{prct_used};
}
1;
__END__
=head1 MODE
Check memory.
=over 8
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'memory-usage-prct', 'memory-usage', 'memory-usage-free',
=back
=cut

View File

@ -0,0 +1,52 @@
#
# Copyright 2021 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::netgear::sseries::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' => 'network::netgear::sseries::snmp::mode::cpu',
'hardware' => 'network::netgear::sseries::snmp::mode::hardware',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'network::netgear::sseries::snmp::mode::memory',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Netgear Smart Switches (S3300,...) in SNMP.
=cut