From 09b1d76edac479b32ed16489c673fb972eaa6192 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 20 Jan 2020 15:32:06 +0100 Subject: [PATCH] Fix #1754 --- .../network/juniper/common/junos/mode/cpu.pm | 159 +++++++++++++++++ .../juniper/common/junos/mode/cpurouting.pm | 153 ----------------- .../juniper/common/junos/mode/memory.pm | 162 ++++++++++++++++++ .../common/junos/mode/memoryrouting.pm | 151 ---------------- centreon-plugins/network/juniper/ex/plugin.pm | 16 +- .../network/juniper/mseries/plugin.pm | 26 +-- .../network/juniper/srx/plugin.pm | 4 +- 7 files changed, 344 insertions(+), 327 deletions(-) create mode 100644 centreon-plugins/network/juniper/common/junos/mode/cpu.pm delete mode 100644 centreon-plugins/network/juniper/common/junos/mode/cpurouting.pm create mode 100644 centreon-plugins/network/juniper/common/junos/mode/memory.pm delete mode 100644 centreon-plugins/network/juniper/common/junos/mode/memoryrouting.pm diff --git a/centreon-plugins/network/juniper/common/junos/mode/cpu.pm b/centreon-plugins/network/juniper/common/junos/mode/cpu.pm new file mode 100644 index 000000000..7a3f981de --- /dev/null +++ b/centreon-plugins/network/juniper/common/junos/mode/cpu.pm @@ -0,0 +1,159 @@ +# +# Copyright 2020 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::juniper::common::junos::mode::cpu; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'cpu', type => 1, cb_prefix_output => 'prefix_seamsg_output', message_multiple => 'All CPU(s) average usages are ok' }, + ]; + + $self->{maps_counters}->{cpu} = [ + { label => 'utilization', nlabel => 'cpu.utilization.percentage', set => { + key_values => [ { name => 'cpu_usage' }, { name => 'display' } ], + output_template => 'average usage is: %.2f%%', + perfdatas => [ + { label => 'cpu', value => 'cpu_usage_absolute', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'load-1m', nlabel => 'cpu.load.1m.percentage', display_ok => 0, set => { + key_values => [ { name => 'cpu_load1' }, { name => 'display' } ], + output_template => 'load 1min: %s', + perfdatas => [ + { label => 'load1', value => 'cpu_load1_absolute', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'load-5m', nlabel => 'cpu.load.5m.percentage', display_ok => 0, set => { + key_values => [ { name => 'cpu_load5' }, { name => 'display' } ], + output_template => 'load 5min: %s', + perfdatas => [ + { label => 'load5', value => 'cpu_load5_absolute', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'load-15m', nlabel => 'cpu.load.15m.percentage', display_ok => 0, set => { + key_values => [ { name => 'cpu_load15' }, { name => 'display' } ], + output_template => 'load 15min: %s', + perfdatas => [ + { label => 'load15', value => 'cpu_load15_absolute', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub prefix_seamsg_output { + my ($self, %options) = @_; + + return "CPU(s) '" . $options{instance_value}->{display} . "' "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'filter:s' => { name => 'filter', default => 'routing|fpc' } + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_jnxOperatingDescr = '.1.3.6.1.4.1.2636.3.1.13.1.5'; + my $oid_jnxOperatingCPU = '.1.3.6.1.4.1.2636.3.1.13.1.8'; + my $oid_jnxOperating1MinLoadAvg = '.1.3.6.1.4.1.2636.3.1.13.1.20'; + my $oid_jnxOperating5MinLoadAvg = '.1.3.6.1.4.1.2636.3.1.13.1.21'; + my $oid_jnxOperating15MinLoadAvg = '.1.3.6.1.4.1.2636.3.1.13.1.22'; + + my $result = $options{snmp}->get_table(oid => $oid_jnxOperatingDescr, nothing_quit => 1); + my $routing_engine_find = 0; + my @oids_routing_engine = (); + foreach my $oid (keys %$result) { + if ($result->{$oid} =~ /$self->{option_results}->{filter}/i) { + $routing_engine_find = 1; + push @oids_routing_engine, $oid; + } + } + + if ($routing_engine_find == 0) { + $self->{output}->add_option_msg(short_msg => "Cannot find operating with '$self->{option_results}->{filter}' in description."); + $self->{output}->option_exit(); + } + + $options{snmp}->load( + oids => [$oid_jnxOperatingCPU, $oid_jnxOperating1MinLoadAvg, $oid_jnxOperating5MinLoadAvg, $oid_jnxOperating15MinLoadAvg], + instances => \@oids_routing_engine, + instance_regexp => "^" . $oid_jnxOperatingDescr . '\.(.+)' + ); + my $result2 = $options{snmp}->get_leef(); + + foreach my $oid_routing_engine (@oids_routing_engine) { + $oid_routing_engine =~ /^$oid_jnxOperatingDescr\.(.+)/; + my $instance = $1; + + $self->{cpu}->{$instance} = { + display => $result->{$oid_jnxOperatingDescr . '.' . $instance}, + cpu_usage => $result2->{$oid_jnxOperatingCPU . '.' . $instance}, + cpu_load1 => $result2->{$oid_jnxOperating1MinLoadAvg . '.' . $instance}, + cpu_load5 => $result2->{$oid_jnxOperating5MinLoadAvg . '.' . $instance}, + cpu_load15 => $result2->{$oid_jnxOperating15MinLoadAvg . '.' . $instance} + }; + } +} + +1; + +__END__ + +=head1 MODE + +Check cpu usage. + +=over 8 + +=item B<--filter> + +Filter operating (Default: 'routing|fpc'). + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'utilization', 'load-1m', 'load-5m', 'load-15m'. + +=back + +=cut diff --git a/centreon-plugins/network/juniper/common/junos/mode/cpurouting.pm b/centreon-plugins/network/juniper/common/junos/mode/cpurouting.pm deleted file mode 100644 index 88400dfd5..000000000 --- a/centreon-plugins/network/juniper/common/junos/mode/cpurouting.pm +++ /dev/null @@ -1,153 +0,0 @@ -# -# Copyright 2020 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::juniper::common::junos::mode::cpurouting; - -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; - - $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) = @_; - - my $oid_jnxOperatingDescr = '.1.3.6.1.4.1.2636.3.1.13.1.5'; - my $oid_jnxOperatingCPU = '.1.3.6.1.4.1.2636.3.1.13.1.8'; - my $oid_jnxOperating1MinLoadAvg = '.1.3.6.1.4.1.2636.3.1.13.1.20'; - my $oid_jnxOperating5MinLoadAvg = '.1.3.6.1.4.1.2636.3.1.13.1.21'; - my $oid_jnxOperating15MinLoadAvg = '.1.3.6.1.4.1.2636.3.1.13.1.22'; - - my $result = $options{snmp}->get_table(oid => $oid_jnxOperatingDescr, nothing_quit => 1); - my $routing_engine_find = 0; - my @oids_routing_engine = (); - foreach my $oid (keys %$result) { - if ($result->{$oid} =~ /routing/i) { - $routing_engine_find = 1; - push @oids_routing_engine, $oid; - } - } - - if ($routing_engine_find == 0) { - $self->{output}->add_option_msg(short_msg => "Cannot find operating with 'routing' in description."); - $self->{output}->option_exit(); - } - my $multiple = 0; - if (scalar(@oids_routing_engine) > 1) { - $multiple = 1; - $self->{output}->output_add( - severity => 'OK', - short_msg => sprintf("All CPU(s) average usages are ok") - ); - } - - $options{snmp}->load( - oids => [$oid_jnxOperatingCPU, $oid_jnxOperating1MinLoadAvg, $oid_jnxOperating5MinLoadAvg, $oid_jnxOperating15MinLoadAvg], - instances => \@oids_routing_engine, - instance_regexp => "^" . $oid_jnxOperatingDescr . '\.(.+)' - ); - my $result2 = $options{snmp}->get_leef(); - - foreach my $oid_routing_engine (@oids_routing_engine) { - $oid_routing_engine =~ /^$oid_jnxOperatingDescr\.(.+)/; - my $instance = $1; - my $description = $result->{$oid_jnxOperatingDescr . '.' . $instance}; - my $cpu_usage = $result2->{$oid_jnxOperatingCPU . '.' . $instance}; - my $cpu_load1 = $result2->{$oid_jnxOperating1MinLoadAvg . '.' . $instance}; - my $cpu_load5 = $result2->{$oid_jnxOperating5MinLoadAvg . '.' . $instance}; - my $cpu_load15 = $result2->{$oid_jnxOperating15MinLoadAvg . '.' . $instance}; - - my $exit_code = $self->{perfdata}->threshold_check(value => $cpu_usage, - threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->output_add(long_msg => sprintf("CPU(s) '%s' average usage is: %s%%", $description, $cpu_usage)); - if ($multiple == 0 || !$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("CPU(s) '%s' average usage is: %s%%", $description, $cpu_usage)); - } - my $extra_label = ''; - $extra_label = '_' . $description if ($multiple == 1); - $self->{output}->perfdata_add(label => 'cpu' . $extra_label, unit => '%', - value => $cpu_usage, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0, max => 100); - $self->{output}->perfdata_add(label => 'load1' . $extra_label, - value => $cpu_load1, - min => 0); - $self->{output}->perfdata_add(label => 'load5' . $extra_label, - value => $cpu_load5, - min => 0); - $self->{output}->perfdata_add(label => 'load15' . $extra_label, - value => $cpu_load15, - min => 0); - } - - $self->{output}->display(); - $self->{output}->exit(); -} - -1; - -__END__ - -=head1 MODE - -Check CPU Usage of routing engine. - -=over 8 - -=item B<--warning> - -Threshold warning in percent. - -=item B<--critical> - -Threshold critical in percent. - -=back - -=cut diff --git a/centreon-plugins/network/juniper/common/junos/mode/memory.pm b/centreon-plugins/network/juniper/common/junos/mode/memory.pm new file mode 100644 index 000000000..d3f3cbd3a --- /dev/null +++ b/centreon-plugins/network/juniper/common/junos/mode/memory.pm @@ -0,0 +1,162 @@ +# +# Copyright 2020 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::juniper::common::junos::mode::memory; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub custom_mem_output { + my ($self, %options) = @_; + + return sprintf("Total: %s %s Used: %s %s (%.2f%%) Free: %s %s (%.2f%%)", + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), + $self->{result_values}->{prct_used_absolute}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), + $self->{result_values}->{prct_free_absolute} + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'memory', type => 1, cb_prefix_output => 'prefix_memory_output', message_multiple => 'All memories are ok', skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{memory} = [ + { label => 'usage', nlabel => 'memory.usage.bytes', set => { + key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], + closure_custom_output => $self->can('custom_mem_output'), + perfdatas => [ + { label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => { + key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], + closure_custom_output => $self->can('custom_mem_output'), + perfdatas => [ + { label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => { + key_values => [ { name => 'prct_used' }, { name => 'display' } ], + output_template => 'Used : %.2f %%', + perfdatas => [ + { label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%', + label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub prefix_memory_output { + my ($self, %options) = @_; + + return "Memory '" . $options{instance_value}->{display} . "' "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'filter:s' => { name => 'filter', default => 'routing|fpc'} + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_jnxOperatingDescr = '.1.3.6.1.4.1.2636.3.1.13.1.5'; + my $oid_jnxOperatingBuffer = '.1.3.6.1.4.1.2636.3.1.13.1.11'; + my $oid_jnxOperatingMemory = '.1.3.6.1.4.1.2636.3.1.13.1.15'; # MB + + my $result = $options{snmp}->get_table(oid => $oid_jnxOperatingDescr, nothing_quit => 1); + my $routing_engine_find = 0; + my @oids_routing_engine = (); + foreach my $oid (keys %$result) { + if ($result->{$oid} =~ /$self->{option_results}->{filter}/i) { + $routing_engine_find = 1; + push @oids_routing_engine, $oid; + } + } + + if ($routing_engine_find == 0) { + $self->{output}->add_option_msg(short_msg => "Cannot find operating with '$self->{option_results}->{filter}' in description."); + $self->{output}->option_exit(); + } + + $options{snmp}->load( + oids => [$oid_jnxOperatingBuffer, $oid_jnxOperatingMemory], + instances => \@oids_routing_engine, + instance_regexp => "^" . $oid_jnxOperatingDescr . '\.(.+)' + ); + my $result2 = $options{snmp}->get_leef(); + foreach my $oid_routing_engine (@oids_routing_engine) { + $oid_routing_engine =~ /^$oid_jnxOperatingDescr\.(.+)/; + my $instance = $1; + my $total_size = $result2->{$oid_jnxOperatingMemory . '.' . $instance} * 1024 * 1024; + my $prct_used = $result2->{$oid_jnxOperatingBuffer . '.' . $instance}; + + $self->{memory}->{$instance} = { + display => $result->{$oid_jnxOperatingDescr . '.' . $instance}, + total => $total_size, + prct_used => $prct_used, + prct_free => 100 - $prct_used, + used => $total_size * $prct_used / 100, + free => $total_size - ($total_size * $prct_used / 100) + }; + } +} + +1; + +__END__ + +=head1 MODE + +Check Memory Usage of routing engine. + +=over 8 + +=item B<--filter> + +Filter operating (Default: 'routing|fpc'). + +=item B<--warning-*> B<--critical-usage> + +Thresholds. +Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%). + +=back + +=cut diff --git a/centreon-plugins/network/juniper/common/junos/mode/memoryrouting.pm b/centreon-plugins/network/juniper/common/junos/mode/memoryrouting.pm deleted file mode 100644 index d912fcde9..000000000 --- a/centreon-plugins/network/juniper/common/junos/mode/memoryrouting.pm +++ /dev/null @@ -1,151 +0,0 @@ -# -# Copyright 2020 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::juniper::common::junos::mode::memoryrouting; - -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; - - $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_jnxOperatingDescr = '.1.3.6.1.4.1.2636.3.1.13.1.5'; - my $oid_jnxOperatingBuffer = '.1.3.6.1.4.1.2636.3.1.13.1.11'; - my $oid_jnxOperatingMemory = '.1.3.6.1.4.1.2636.3.1.13.1.15'; # MB - - my $result = $self->{snmp}->get_table(oid => $oid_jnxOperatingDescr, nothing_quit => 1); - my $routing_engine_find = 0; - my @oids_routing_engine = (); - foreach my $oid (keys %$result) { - if ($result->{$oid} =~ /routing/i) { - $routing_engine_find = 1; - push @oids_routing_engine, $oid; - } - } - - if ($routing_engine_find == 0) { - $self->{output}->add_option_msg(short_msg => "Cannot find operating with 'routing' in description."); - $self->{output}->option_exit(); - } - - my $multiple = 0; - if (scalar(@oids_routing_engine) > 1) { - $multiple = 1; - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("All memory usages are ok")); - } - - $self->{snmp}->load(oids => [$oid_jnxOperatingBuffer, $oid_jnxOperatingMemory], - instances => \@oids_routing_engine, - instance_regexp => "^" . $oid_jnxOperatingDescr . '\.(.+)'); - my $result2 = $self->{snmp}->get_leef(); - - foreach my $oid_routing_engine (@oids_routing_engine) { - $oid_routing_engine =~ /^$oid_jnxOperatingDescr\.(.+)/; - my $instance = $1; - my $description = $result->{$oid_jnxOperatingDescr . '.' . $instance}; - my $total_size = $result2->{$oid_jnxOperatingMemory . '.' . $instance} * 1024 * 1024; - my $prct_used = $result2->{$oid_jnxOperatingBuffer . '.' . $instance}; - my $prct_free = 100 - $prct_used; - my $memory_used = $total_size * $prct_used / 100; - my $memory_free = $total_size - $memory_used; - - 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 ($used_value, $used_unit) = $self->{perfdata}->change_bytes(value => $memory_used); - my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $memory_free); - - $self->{output}->output_add(long_msg => sprintf("Memory '%s' Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", - $description, $total_value . " " . $total_unit, - $used_value . " " . $used_unit, $prct_used, - $free_value . " " . $free_unit, $prct_free)); - if ($multiple == 0 || !$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Memory '%s' Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", - $description, $total_value . " " . $total_unit, - $used_value . " " . $used_unit, $prct_used, - $free_value . " " . $free_unit, $prct_free)); - } - - my $extra_label = ''; - $extra_label = '_' . $description if ($multiple == 1); - $self->{output}->perfdata_add(label => "used" . $extra_label, unit => 'B', - value => $memory_used, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size), - min => 0, max => $total_size); - } - - $self->{output}->display(); - $self->{output}->exit(); -} - -1; - -__END__ - -=head1 MODE - -Check Memory Usage of routing engine. - -=over 8 - -=item B<--warning> - -Threshold warning in percent. - -=item B<--critical> - -Threshold critical in percent. - -=back - -=cut diff --git a/centreon-plugins/network/juniper/ex/plugin.pm b/centreon-plugins/network/juniper/ex/plugin.pm index c83cdc48b..729045fee 100644 --- a/centreon-plugins/network/juniper/ex/plugin.pm +++ b/centreon-plugins/network/juniper/ex/plugin.pm @@ -31,14 +31,14 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'cpu-routing' => 'network::juniper::common::junos::mode::cpurouting', # routing engine - 'hardware' => 'network::juniper::common::junos::mode::hardware', - 'interfaces' => 'snmp_standard::mode::interfaces', - 'list-interfaces' => 'snmp_standard::mode::listinterfaces', - 'memory-routing' => 'network::juniper::common::junos::mode::memoryrouting', # routing engine - 'list-storages' => 'snmp_standard::mode::liststorages', - 'stack' => 'network::juniper::common::junos::mode::stack', - 'storage' => 'snmp_standard::mode::storage', + 'cpu' => 'network::juniper::common::junos::mode::cpu', + 'hardware' => 'network::juniper::common::junos::mode::hardware', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'memory' => 'network::juniper::common::junos::mode::memory', + 'list-storages' => 'snmp_standard::mode::liststorages', + 'stack' => 'network::juniper::common::junos::mode::stack', + 'storage' => 'snmp_standard::mode::storage', ); return $self; diff --git a/centreon-plugins/network/juniper/mseries/plugin.pm b/centreon-plugins/network/juniper/mseries/plugin.pm index b3dbec1ee..60546cdd1 100644 --- a/centreon-plugins/network/juniper/mseries/plugin.pm +++ b/centreon-plugins/network/juniper/mseries/plugin.pm @@ -31,19 +31,19 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'bgp-peer-state' => 'network::juniper::common::junos::mode::bgppeerstate', - 'bgp-peer-prefix-statistics' => 'network::juniper::common::junos::mode::bgppeerprefixstatistics', - 'cpu-routing' => 'network::juniper::common::junos::mode::cpurouting', # routing engine - 'hardware' => 'network::juniper::common::junos::mode::hardware', - 'interfaces' => 'network::juniper::common::junos::mode::interfaces', - 'ldp-session-status' => 'network::juniper::common::junos::mode::ldpsessionstatus', - 'lsp-status' => 'network::juniper::common::junos::mode::lspstatus', - 'list-bgp-peers' => 'network::juniper::common::junos::mode::listbgppeers', - 'list-interfaces' => 'snmp_standard::mode::listinterfaces', - 'list-storages' => 'snmp_standard::mode::liststorages', - 'memory-routing' => 'network::juniper::common::junos::mode::memoryrouting', # routing engine - 'rsvp-session-status' => 'network::juniper::common::junos::mode::rsvpsessionstatus', - 'storage' => 'snmp_standard::mode::storage', + 'bgp-peer-state' => 'network::juniper::common::junos::mode::bgppeerstate', + 'bgp-peer-prefix-statistics' => 'network::juniper::common::junos::mode::bgppeerprefixstatistics', + 'cpu' => 'network::juniper::common::junos::mode::cpu', + 'hardware' => 'network::juniper::common::junos::mode::hardware', + 'interfaces' => 'network::juniper::common::junos::mode::interfaces', + 'ldp-session-status' => 'network::juniper::common::junos::mode::ldpsessionstatus', + 'lsp-status' => 'network::juniper::common::junos::mode::lspstatus', + 'list-bgp-peers' => 'network::juniper::common::junos::mode::listbgppeers', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'list-storages' => 'snmp_standard::mode::liststorages', + 'memory' => 'network::juniper::common::junos::mode::memory', + 'rsvp-session-status' => 'network::juniper::common::junos::mode::rsvpsessionstatus', + 'storage' => 'snmp_standard::mode::storage', ); return $self; diff --git a/centreon-plugins/network/juniper/srx/plugin.pm b/centreon-plugins/network/juniper/srx/plugin.pm index 91cb83b0d..2902c4218 100644 --- a/centreon-plugins/network/juniper/srx/plugin.pm +++ b/centreon-plugins/network/juniper/srx/plugin.pm @@ -32,9 +32,9 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( 'hardware' => 'network::juniper::common::junos::mode::hardware', - 'cpu-routing' => 'network::juniper::common::junos::mode::cpurouting', # routing engine + 'cpu' => 'network::juniper::common::junos::mode::cpu', 'cpu-forwarding' => 'network::juniper::common::junos::mode::cpuforwarding', # packet forwarding engine - 'memory-routing' => 'network::juniper::common::junos::mode::memoryrouting', # routing engine + 'memory' => 'network::juniper::common::junos::mode::memory', 'memory-forwarding' => 'network::juniper::common::junos::mode::memoryforwarding', # packet forwarding engine 'cp-sessions' => 'network::juniper::common::junos::mode::cpsessions', # CP = 'central point' 'flow-sessions' => 'network::juniper::common::junos::mode::flowsessions',