diff --git a/centreon-plugins/hardware/devices/polycom/dma/snmp/mode/alerts.pm b/centreon-plugins/hardware/devices/polycom/dma/snmp/mode/alerts.pm new file mode 100644 index 000000000..24b33df9e --- /dev/null +++ b/centreon-plugins/hardware/devices/polycom/dma/snmp/mode/alerts.pm @@ -0,0 +1,201 @@ +# +# 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 hardware::devices::polycom::dma::snmp::mode::alerts; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::misc; +use centreon::plugins::statefile; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = sprintf("alarm [code: %s] [severity: %s] [description: %s] %s", $self->{result_values}->{code}, + $self->{result_values}->{severity}, $self->{result_values}->{description}, $self->{result_values}->{timestamp}); + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{code} = $options{new_datas}->{$self->{instance} . '_alActAlertCode'}; + $self->{result_values}->{severity} = $options{new_datas}->{$self->{instance} . '_alActAlertSeverity'}; + $self->{result_values}->{description} = $options{new_datas}->{$self->{instance} . '_alActAlertDescription'}; + $self->{result_values}->{timestamp} = $options{new_datas}->{$self->{instance} . '_alActAlertTimestamp'}; + $self->{result_values}->{since} = $options{new_datas}->{$self->{instance} . '_since'}; + return 0; +} + + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'alerts', type => 2, message_multiple => 'No problem detected', display_counter_problem => { label => 'dma.alerts.total.count', min => 0 }, + group => [ { name => 'alert', skipped_code => { -11 => 1 } } ] + } + ]; + + $self->{maps_counters}->{alert} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'alActAlertCode' }, { name => 'alActAlertSeverity' }, + { name => 'since' }, { name => 'alActAlertDescription' }, { name => 'alActAlertTimestamp' } ], + 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 => \&catalog_status_threshold + } + } + ]; +} + +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 => { + "filter-msg:s" => { name => 'filter_msg' }, + "warning-status:s" => { name => 'warning_status', default => '%{severity} =~ /warn/i' }, + "critical-status:s" => { name => 'critical_status', default => '%{severity} =~ /severe/i' }, + "memory" => { name => 'memory' } + }); + + centreon::plugins::misc::mymodule_load( + output => $self->{output}, + module => 'Date::Parse', + error_msg => "Cannot load module 'Date::Parse'." + ); + + $self->{statefile_cache} = centreon::plugins::statefile->new(%options); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_status', 'critical_status']); + if (defined($self->{option_results}->{memory})) { + $self->{statefile_cache}->check_options(%options); + } +} + +my %map_severity = (0 => 'warn', 1 => 'severe', 2 => 'critical'); + +my $mapping = { + alActAlertTimestamp => { oid => '.1.3.6.1.4.1.13885.13.2.4.1.2.1.3' }, + alActAlertCode => { oid => '.1.3.6.1.4.1.23916.3.1.4.1.4' }, + alActAlertSeverity => { oid => '.1.3.6.1.4.1.23916.3.1.4.1.6' }, + alActAlertDescription => { oid => '.1.3.6.1.4.1.23916.3.1.4.1.13', map => \%map_severity } +}; + +my $oid_alActiveAlertsEntry = '.1.3.6.1.4.1.13885.13.2.4.1.2.1'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{alerts}->{global} = { alarm => {} }; + + my $alert_result = $options{snmp}->get_table( + oid => $oid_alActiveAlertsEntry, + nothing_quit => 0 + ); + + my $last_time; + if (defined($self->{option_results}->{memory})) { + $self->{statefile_cache}->read(statefile => "cache_polycom_dma_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port(). '_' . $self->{mode}); + $last_time = $self->{statefile_cache}->get(name => 'last_time'); + } + + my ($i, $current_time) = (1, time()); + foreach my $oid (keys %{$alert_result}) { + next if ($oid !~ /^$mapping->{alActAlertSeverity}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $alert_result, instance => $instance); + + my $create_time = Date::Parse::str2time($result->{msgGenerationTime}); + if (!defined($create_time)) { + $self->{output}->output_add( + severity => 'UNKNOWN', + short_msg => "Can't Parse date '" . $result->{msgGenerationTime} . "'" + ); + next; + } + + next if (defined($self->{option_results}->{memory}) && defined($last_time) && $last_time > $create_time); + if (defined($self->{option_results}->{filter_msg}) && $self->{option_results}->{filter_msg} ne '' && + $result->{filter_severity} !~ /$self->{option_results}->{filter_msg}/) { + $self->{output}->output_add(long_msg => "skipping '" . $result->{filter_severity} . "': no matching filter.", debug => 1); + next; + } + if (defined($self->{option_results}->{filter_severity}) && $self->{option_results}->{filter_severity} ne '' && + $result->{alActAlertSeverity} !~ /$self->{option_results}->{filter_severity}/) { + $self->{output}->output_add(long_msg => "skipping '" . $result->{alActAlertSeverity} . "': no matching filter.", debug => 1); + next; + } + + my $diff_time = $current_time - $create_time; + + $self->{alerts}->{global}->{alert}->{$i} = { %$result, since => $diff_time }; + $i++; + } + + if (defined($self->{option_results}->{memory})) { + $self->{statefile_cache}->write(data => { last_time => $current_time }); + } +} + +1; + +__END__ + +=head1 MODE + +Check alerts. + +=over 8 + +=item B<--filter-msg> + +Filter by message (can be a regexp). + +=item B<--warning-status> + +Set warning threshold for status (Default: '%{severity} =~ /warn/i') +Can use special variables like: %{severity}, %{text}, %{code}, %{since} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{severity} =~ /severe/i'). +Can use special variables like: %{severity}, %{text}, %{source}, %{since} + +=item B<--memory> + +Only check new alarms. + +=back + +=cut diff --git a/centreon-plugins/hardware/devices/polycom/dma/snmp/mode/clusters.pm b/centreon-plugins/hardware/devices/polycom/dma/snmp/mode/clusters.pm new file mode 100644 index 000000000..223fbf6d3 --- /dev/null +++ b/centreon-plugins/hardware/devices/polycom/dma/snmp/mode/clusters.pm @@ -0,0 +1,253 @@ +# +# 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 hardware::devices::polycom::dma::snmp::mode::clusters; + +use base qw(centreon::plugins::templates::counter); +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'cluster', type => 1, cb_prefix_output => 'prefix_cluster_output', message_multiple => 'All clusters are ok', skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'dma-total-clusters', nlabel => 'dma.clusters.total.count', set => { + key_values => [ { name => 'clusters_count' } ], + output_template => 'Total clusters : %s', + perfdatas => [ { value => 'clusters_count', template => '%d', min => 0 } ] + } + }, + ]; + + $self->{maps_counters}->{cluster} = [ + { label => 'cluster-status', threshold => 0, display_ok => 0, set => { + key_values => [ { name => 'cluster_status' }, { name => 'display' } ], + closure_custom_output => $self->can('custom_cluster_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'license-status', threshold => 0, display_ok => 0, set => { + key_values => [ { name => 'license_status' }, { name => 'display' } ], + closure_custom_output => $self->can('custom_license_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'cluster-active-calls', nlabel => 'dma.cluster.activecalls.count', set => { + key_values => [ { name => 'active_calls' }, { name => 'licenses_total'}, { name => 'display'} ], + output_template => 'Active calls : %s', + perfdatas => [ + { value => 'active_calls', label_extra_instance => 1, + instance_use => 'display', template => '%s', max => 'licenses_total' } + ] + } + }, + { label => 'cluster-license-usage-free', nlabel => 'dma.cluster.licenses.free.count', set => { + key_values => [ { name => 'licenses_free' }, { name => 'display'} ], + output_template => 'Free licenses : %s', + perfdatas => [ + { value => 'licenses_free', label_extra_instance => 1, + instance_use => 'display', template => '%s', min => 0 } + ] + } + }, + { label => 'cluster-license-usage-prct', nlabel => 'dma.cluster.licenses.usage.percentage', set => { + key_values => [ { name => 'licenses_used_prct' }, { name => 'display'} ], + output_template => 'Licenses percentage usage : %.2f%%', + perfdatas => [ + { value => 'licenses_used_prct', label_extra_instance => 1, unit => '%', + instance_use => 'display', template => '%.2f', min => 0 } + ] + } + } + ]; +} + +sub prefix_cluster_output { + my ($self, %options) = @_; + + return "Cluster '" . $options{instance_value}->{display} . "' "; +} + +sub custom_cluster_status_output { + my ($self, %options) = @_; + + return sprintf('Cluster status: %s', $self->{result_values}->{cluster_status}); +} + +sub custom_license_status_output { + my ($self, %options) = @_; + + return sprintf('License status: %s', $self->{result_values}->{license_status}); +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_cluster_status', 'critical_cluster_status','warning_license_status', 'critical_license_status']); +} + +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 => { + 'filter-cluster:s' => { name => 'filter_cluster' }, + 'warning-cluster-status:s' => { name => 'warning_cluster_status', default => '' }, + 'critical-cluster-status:s' => { name => 'critical_cluster_status', default => '%{cluster_status} =~ /outOfService/i' }, + 'warning-license-status:s' => { name => 'warning_license_status', default => '' }, + 'critical-license-status:s' => { name => 'critical_license_status', default => '%{license_status} =~ /invalid/i' }, + }); + return $self; +} + +my %map_cluster_status = (1 => 'inService', 2 => 'busyOut', 3 => 'outOfService'); +my %map_licensing_status = (1 => 'valid', 2 => 'invalid', 3 => 'notInstalled'); + + +my $mapping_status = { + stClClusterName => { oid => '.1.3.6.1.4.1.13885.13.2.2.3.2.1.2' }, + stClClusterStatus => { oid => '.1.3.6.1.4.1.13885.13.2.2.3.2.1.3', map => \%map_cluster_status } +}; + +my $mapping_licenses = { + stLicClusterName => { oid => '.1.3.6.1.4.1.13885.13.2.2.3.3.1.2' }, + stLicLicenseStatus => { oid => '.1.3.6.1.4.1.13885.13.2.2.3.3.1.3', map => \%map_licensing_status}, + stLicLicensedCalls => { oid => '.1.3.6.1.4.1.13885.13.2.2.3.3.1.4' }, + stLicCallserverActiveCalls => { oid => '.1.3.6.1.4.1.13885.13.2.2.3.3.1.5' } +}; + + +my $oid_stClustersEntry = '.1.3.6.1.4.1.13885.13.2.2.3.2.1'; +my $oid_stLicensesEntry = '.1.3.6.1.4.1.13885.13.2.2.3.3.1'; + +my $oid_stClustersCount = '.1.3.6.1.4.1.13885.13.2.2.3.1.0'; #global + + +sub manage_selection { + my ($self, %options) = @_; + + my $global_result = $options{snmp}->get_leef( + oids => [ $oid_stClustersCount ], + nothing_quit => 1 + ); + + $self->{global} = { clusters_count => $global_result->{$oid_stClustersCount} }; + + $self->{clusters_result} = {}; + $self->{clusters_result} = $options{snmp}->get_multiple_table( + oids => [ + { oid => $oid_stClustersEntry }, + { oid => $oid_stLicensesEntry } + ], + nothing_quit => 1 + ); + + foreach my $oid (keys %{$self->{clusters_result}->{$oid_stClustersEntry}}) { + next if ($oid !~ /^$mapping_status->{stClClusterName}->{oid}\.(.*)$/); + my $instance = $1; + + my $result_status = $options{snmp}->map_instance(mapping => $mapping_status, results => $self->{clusters_result}->{$oid_stClustersEntry}, instance => $instance); + my $result_licenses = $options{snmp}->map_instance(mapping => $mapping_licenses, results => $self->{clusters_result}->{$oid_stLicensesEntry}, instance => $instance); + + if (defined($self->{option_results}->{filter_cluster}) && $self->{option_results}->{filter_cluster} ne '' && + $result_status->{stClClusterName} !~ /$self->{option_results}->{filter_cluster}/) { + $self->{output}->output_add(long_msg => "skipping '" . $result_status->{stClClusterName} . "': no matching filter.", debug => 1); + next; + } + + my ($licenses_used, $licenses_total) = ($result_licenses->{stLicCallserverActiveCalls}, $result_licenses->{stLicLicensedCalls}); + my $licenses_free = $licenses_total - $licenses_used; + + $self->{cluster}->{$instance} = { + display => $result_status->{stClClusterName}, + cluster_status => $result_status->{stClClusterStatus}, + active_calls => $result_licenses->{stLicCallserverActiveCalls}, + license_status => $result_licenses->{stLicLicenseStatus}, + licenses_total => $licenses_total, + licenses_free => $licenses_free, + licenses_used_prct => ( $licenses_used * 100 ) / $licenses_total + }; + } + +} + +1; + +__END__ + +=head1 MODE + +Check information about clusters in the Polycom DMA supercluster. + +=over 8 + +=item B<--filter-cluster> + +Filter on one or several cluster (POSIX regexp) + +=item B<--warning-cluster-status> + +Custom Warning threshold of the cluster state (Default: none) +Syntax: --warning-cluster-status='%{cluster_status} =~ /busyOut/i' + + +=item B<--critical-cluster-status> + +Custom Critical threshold of the cluster state +(Default: '%{cluster_status} =~ /outOfService/i' ) +Syntax: --critical-cluster-status='%{cluster_status} =~ /busyOut/i' + + +=item B<--warning-license-status> + +Custom Warning threshold of the cluster license state (Default: none) +Syntax: --warning-license-status='%{license_status} =~ /notinstalled/i' + + +=item B<--critical-license-status> + +Custom Critical threshold of the cluster license state +(Default: '%{license_status} =~ /invalid/i') +Syntax: --critical-license-status='%{license_status} =~ /notinstalled/i' + +=item B<--warning-* --critical-*> + +Warning & Critical Thresholds for the collected metrics. Possible values: + +[PER-CLUSTER] cluster-active-calls cluster-license-usage-free cluster-license-usage-prct + +[GLOBAL] dma-total-clusters + +=back + +=cut + + diff --git a/centreon-plugins/hardware/devices/polycom/dma/snmp/mode/conferencemanager.pm b/centreon-plugins/hardware/devices/polycom/dma/snmp/mode/conferencemanager.pm new file mode 100644 index 000000000..b7f5202e8 --- /dev/null +++ b/centreon-plugins/hardware/devices/polycom/dma/snmp/mode/conferencemanager.pm @@ -0,0 +1,276 @@ +# +# 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 hardware::devices::polycom::dma::snmp::mode::conferencemanager; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub custom_video_port_output { + my ($self, %options) = @_; + + my $msg = sprintf("video ports [total: %s used: %s (%.2f%%) free: %s (%.2f%%)]", + $self->{result_values}->{vp_total}, + $self->{result_values}->{vp_used}, + $self->{result_values}->{vp_prct_used}, + $self->{result_values}->{vp_free}, + $self->{result_values}->{vp_prct_free} + ); + return $msg; +} + +sub custom_voice_port_output { + my ($self, %options) = @_; + + my $msg = sprintf("voice ports [total: %s used: %s (%.2f%%) free: %s (%.2f%%)]", + $self->{result_values}->{vop_total}, + $self->{result_values}->{vop_used}, + $self->{result_values}->{vop_prct_used}, + $self->{result_values}->{vop_free}, + $self->{result_values}->{vop_prct_free} + ); + return $msg; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'cluster', type => 1, cb_prefix_output => 'prefix_cluster_output', message_multiple => 'All clusters are ok', skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'dma-total-conferences', nlabel => 'dma.conferences.active.count', set => { + key_values => [ { name => 'useConfMgrUsageCount' } ], + output_template => 'Total conferences : %s', + perfdatas => [ + { label => 'conferences', value => 'useConfMgrUsageCount', template => '%d', min => 0, + instance_use => 'display', template => '%d', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{cluster} = [ + { label => 'cluster-conferences', nlabel => 'dma.cluster.conferences.active.count', set => { + key_values => [ { name => 'useCMUsageActiveConfs' }, { name => 'display'} ], + output_template => 'current conferences : %s', + perfdatas => [ + { label => 'conferences_active', value => 'useCMUsageActiveConfs', label_extra_instance => 1, + instance_use => 'display', template => '%d', min => 0 } + ] + } + }, + { label => 'cluster-participants', nlabel => 'dma.cluster.participants.active.count', set => { + key_values => [ { name => 'useCMUsageActiveParts' }, { name => 'display'} ], + output_template => 'current participants : %s', + perfdatas => [ + { label => 'participants', value => 'useCMUsageActiveParts',label_extra_instance => 1, + instance_use => 'display', template => '%d', min => 0 } + ] + } + }, + { label => 'cluster-local-users', nlabel => 'dma.cluster.local.database.users.count', set => { + key_values => [ { name => 'useCMUsageLocalUsers' }, { name => 'display'} ], + output_template => 'local users : %s', + perfdatas => [ + { label => 'local_users', value => 'useCMUsageLocalUsers', label_extra_instance => 1, + instance_use => 'display', template => '%d', min => 0 } + ] + } + }, + { label => 'cluster-custom-rooms', nlabel => 'dma.cluster.custom.conference.rooms.count', set => { + key_values => [ { name => 'useCMUsageCustomConfRooms' }, { name => 'display'} ], + output_template => 'custom conference rooms : %s', + perfdatas => [ + { label => 'custom_rooms', value => 'useCMUsageCustomConfRooms', label_extra_instance => 1, + instance_use => 'display', template => '%d', min => 0 } + ] + } + }, + { label => 'cluster-video-ports-usage', nlabel => 'dma.cluster.video.port.usage.count', set => { + key_values => [ { name => 'vp_used' }, { name => 'vp_free' }, { name => 'vp_prct_used' }, + { name => 'vp_prct_free' }, { name => 'vp_total' }, { name => 'display'} ], + closure_custom_output => $self->can('custom_video_port_output'), + perfdatas => [ + { value => 'vp_used', template => '%d', instance_use => 'display', label_extra_instance => 1, + instance_use => 'display', template => '%d', min => 0, max => 'total', cast_int => 1 } + ] + } + }, + { label => 'cluster-video-ports-free', display_ok => 0, nlabel => 'dma.cluster.video.port.free.count', set => { + key_values => [ { name => 'vp_free' }, { name => 'vp_used' }, { name => 'vp_prct_used' }, + { name => 'vp_prct_free' }, { name => 'vp_total' }, { name => 'display'} ], + closure_custom_output => $self->can('custom_video_port_output'), + perfdatas => [ + { value => 'vp_free', template => '%d', label_extra_instance => 1, instance_use => 'display', + min => 0, max => 'total', cast_int => 1 } + ] + } + }, + { label => 'cluster-video-ports-prct', display_ok => 0, nlabel => 'dma.cluster.video.port.percentage', set => { + key_values => [ { name => 'vp_prct_used' }, { name => 'display'} ], + output_template => 'video ports used: %.2f %%', + perfdatas => [ + { value => 'vp_prct_used', template => '%.2f', label_extra_instance => 1, instance_use => 'display', + min => 0, max => 100, unit => '%' } + ] + } + }, + { label => 'cluster-voice-ports-usage', nlabel => 'dma.cluster.voice.port.usage.count', set => { + key_values => [ { name => 'vop_used' }, { name => 'vop_free' }, { name => 'vop_prct_used' }, + { name => 'vop_prct_free' }, { name => 'vop_total' }, { name => 'display'} ], + closure_custom_output => $self->can('custom_voice_port_output'), + perfdatas => [ + { value => 'vop_used', template => '%d', label_extra_instance => 1, instance_use => 'display', + min => 0, max => 'total', cast_int => 1 } + ] + } + }, + { label => 'cluster-voice-ports-free', display_ok => 0, nlabel => 'dma.cluster.voice.port.free.count', set => { + key_values => [ { name => 'vop_free' }, { name => 'vop_used' }, { name => 'vop_prct_used' }, + { name => 'vop_prct_free' }, { name => 'vop_total' }, { name => 'display'} ], + closure_custom_output => $self->can('custom_voice_port_output'), + perfdatas => [ + { value => 'vop_free', template => '%d', label_extra_instance => 1, instance_use => 'display', + min => 0, max => 'total', cast_int => 1 } + ] + } + }, + { label => 'cluster-voice-ports-prct', display_ok => 0, nlabel => 'dma.cluster.voice.port.percentage', set => { + key_values => [ { name => 'vop_prct_used' }, { name => 'display'} ], + output_template => 'voice ports used: %.2f %%', + perfdatas => [ + { value => 'vop_prct_used', template => '%.2f', label_extra_instance => 1, instance_use => 'display', + 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 => { + 'filter-cluster:s' => { name => 'filter_cluster' }, + }); + + return $self; +} + +sub prefix_cluster_output { + my ($self, %options) = @_; + + return "Cluster '" . $options{instance_value}->{display} . "' "; +} + +my $mapping = { + useCMUsageClusterName => { oid => '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1.2' }, + useCMUsageActiveConfs => { oid => '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1.3' }, + useCMUsageActiveParts => { oid => '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1.4' }, + useCMUsageTotalVideoPorts => { oid => '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1.5' }, + useCMUsageUsedVideoPorts => { oid => '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1.6' }, + useCMUsageTotalVoicePorts => { oid => '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1.7' }, + useCMUsageUsedVoicePorts => { oid => '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1.8' }, + useCMUsageLocalUsers => { oid => '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1.9' }, + useCMUsageCustomConfRooms => { oid => '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1.10' }, +}; + +my $oid_useConfMgrUsageEntry = '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1'; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_useConfMgrUsageCount = '.1.3.6.1.4.1.13885.13.2.3.2.1.1.0'; + my $global_result = $options{snmp}->get_leef(oids => [$oid_useConfMgrUsageCount], nothing_quit => 1); + + $self->{global} = { useConfMgrUsageCount => $global_result->{$oid_useConfMgrUsageCount} }; + + $self->{cluster} = {}; + my $cluster_result = $options{snmp}->get_table( + oid => $oid_useConfMgrUsageEntry, + nothing_quit => 1 + ); + + foreach my $oid (keys %{$cluster_result}) { + next if ($oid !~ /^$mapping->{useCMUsageClusterName}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $cluster_result, instance => $instance); + + $result->{useCMUsageClusterName} = centreon::plugins::misc::trim($result->{useCMUsageClusterName}); + if (defined($self->{option_results}->{filter_cluster}) && $self->{option_results}->{filter_cluster} ne '' && + $result->{useCMUsageClusterName} !~ /$self->{option_results}->{filter_cluster}/) { + $self->{output}->output_add(long_msg => "skipping '" . $result->{useCMUsageClusterName} . "': no matching filter.", debug => 1); + next; + } + + my ($video_port_used, $video_port_total) = ($result->{useCMUsageUsedVideoPorts},$result->{useCMUsageTotalVideoPorts}); + my ($voice_port_used, $voice_port_total) = ($result->{useCMUsageUsedVoicePorts},$result->{useCMUsageTotalVoicePorts}); + + $self->{cluster}->{$instance} = { + display => $result->{useCMUsageClusterName}, + vp_free => $video_port_total - $video_port_used, + vp_prct_free => ($video_port_total != 0) ? 100 - ($video_port_used * 100 / $video_port_total) : '0', + vp_prct_used => ($video_port_total != 0) ? $video_port_used * 100 / $video_port_total : '0', + vp_total => $video_port_total, + vp_used => $video_port_used, + vop_free => $voice_port_total - $voice_port_used, + vop_prct_free => ($voice_port_total != 0) ? 100 - ($voice_port_used * 100 / $voice_port_total) : '0', + vop_prct_used => ($voice_port_total != 0) ? $voice_port_used * 100 / $voice_port_total : '0', + vop_total => $voice_port_total, + vop_used => $voice_port_used, + %$result, + }; + } + +} + +1; + +__END__ + +=head1 MODE + +Check conferences metrics. + +=over 8 + +=item B<--filter-cluster> + +Filter on one or several cluster (POSIX regexp) + +=item B<--warning-* --critical-*> + +TWarning & Critical Thresholds. Possible values: +[PER-CLUSTER] cluster-conferences, cluster-participants, cluster-local-users, cluster-custom-rooms, +cluster-video-ports-usage, cluster-video-ports-free, cluster-video-ports-prct, +cluster-voice-ports-usage, cluster-voice-ports-free, cluster-voice-ports-prct + +[GLOBAL] dma-total-conferences + +=back + +=cut diff --git a/centreon-plugins/hardware/devices/polycom/dma/snmp/mode/deviceregistrations.pm b/centreon-plugins/hardware/devices/polycom/dma/snmp/mode/deviceregistrations.pm new file mode 100644 index 000000000..c5680932e --- /dev/null +++ b/centreon-plugins/hardware/devices/polycom/dma/snmp/mode/deviceregistrations.pm @@ -0,0 +1,156 @@ +# +# 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 hardware::devices::polycom::dma::snmp::mode::deviceregistrations; + +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 }, + { name => 'cluster', type => 1, cb_prefix_output => 'prefix_cluster_output', message_multiple => 'All clusters are ok', skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'dma-total-registrations', nlabel => 'dma.registrations.count', set => { + key_values => [ { name => 'useDevRegistrationsCount' } ], + output_template => 'Total registrations : %s', + perfdatas => [ + { label => 'dma_registrations', value => 'useDevRegistrationsCount', label_extra_instance => 1, + instance_use => 'display', template => '%d', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{cluster} = [ + { label => 'cluster-endpoint-active-registration', nlabel => 'dma.cluster.endpoint.registrations.active.count', set => { + key_values => [ { name => 'useDevRegActiveEndpointReg' }, { name => 'display'} ], + output_template => 'endpoint active registrations : %s', + perfdatas => [ + { label => 'endpoint_registration_active', value => 'useDevRegActiveEndpointReg', label_extra_instance => 1, + instance_use => 'display', template => '%d', min => 0 } + ] + } + }, + { label => 'cluster-endpoint-inactive-registration', nlabel => 'dma.cluster.endpoint.registrations.inactive.count', set => { + key_values => [ { name => 'useDevRegInactiveEndpointReg' }, { name => 'display'} ], + output_template => 'endpoint inactive registrations : %s', + perfdatas => [ + { label => 'endpoint_registration_inactive', value => 'useDevRegInactiveEndpointReg', label_extra_instance => 1, + instance_use => 'display',template => '%d', min => 0 } + ] + } + } + ]; +} + +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 => { + 'filter-cluster:s' => { name => 'filter_cluster' }, + }); + return $self; +} + +sub prefix_cluster_output { + my ($self, %options) = @_; + + return "Cluster '" . $options{instance_value}->{display} . "' "; +} + +my $mapping = { + useDevRegClusterName => { oid => '.1.3.6.1.4.1.13885.13.2.3.3.1.2.1.2' }, + useDevRegActiveEndpointReg => { oid => '.1.3.6.1.4.1.13885.13.2.3.3.1.2.1.3' }, + useDevRegInactiveEndpointReg => { oid => '.1.3.6.1.4.1.13885.13.2.3.3.1.2.1.4' }, +}; + +my $oid_useDevRegistrationsEntry = '.1.3.6.1.4.1.13885.13.2.3.3.1.2.1'; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_useDevRegistrationsCount = '.1.3.6.1.4.1.13885.13.2.3.3.1.1.0'; + my $global_result = $options{snmp}->get_leef( + oids => [$oid_useDevRegistrationsCount], + nothing_quit => 1 + ); + + $self->{global} = { useDevRegistrationsCount => $global_result->{$oid_useDevRegistrationsCount} }; + + $self->{cluster} = {}; + my $cluster_result = $options{snmp}->get_table( + oid => $oid_useDevRegistrationsEntry, + nothing_quit => 1 + ); + + foreach my $oid (keys %{$cluster_result}) { + next if ($oid !~ /^$mapping->{useDevRegClusterName}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $cluster_result, instance => $instance); + + $result->{useDevRegClusterName} = centreon::plugins::misc::trim($result->{useDevRegClusterName}); + if (defined($self->{option_results}->{filter_cluster}) && $self->{option_results}->{filter_cluster} ne '' && + $result->{useDevRegClusterName} !~ /$self->{option_results}->{filter_cluster}/) { + $self->{output}->output_add(long_msg => "skipping '" . $result->{useDevRegClusterName} . "': no matching filter.", debug => 1); + next; + } + + $self->{cluster}->{$instance} = { + display => $result->{useDevRegClusterName}, + %$result + }; + } + +} + +1; + +__END__ + +=head1 MODE + +Check global and per-cluster devices registrations metrics. + +=over 8 + +=item B<--filter-cluster> + +Filter on one or several cluster (POSIX regexp) + +=item B<--warning-* --critical-*> + +Warning & Critical Thresholds. Possible values: + +[PER-CLUSTER] cluster-endpoint-active-registration cluster-endpoint-inactive-registration + +[GLOBAL] dma-total-registrations + +=back + +=cut diff --git a/centreon-plugins/hardware/devices/polycom/dma/snmp/mode/serversusage.pm b/centreon-plugins/hardware/devices/polycom/dma/snmp/mode/serversusage.pm new file mode 100644 index 000000000..c8d6e5b22 --- /dev/null +++ b/centreon-plugins/hardware/devices/polycom/dma/snmp/mode/serversusage.pm @@ -0,0 +1,369 @@ +# +# 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 hardware::devices::polycom::dma::snmp::mode::serversusage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub custom_memory_output { + my ($self, %options) = @_; + + my $msg = sprintf("Memory Total: %s %s, Used: %s %s (%.2f%%), Free: %s %s (%.2f%%)", + $self->{perfdata}->change_bytes(value => $self->{result_values}->{memory_total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{memory_used}), + $self->{result_values}->{memory_prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{memory_free}), + $self->{result_values}->{memory_prct_free} + ); + return $msg; +} + +sub custom_swap_output { + my ($self, %options) = @_; + + my $msg = sprintf("Swap Total: %s %s, Used: %s %s (%.2f%%), Free: %s %s (%.2f%%)", + $self->{perfdata}->change_bytes(value => $self->{result_values}->{swap_total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{swap_used}), + $self->{result_values}->{swap_prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{swap_free}), + $self->{result_values}->{swap_prct_free} + ); + return $msg; +} + +sub custom_disk_output { + my ($self, %options) = @_; + + my $msg = sprintf("Disk Total: %s %s, Used: %s %s (%.2f%%), Free: %s %s (%.2f%%)", + $self->{perfdata}->change_bytes(value => $self->{result_values}->{disk_total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{disk_used}), + $self->{result_values}->{disk_prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{disk_free}), + $self->{result_values}->{disk_prct_free} + ); + return $msg; +} + +sub custom_logs_output { + my ($self, %options) = @_; + + my $msg = sprintf("Logs Total: %s %s, Used: %s %s (%.2f%%), Free: %s %s (%.2f%%)", + $self->{perfdata}->change_bytes(value => $self->{result_values}->{logs_total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{logs_used}), + $self->{result_values}->{logs_prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{logs_free}), + $self->{result_values}->{logs_prct_free} + ); + return $msg; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'server', type => 1, cb_prefix_output => 'prefix_server_output', message_multiple => 'All servers are ok' } + ]; + + $self->{maps_counters}->{server} = [ + { label => 'server-cpu-usage', nlabel => 'dma.server.cpu.utilization.percentage', set => { + key_values => [ { name => 'stRsrcCPUUsageCPUUtilizationPct' }, { name => 'display'} ], + output_template => 'CPU Utilization : %.2f %%', + perfdatas => [ + { label => 'cpu_utilization', value => 'stRsrcCPUUsageCPUUtilizationPct', template => '%d', + label_extra_instance => 1, instance_use => 'display', min => 0, max => 100, unit => '%' } + ] + } + }, + # Memory counters + { label => 'server-memory-usage', nlabel => 'dma.server.memory.usage.bytes', set => { + key_values => [ { name => 'memory_used' }, { name => 'memory_free' }, { name => 'memory_prct_used' }, + { name => 'memory_prct_free' }, { name => 'memory_total' }, { name => 'display'} ], + closure_custom_output => $self->can('custom_memory_output'), + perfdatas => [ + { value => 'memory_used', template => '%d', label_extra_instance => 1, instance_use => 'display', + cast_int => 1, min => 0, max => 'total' } + ] + } + }, + { label => 'server-memory-free', display_ok => 0, nlabel => 'dma.server.memory.free.bytes', set => { + key_values => [ { name => 'memory_free' }, { name => 'memory_used' }, { name => 'memory_prct_used' }, + { name => 'memory_prct_free' }, { name => 'memory_total' } ], + closure_custom_output => $self->can('custom_memory_output'), + perfdatas => [ + { value => 'memory_free', template => '%d', label_extra_instance => 1, instance_use => 'display', + cast_int => 1, min => 0, max => 'total' } + ] + } + }, + { label => 'server-memory-prct', display_ok => 0, nlabel => 'dma.server.memory.usage.percentage', set => { + key_values => [ { name => 'memory_prct_used' } ], + output_template => 'RAM used: %.2f %%', + perfdatas => [ + { value => 'memory_prct_used', template => '%.2f', label_extra_instance => 1, instance_use => 'display', + min => 0, max => 100, unit => '%' } + ] + } + }, + # Swap counters + { label => 'server-swap-usage', nlabel => 'dma.server.swap.usage.percentage', set => { + key_values => [ { name => 'swap_used' }, { name => 'swap_free' }, { name => 'swap_prct_used' }, + { name => 'swap_prct_free' }, { name => 'swap_total' } ], + closure_custom_output => $self->can('custom_swap_output'), + perfdatas => [ + { value => 'swap_used', template => '%d', label_extra_instance => 1, instance_use => 'display', + cast_int => 1, min => 0, max => 'total' } + ] + } + }, + { label => 'server-swap-free', display_ok => 0, nlabel => 'dma.server.swap.free.bytes', set => { + key_values => [ { name => 'swap_free' }, { name => 'swap_used' }, { name => 'swap_prct_used' }, + { name => 'swap_prct_free' }, { name => 'swap_total' } ], + closure_custom_output => $self->can('custom_swap_output'), + perfdatas => [ + { value => 'swap_free', template => '%d', min => 0, max => 'total', + cast_int => 1, min => 0, max => 'total' } + ] + } + }, + { label => 'server-swap-prct', display_ok => 0, nlabel => 'dma.server.swap.usage.percentage', set => { + key_values => [ { name => 'swap_prct_used' } ], + output_template => 'RAM used: %.2f %%', + perfdatas => [ + { value => 'swap_prct_used', template => '%.2f', label_extra_instance => 1, instance_use => 'display', + min => 0, max => 100, unit => '%' } + ] + } + }, + # Disk counters + { label => 'server-disk-usage', nlabel => 'dma.server.disk.usage.bytes', set => { + key_values => [ { name => 'disk_used' }, { name => 'disk_free' }, { name => 'disk_prct_used' }, + { name => 'disk_prct_free' }, { name => 'disk_total' } ], + closure_custom_output => $self->can('custom_disk_output'), + perfdatas => [ + { value => 'disk_used', template => '%d', label_extra_instance => 1, instance_use => 'display', + min => 0, max => 'total', + cast_int => 1 } + ] + } + }, + { label => 'server-disk-free', display_ok => 0, nlabel => 'dma.server.disk.free.bytes', set => { + key_values => [ { name => 'disk_free' }, { name => 'disk_used' }, { name => 'disk_prct_used' }, + { name => 'disk_prct_free' }, { name => 'disk_total' } ], + closure_custom_output => $self->can('custom_disk_output'), + perfdatas => [ + { value => 'disk_free', template => '%d', label_extra_instance => 1, instance_use => 'display', + cast_int => 1, min => 0, max => 'total' } + ] + } + }, + { label => 'server-disk-prct', display_ok => 0, nlabel => 'dma.server.disk.usage.percentage', set => { + key_values => [ { name => 'disk_prct_used' } ], + output_template => 'RAM used: %.2f %%', + perfdatas => [ + { value => 'disk_prct_used', template => '%.2f', label_extra_instance => 1, instance_use => 'display', + min => 0, max => 100, unit => '%' } + ] + } + }, + # Log counters + { label => 'server-logs-usage', nlabel => 'dma.server.logs.usage.bytes', set => { + key_values => [ { name => 'logs_used' }, { name => 'logs_free' }, { name => 'logs_prct_used' }, + { name => 'logs_prct_free' }, { name => 'logs_total' } ], + closure_custom_output => $self->can('custom_logs_output'), + perfdatas => [ + { value => 'logs_used', template => '%d', label_extra_instance => 1, instance_use => 'display', + cast_int => 1, min => 0, max => 'total' } + ] + } + }, + { label => 'server-logs-free', display_ok => 0, nlabel => 'dma.server.logs.free.bytes', set => { + key_values => [ { name => 'logs_free' }, { name => 'logs_used' }, { name => 'logs_prct_used' }, + { name => 'logs_prct_free' }, { name => 'logs_total' } ], + closure_custom_output => $self->can('custom_logs_output'), + perfdatas => [ + { value => 'logs_free', template => '%d', label_extra_instance => 1, instance_use => 'display', + cast_int => 1, min => 0, max => 'total' } + ] + } + }, + { label => 'server-logs-prct', display_ok => 0, nlabel => 'dma.server.logs.usage.percentage', set => { + key_values => [ { name => 'logs_prct_used' } ], + output_template => 'RAM used: %.2f %%', + perfdatas => [ + { value => 'logs_prct_used', template => '%.2f', label_extra_instance => 1, instance_use => 'display', + 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 => { + 'filter-server:s' => { name => 'filter_server' }, + }); + + return $self; +} + +sub prefix_server_output { + my ($self, %options) = @_; + + return "Server '" . $options{instance_value}->{display} . "' "; +} + +my $mapping_cpu = { + stRsrcCPUUsageHostName => { oid => '.1.3.6.1.4.1.13885.13.2.2.1.4.1.1.2' }, + stRsrcCPUUsageCPUUtilizationPct => { oid => '.1.3.6.1.4.1.13885.13.2.2.1.4.1.1.3' } +}; + +my $mapping_memory = { + stRsrcMemUsageHostName => { oid => '.1.3.6.1.4.1.13885.13.2.2.1.4.2.1.2' }, + stRsrcMemUsageTotalMemory => { oid => '.1.3.6.1.4.1.13885.13.2.2.1.4.2.1.3' }, + stRsrcMemUsageBuffersAndCache => { oid => '.1.3.6.1.4.1.13885.13.2.2.1.4.2.1.4' }, + stRsrcMemUsageUsed => { oid => '.1.3.6.1.4.1.13885.13.2.2.1.4.2.1.5' }, + stRsrcMemUsageFree => { oid => '.1.3.6.1.4.1.13885.13.2.2.1.4.2.1.6' } +}; + +my $mapping_swap = { + stRsrcSwapHostName => { oid => '.1.3.6.1.4.1.13885.13.2.2.1.4.3.1.2' }, + stRsrcSwapTotal => { oid => '.1.3.6.1.4.1.13885.13.2.2.1.4.3.1.3' }, + stRsrcSwapUsed => { oid => '.1.3.6.1.4.1.13885.13.2.2.1.4.3.1.4' } +}; + +my $mapping_disk = { + stRsrcDiskHostName => { oid => '.1.3.6.1.4.1.13885.13.2.2.1.4.4.1.2' }, + stRsrcDiskTotal => { oid => '.1.3.6.1.4.1.13885.13.2.2.1.4.4.1.3' }, + stRsrcDiskUsed => { oid => '.1.3.6.1.4.1.13885.13.2.2.1.4.4.1.4' } +}; + +my $mapping_logs = { + stRsrcLogHostName => { oid => '.1.3.6.1.4.1.13885.13.2.2.1.4.5.1.2'}, + stRsrcLogTotal => { oid => '.1.3.6.1.4.1.13885.13.2.2.1.4.5.1.3'}, + stRsrcLogUsed => { oid => '.1.3.6.1.4.1.13885.13.2.2.1.4.5.1.4'} +}; + +my $oid_stRsrcCPUUsageEntry = '.1.3.6.1.4.1.13885.13.2.2.1.4.1.1'; +my $oid_stRsrcMemoryUsageEntry = '.1.3.6.1.4.1.13885.13.2.2.1.4.2.1'; +my $oid_stRsrcSwapUsageEntry = '.1.3.6.1.4.1.13885.13.2.2.1.4.3.1'; +my $oid_stRsrcDiskSpaceEntry = '.1.3.6.1.4.1.13885.13.2.2.1.4.4.1'; +my $oid_stRsrcLogSpaceEntry = '.1.3.6.1.4.1.13885.13.2.2.1.4.5.1'; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{server} = {}; + + $self->{server_result} = $options{snmp}->get_multiple_table( + oids => [ + { oid => $oid_stRsrcCPUUsageEntry }, + { oid => $oid_stRsrcMemoryUsageEntry }, + { oid => $oid_stRsrcSwapUsageEntry }, + { oid => $oid_stRsrcDiskSpaceEntry }, + { oid => $oid_stRsrcLogSpaceEntry }, + ], + nothing_quit => 1 + ); + + foreach my $oid (keys %{$self->{server_result}->{$oid_stRsrcCPUUsageEntry}}) { + next if ($oid !~ /^$mapping_cpu->{stRsrcCPUUsageHostName}->{oid}\.(.*)$/); + my $instance = $1; + + my $result_cpu = $options{snmp}->map_instance(mapping => $mapping_cpu, results => $self->{server_result}->{$oid_stRsrcCPUUsageEntry}, instance => $instance); + my $result_memory = $options{snmp}->map_instance(mapping => $mapping_memory, results => $self->{server_result}->{$oid_stRsrcMemoryUsageEntry}, instance => $instance); + my $result_swap = $options{snmp}->map_instance(mapping => $mapping_swap, results => $self->{server_result}->{$oid_stRsrcSwapUsageEntry}, instance => $instance); + my $result_disk = $options{snmp}->map_instance(mapping => $mapping_disk, results => $self->{server_result}->{$oid_stRsrcDiskSpaceEntry}, instance => $instance); + my $result_logs = $options{snmp}->map_instance(mapping => $mapping_logs, results => $self->{server_result}->{$oid_stRsrcLogSpaceEntry}, instance => $instance); + + $result_cpu->{stRsrcCPUUsageHostName} = centreon::plugins::misc::trim($result_cpu->{stRsrcCPUUsageHostName}); + if (defined($self->{option_results}->{filter_server}) && $self->{option_results}->{filter_server} ne '' && + $result_cpu->{stRsrcCPUUsageHostName} !~ /$self->{option_results}->{filter_server}/) { + $self->{output}->output_add(long_msg => "skipping '" . $result_cpu->{stRsrcCPUUsageHostName} . "': no matching filter.", debug => 1); + next; + } + + my ($memory_used, $memory_total) = (($result_memory->{stRsrcMemUsageUsed} + $result_memory->{stRsrcMemUsageBuffersAndCache} * 1024 * 1024), + $result_memory->{stRsrcMemUsageTotalMemory} * 1024 * 1024); + my ($swap_used, $swap_total) = (($result_swap->{stRsrcSwapUsed} * 1024 * 1024), ($result_swap->{stRsrcSwapTotal} * 1024 * 1024)); + my ($disk_used, $disk_total) = (($result_disk->{stRsrcDiskUsed} * 1024 * 1024), ($result_disk->{stRsrcDiskTotal} * 1024 * 1024)); + my ($logs_used, $logs_total) = (($result_logs->{stRsrcLogUsed} * 1024 * 1024, $result_logs->{stRsrcLogTotal} * 1024 * 1024)); + + $self->{server}->{$instance} = { + display => $result_cpu->{stRsrcCPUUsageHostName}, + stRsrcCPUUsageCPUUtilizationPct => $result_cpu->{stRsrcCPUUsageCPUUtilizationPct}, + memory_free => $memory_total - $memory_used, + memory_prct_free => 100 - ($memory_used * 100 / $memory_total), + memory_prct_used => ($memory_total != 0) ? $memory_used * 100 / $memory_total : '0', + memory_total => $memory_total, + memory_used => $memory_used, + swap_free => $swap_total - $swap_used, + swap_prct_free => 100 - ($swap_used * 100 / $swap_total), + swap_prct_used => ($swap_total != 0) ? $swap_used * 100 / $swap_total : '0', + swap_total => $swap_total, + swap_used => $swap_used, + disk_free => $disk_total - $disk_used, + disk_prct_free => 100 - ($disk_used * 100 / $disk_total), + disk_prct_used => ($disk_total != 0) ? $disk_used * 100 / $disk_total : '0', + disk_total => $disk_total, + disk_used => $disk_used, + logs_free => $logs_total - $logs_used, + logs_prct_free => 100 - ($logs_used * 100 / $logs_total), + logs_prct_used => ($logs_total != 0) ? $logs_used * 100 / $logs_total : '0', + logs_total => $logs_total, + logs_used => $logs_used + }; + } + +} + +1; + +__END__ + +=head1 MODE + +Check managed servers system usage metrics + +=over 8 + +=item B<--filter-server> + +Filter on one or several server (POSIX regexp) + +=item B<--warning-* --critical-*> + +Warning & Critical Thresholds. Possible values: + +[CPU] server-cpu-usage +[RAM] server-memory-usage server-memory-free server-memory-prct +[SWAP] server-swap-usage server-swap-free server-swap-prct +[DISK] server-disk-usage server-disk-free server-disk-prct +[LOGS] server-logs-usage server-logs-free server-logs-prct + +=back + +=cut diff --git a/centreon-plugins/hardware/devices/polycom/dma/snmp/plugin.pm b/centreon-plugins/hardware/devices/polycom/dma/snmp/plugin.pm new file mode 100644 index 000000000..d2cdcaf2d --- /dev/null +++ b/centreon-plugins/hardware/devices/polycom/dma/snmp/plugin.pm @@ -0,0 +1,60 @@ +# +# 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 hardware::devices::polycom::dma::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}} = ( + 'alerts' => 'hardware::devices::polycom::dma::snmp::mode::alerts', + 'clusters' => 'hardware::devices::polycom::dma::snmp::mode::clusters', + 'cpu' => 'snmp_standard::mode::cpu', + 'cpu-detailed' => 'snmp_standard::mode::cpudetailed', + 'conference-manager' => 'hardware::devices::polycom::dma::snmp::mode::conferencemanager', + 'device-registrations' => 'hardware::devices::polycom::dma::snmp::mode::deviceregistrations', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'load' => 'snmp_standard::mode::loadaverage', + 'memory' => 'snmp_standard::mode::memory', + 'servers-usage' => 'hardware::devices::polycom::dma::snmp::mode::serversusage', + 'storage' => 'snmp_standard::mode::storage', + 'swap' => 'snmp_standard::mode::swap', + 'uptime' => 'snmp_standard::mode::uptime', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Polycom DMA Cluster Manager in SNMP. + +=cut