diff --git a/hardware/devices/polycom/dma/snmp/mode/alerts.pm b/hardware/devices/polycom/dma/snmp/mode/alerts.pm index 24b33df9e..b1df50d63 100644 --- a/hardware/devices/polycom/dma/snmp/mode/alerts.pm +++ b/hardware/devices/polycom/dma/snmp/mode/alerts.pm @@ -31,9 +31,10 @@ 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; + return 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} + ); } sub custom_status_calc { @@ -47,7 +48,6 @@ sub custom_status_calc { return 0; } - sub set_counters { my ($self, %options) = @_; @@ -76,10 +76,10 @@ sub new { 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' } + '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( @@ -126,7 +126,7 @@ sub manage_selection { 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}); + $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'); } diff --git a/hardware/devices/polycom/dma/snmp/mode/clusters.pm b/hardware/devices/polycom/dma/snmp/mode/clusters.pm index 223fbf6d3..2e30582ec 100644 --- a/hardware/devices/polycom/dma/snmp/mode/clusters.pm +++ b/hardware/devices/polycom/dma/snmp/mode/clusters.pm @@ -38,20 +38,30 @@ sub set_counters { { 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 } ] + perfdatas => [ { template => '%d', min => 0 } ] } }, ]; $self->{maps_counters}->{cluster} = [ - { label => 'cluster-status', threshold => 0, display_ok => 0, set => { + { + label => 'cluster-status', + type => 2, + critical_default => '%{cluster_status} =~ /outOfService/i', + 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 => { + { + label => 'license-status', + type => 2, + critical_default => '%{license_status} =~ /invalid/i', + 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; }, @@ -59,29 +69,26 @@ sub set_counters { } }, { label => 'cluster-active-calls', nlabel => 'dma.cluster.activecalls.count', set => { - key_values => [ { name => 'active_calls' }, { name => 'licenses_total'}, { name => 'display'} ], + 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' } + { template => '%s', max => 'licenses_total', label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'cluster-license-usage-free', nlabel => 'dma.cluster.licenses.free.count', set => { - key_values => [ { name => 'licenses_free' }, { name => 'display'} ], + 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 } + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'cluster-license-usage-prct', nlabel => 'dma.cluster.licenses.usage.percentage', set => { - key_values => [ { name => 'licenses_used_prct' }, { name => 'display'} ], + 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 } + { template => '%.2f', min => 0, unit => '%', label_extra_instance => 1, instance_use => 'display' } ] } } @@ -106,32 +113,21 @@ sub custom_license_status_output { 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' }, + 'filter-cluster:s' => { name => 'filter_cluster' } }); + 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 } @@ -144,20 +140,18 @@ my $mapping_licenses = { 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} }; @@ -196,7 +190,6 @@ sub manage_selection { licenses_used_prct => ( $licenses_used * 100 ) / $licenses_total }; } - } 1; diff --git a/hardware/devices/polycom/dma/snmp/mode/conferencemanager.pm b/hardware/devices/polycom/dma/snmp/mode/conferencemanager.pm index b7f5202e8..fcb2573d4 100644 --- a/hardware/devices/polycom/dma/snmp/mode/conferencemanager.pm +++ b/hardware/devices/polycom/dma/snmp/mode/conferencemanager.pm @@ -28,27 +28,27 @@ use warnings; sub custom_video_port_output { my ($self, %options) = @_; - my $msg = sprintf("video ports [total: %s used: %s (%.2f%%) free: %s (%.2f%%)]", + return 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%%)]", + return 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 { @@ -64,8 +64,7 @@ sub set_counters { 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 } + { template => '%d', min => 0, instance_use => 'display', template => '%d', min => 0 } ] } } @@ -73,96 +72,94 @@ sub set_counters { $self->{maps_counters}->{cluster} = [ { label => 'cluster-conferences', nlabel => 'dma.cluster.conferences.active.count', set => { - key_values => [ { name => 'useCMUsageActiveConfs' }, { name => 'display'} ], + 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 } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'cluster-participants', nlabel => 'dma.cluster.participants.active.count', set => { - key_values => [ { name => 'useCMUsageActiveParts' }, { name => 'display'} ], + 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 } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'cluster-local-users', nlabel => 'dma.cluster.local.database.users.count', set => { - key_values => [ { name => 'useCMUsageLocalUsers' }, { name => 'display'} ], + 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 } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'cluster-custom-rooms', nlabel => 'dma.cluster.custom.conference.rooms.count', set => { - key_values => [ { name => 'useCMUsageCustomConfRooms' }, { name => 'display'} ], + 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 } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, { 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'} ], + 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 } + { template => '%d', min => 0, max => 'total', cast_int => 1, label_extra_instance => 1, instance_use => 'display' } ] } }, { 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'} ], + 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 } + { template => '%d', min => 0, max => 'total', cast_int => 1, label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'cluster-video-ports-prct', display_ok => 0, nlabel => 'dma.cluster.video.port.percentage', set => { - key_values => [ { name => 'vp_prct_used' }, { name => 'display'} ], + 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 => '%' } + { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' } ] } }, { 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'} ], + 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 } + { template => '%d', min => 0, max => 'total', cast_int => 1, label_extra_instance => 1, instance_use => 'display' } ] } }, { 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'} ], + 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 } + { template => '%d', min => 0, max => 'total', cast_int => 1, label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'cluster-voice-ports-prct', display_ok => 0, nlabel => 'dma.cluster.voice.port.percentage', set => { - key_values => [ { name => 'vop_prct_used' }, { name => 'display'} ], + 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 => '%' } + { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' } ] } } @@ -175,7 +172,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'filter-cluster:s' => { name => 'filter_cluster' }, + 'filter-cluster:s' => { name => 'filter_cluster' } }); return $self; diff --git a/hardware/devices/polycom/dma/snmp/mode/deviceregistrations.pm b/hardware/devices/polycom/dma/snmp/mode/deviceregistrations.pm index c5680932e..1a1f27f0e 100644 --- a/hardware/devices/polycom/dma/snmp/mode/deviceregistrations.pm +++ b/hardware/devices/polycom/dma/snmp/mode/deviceregistrations.pm @@ -38,8 +38,7 @@ sub set_counters { 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 } + { template => '%d', min => 0 } ] } } @@ -48,19 +47,17 @@ sub set_counters { $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', + output_template => 'endpoint active registrations: %s', perfdatas => [ - { label => 'endpoint_registration_active', value => 'useDevRegActiveEndpointReg', label_extra_instance => 1, - instance_use => 'display', template => '%d', min => 0 } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, { 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', + output_template => 'endpoint inactive registrations: %s', perfdatas => [ - { label => 'endpoint_registration_inactive', value => 'useDevRegInactiveEndpointReg', label_extra_instance => 1, - instance_use => 'display',template => '%d', min => 0 } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } } @@ -126,7 +123,6 @@ sub manage_selection { %$result }; } - } 1; diff --git a/hardware/devices/polycom/dma/snmp/mode/serversusage.pm b/hardware/devices/polycom/dma/snmp/mode/serversusage.pm index c8d6e5b22..da5925e56 100644 --- a/hardware/devices/polycom/dma/snmp/mode/serversusage.pm +++ b/hardware/devices/polycom/dma/snmp/mode/serversusage.pm @@ -28,53 +28,53 @@ use warnings; sub custom_memory_output { my ($self, %options) = @_; - my $msg = sprintf("Memory Total: %s %s, Used: %s %s (%.2f%%), Free: %s %s (%.2f%%)", + return 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%%)", + return 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%%)", + return 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%%)", + return 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 { @@ -87,134 +87,136 @@ sub set_counters { $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 %%', + 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 => '%' } + { template => '%d', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' } ] } }, # 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'} ], + 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' } + { template => '%d', cast_int => 1, min => 0, max => 'memory_total', label_extra_instance => 1, instance_use => 'display' } ] } }, { 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' } ], + key_values => [ + { name => 'memory_free' }, { name => 'memory_used' }, { name => 'memory_prct_used' }, + { name => 'memory_prct_free' }, { name => 'memory_total' }, { name => 'display' } + ], 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' } + { template => '%d', cast_int => 1, min => 0, max => 'memory_total', label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'server-memory-prct', display_ok => 0, nlabel => 'dma.server.memory.usage.percentage', set => { - key_values => [ { name => 'memory_prct_used' } ], + key_values => [ { name => 'memory_prct_used' }, { name => 'display' } ], output_template => 'RAM used: %.2f %%', perfdatas => [ - { value => 'memory_prct_used', template => '%.2f', label_extra_instance => 1, instance_use => 'display', - min => 0, max => 100, unit => '%' } + { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' } ] } }, # 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' } ], + key_values => [ + { name => 'swap_used' }, { name => 'swap_free' }, { name => 'swap_prct_used' }, + { name => 'swap_prct_free' }, { name => 'swap_total' }, { name => 'display' } + ], 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' } + { template => '%d', cast_int => 1, min => 0, max => 'swap_total', label_extra_instance => 1, instance_use => 'display' } ] } }, { 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' } ], + key_values => [ + { name => 'swap_free' }, { name => 'swap_used' }, { name => 'swap_prct_used' }, + { name => 'swap_prct_free' }, { name => 'swap_total' }, { name => 'display' } + ], 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' } + { template => '%d', cast_int => 1, min => 0, max => 'swap_total', label_extra_instance => 1, instance_use => 'display' } ] } }, { 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 %%', + key_values => [ { name => 'swap_prct_used' }, { name => 'display' } ], + output_template => 'swap used: %.2f %%', perfdatas => [ - { value => 'swap_prct_used', template => '%.2f', label_extra_instance => 1, instance_use => 'display', - min => 0, max => 100, unit => '%' } + { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' } ] } }, # 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' } ], + key_values => [ + { name => 'disk_used' }, { name => 'disk_free' }, { name => 'disk_prct_used' }, + { name => 'disk_prct_free' }, { name => 'disk_total' }, { name => 'display' } + ], 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 } + { template => '%d', min => 0, max => 'disk_total', cast_int => 1, label_extra_instance => 1, instance_use => 'display' } ] } }, { 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' } ], + key_values => [ + { name => 'disk_free' }, { name => 'disk_used' }, { name => 'disk_prct_used' }, + { name => 'disk_prct_free' }, { name => 'disk_total' }, { name => 'display' } + ], 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' } + { template => '%d', cast_int => 1, min => 0, max => 'disk_total', label_extra_instance => 1, instance_use => 'display', } ] } }, { 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 %%', + key_values => [ { name => 'disk_prct_used' }, { name => 'display' } ], + output_template => 'disk used: %.2f %%', perfdatas => [ - { value => 'disk_prct_used', template => '%.2f', label_extra_instance => 1, instance_use => 'display', - min => 0, max => 100, unit => '%' } + { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' } ] } }, # 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' } ], + key_values => [ + { name => 'logs_used' }, { name => 'logs_free' }, { name => 'logs_prct_used' }, + { name => 'logs_prct_free' }, { name => 'logs_total' }, { name => 'display' } + ], 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' } + { template => '%d', cast_int => 1, min => 0, max => 'logs_total', label_extra_instance => 1, instance_use => 'display' } ] } }, { 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' } ], + key_values => [ + { name => 'logs_free' }, { name => 'logs_used' }, { name => 'logs_prct_used' }, + { name => 'logs_prct_free' }, { name => 'logs_total' }, { name => 'display' } + ], 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' } + { template => '%d', cast_int => 1, min => 0, max => 'logs_total', label_extra_instance => 1, instance_use => 'display' } ] } }, { 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 %%', + key_values => [ { name => 'logs_prct_used' }, { name => 'display' } ], + output_template => 'logs used: %.2f %%', perfdatas => [ - { value => 'logs_prct_used', template => '%.2f', label_extra_instance => 1, instance_use => 'display', - min => 0, max => 100, unit => '%' } + { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' } ] } - }, + } ]; } @@ -224,7 +226,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'filter-server:s' => { name => 'filter_server' }, + 'filter-server:s' => { name => 'filter_server' } }); return $self; @@ -276,28 +278,27 @@ 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( + my $snmp_result = $options{snmp}->get_multiple_table( oids => [ { oid => $oid_stRsrcCPUUsageEntry }, { oid => $oid_stRsrcMemoryUsageEntry }, { oid => $oid_stRsrcSwapUsageEntry }, { oid => $oid_stRsrcDiskSpaceEntry }, - { oid => $oid_stRsrcLogSpaceEntry }, + { oid => $oid_stRsrcLogSpaceEntry } ], nothing_quit => 1 ); - foreach my $oid (keys %{$self->{server_result}->{$oid_stRsrcCPUUsageEntry}}) { + $self->{server} = {}; + foreach my $oid (keys %{$snmp_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); + my $result_cpu = $options{snmp}->map_instance(mapping => $mapping_cpu, results => $snmp_result->{$oid_stRsrcCPUUsageEntry}, instance => $instance); + my $result_memory = $options{snmp}->map_instance(mapping => $mapping_memory, results => $snmp_result->{$oid_stRsrcMemoryUsageEntry}, instance => $instance); + my $result_swap = $options{snmp}->map_instance(mapping => $mapping_swap, results => $snmp_result->{$oid_stRsrcSwapUsageEntry}, instance => $instance); + my $result_disk = $options{snmp}->map_instance(mapping => $mapping_disk, results => $snmp_result->{$oid_stRsrcDiskSpaceEntry}, instance => $instance); + my $result_logs = $options{snmp}->map_instance(mapping => $mapping_logs, results => $snmp_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 '' && diff --git a/hardware/devices/polycom/dma/snmp/plugin.pm b/hardware/devices/polycom/dma/snmp/plugin.pm index d2cdcaf2d..b14dd5c05 100644 --- a/hardware/devices/polycom/dma/snmp/plugin.pm +++ b/hardware/devices/polycom/dma/snmp/plugin.pm @@ -30,7 +30,7 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - %{$self->{modes}} = ( + $self->{modes} = { 'alerts' => 'hardware::devices::polycom::dma::snmp::mode::alerts', 'clusters' => 'hardware::devices::polycom::dma::snmp::mode::clusters', 'cpu' => 'snmp_standard::mode::cpu', @@ -43,8 +43,8 @@ sub new { 'servers-usage' => 'hardware::devices::polycom::dma::snmp::mode::serversusage', 'storage' => 'snmp_standard::mode::storage', 'swap' => 'snmp_standard::mode::swap', - 'uptime' => 'snmp_standard::mode::uptime', - ); + 'uptime' => 'snmp_standard::mode::uptime' + }; return $self; }