diff --git a/centreon-plugins/storage/qnap/snmp/mode/components/disk.pm b/centreon-plugins/storage/qnap/snmp/mode/components/disk.pm index af38a068d..391602142 100644 --- a/centreon-plugins/storage/qnap/snmp/mode/components/disk.pm +++ b/centreon-plugins/storage/qnap/snmp/mode/components/disk.pm @@ -37,57 +37,181 @@ my $map_smartinfo = { -1 => 'error' }; -# In MIB 'NAS.mib' my $mapping = { - description => { oid => '.1.3.6.1.4.1.24681.1.2.11.1.2' }, # hdDescr - temperature => { oid => '.1.3.6.1.4.1.24681.1.2.11.1.3' }, # hdTemperature - status => { oid => '.1.3.6.1.4.1.24681.1.2.11.1.4', map => $map_status_disk }, # HdStatus - smartinfo => { oid => '.1.3.6.1.4.1.24681.1.2.11.1.7' } # HdSmartInfo + legacy => { + description => { oid => '.1.3.6.1.4.1.24681.1.2.11.1.2' }, # hdDescr + temperature => { oid => '.1.3.6.1.4.1.24681.1.2.11.1.3' }, # hdTemperature ("40 C/104 F") + status => { oid => '.1.3.6.1.4.1.24681.1.2.11.1.4', map => $map_status_disk }, # HdStatus + smartinfo => { oid => '.1.3.6.1.4.1.24681.1.2.11.1.7' } # HdSmartInfo + }, + ex => { + description => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.5.2.1.2' }, # diskID + status => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.5.2.1.5', map => $map_smartinfo }, # diskSmartInfo + temperature => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.5.2.1.6' } # diskTemperture + }, + es => { + description => { oid => '.1.3.6.1.4.1.24681.2.2.11.1.2' }, # es-HdDescr + temperature => { oid => '.1.3.6.1.4.1.24681.2.2.11.1.3' }, # es-HdTemperature ("26 C/78.8 F") + status => { oid => '.1.3.6.1.4.1.24681.2.2.11.1.4' }, # es-HdStatus + smartinfo => { oid => '.1.3.6.1.4.1.24681.2.2.11.1.7' } # es-HdSmartInfo + } }; -my $mapping2 = { - description => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.5.2.1.2' }, # diskID - status => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.5.2.1.5', map => $map_smartinfo }, # diskSmartInfo - temperature => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.5.2.1.6' } # diskTemperture -}; -my $oid_HdEntry = '.1.3.6.1.4.1.24681.1.2.11.1'; -my $oid_diskTableEntry = '.1.3.6.1.4.1.24681.1.4.1.1.1.1.5.2.1'; -sub load { - my ($self) = @_; - - push @{$self->{request}}, { oid => $oid_HdEntry, start => $mapping->{description}->{oid} }; - push @{$self->{request}}, { - oid => $oid_diskTableEntry, - start => $mapping2->{description}->{oid}, - end => $mapping2->{temperature}->{oid} - }; -} +sub load {} -sub check_disk { +sub check_disk_legacy { my ($self, %options) = @_; return if (defined($self->{disk_checked})); - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $options{entry} }})) { - next if ($oid !~ /^$options{mapping}->{description}->{oid}\.(\d+)$/); - my $instance = $1; - $self->{disk_checked} = 1; + my $snmp_result = $self->{snmp}->get_table( + oid => '.1.3.6.1.4.1.24681.1.2.11', # systemHdTable + start => $mapping->{description}->{oid} + ); - my $result = $self->{snmp}->map_instance(mapping => $options{mapping}, results => $self->{results}->{ $options{entry} }, instance => $instance); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) { + next if ($oid !~ /^$mapping->{legacy}->{description}->{oid}\.(\d+)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping->{legacy}, results => $snmp_result, instance => $instance); next if ($self->check_filter(section => 'disk', instance => $instance)); - next if ($result->{status} eq 'noDisk' && - $self->absent_problem(section => 'disk', instance => $instance)); - + next if ( + $result->{status} eq 'noDisk' && + $self->absent_problem(section => 'disk', instance => $instance) + ); + $self->{components}->{disk}->{total}++; $self->{output}->output_add( long_msg => sprintf( - "Disk '%s' [instance: %s, temperature: %s, smart status: %s] status is %s.", + "disk '%s' status is %s [instance: %s, temperature: %s, smart status: %s]", $result->{description}, + $result->{status}, + $instance, + $result->{temperature}, + defined($result->{smartinfo}) ? $result->{smartinfo} : '-', + ) + ); + my $exit = $self->get_severity(section => 'disk', instance => $instance, value => $result->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Disk '%s' status is %s.", $result->{description}, $result->{status} + ) + ); + } + + if (defined($result->{smartinfo})) { + $exit = $self->get_severity(section => 'smartdisk', value => $result->{smartinfo}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Disk '%s' smart status is %s.", $result->{description}, $result->{smartinfo} + ) + ); + } + } + + next if ($result->{temperature} !~ /([0-9]+)/); + + my $disk_temp = $1; + my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'disk', instance => $instance, value => $disk_temp); + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit2, + short_msg => sprintf( + "Disk '%s' temperature is %s degree centigrade", $result->{description}, $disk_temp + ) + ); + } + $self->{output}->perfdata_add( + nlabel => 'hardware.disk.temperature.celsius', + unit => 'C', + instances => $instance, + value => $disk_temp + ); + } +} + +sub check_disk_ex { + my ($self, %options) = @_; + + my $snmp_result = $self->{snmp}->get_table( + oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.5.2', # diskTable + start => $mapping->{ex}->{description}->{oid}, + end => $mapping->{ex}->{temperature}->{oid} + ); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) { + next if ($oid !~ /^$mapping->{ex}->{description}->{oid}\.(\d+)$/); + my $instance = $1; + $self->{disk_checked} = 1; + + my $result = $self->{snmp}->map_instance(mapping => $mapping->{ex}, results => $snmp_result, instance => $instance); + + next if ($self->check_filter(section => 'disk', instance => $instance)); + + $self->{components}->{disk}->{total}++; + $self->{output}->output_add( + long_msg => sprintf( + "disk '%s' status is %s [instance: %s, temperature: %s]", + $result->{description}, + $result->{status}, + $instance, + $result->{temperature} + ) + ); + my $exit = $self->get_severity(section => 'disk', instance => $instance, value => $result->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Disk '%s' status is %s.", $result->{description}, $result->{status} + ) + ); + } + + next if ($result->{temperature} !~ /([0-9]+)/); + + my $disk_temp = $1; + my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'disk', instance => $instance, value => $disk_temp); + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit2, + short_msg => sprintf( + "Disk '%s' temperature is %s degree centigrade", $result->{description}, $disk_temp + ) + ); + } + $self->{output}->perfdata_add( + nlabel => 'hardware.disk.temperature.celsius', + unit => 'C', + instances => $instance, + value => $disk_temp + ); + } +} + +sub check_disk_es { + my ($self, %options) = @_; + + my $snmp_result = $self->{snmp}->get_table(oid => '.1.3.6.1.4.1.24681.2.2.11'); # es-SystemHdTable + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) { + next if ($oid !~ /^$mapping->{es}->{description}->{oid}\.(\d+)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping->{es}, results => $snmp_result, instance => $instance); + + next if ($self->check_filter(section => 'disk', instance => $instance)); + + $self->{components}->{disk}->{total}++; + $self->{output}->output_add( + long_msg => sprintf( + "disk '%s' status is %s [instance: %s, temperature: %s, smart status: %s]", + $result->{description}, + $result->{status}, $instance, $result->{temperature}, defined($result->{smartinfo}) ? $result->{smartinfo} : '-', - $result->{status} ) ); my $exit = $self->get_severity(section => 'disk', instance => $instance, value => $result->{status}); @@ -125,7 +249,6 @@ sub check_disk { ); } $self->{output}->perfdata_add( - label => 'temp_disk', nlabel => 'hardware.disk.temperature.celsius', unit => 'C', instances => $instance, @@ -141,16 +264,12 @@ sub check { $self->{components}->{disk} = { name => 'disks', total => 0, skip => 0 }; return if ($self->check_filter(section => 'disk')); - check_disk( - $self, - mapping => $mapping2, - entry => $oid_diskTableEntry - ); - check_disk( - $self, - mapping => $mapping, - entry => $oid_HdEntry - ); + if ($self->{is_es} == 1) { + check_disk_es($self); + } else { + check_disk_ex($self); + check_disk_legacy($self); + } } 1; diff --git a/centreon-plugins/storage/qnap/snmp/mode/components/fan.pm b/centreon-plugins/storage/qnap/snmp/mode/components/fan.pm index 2644832a1..0ea84301d 100644 --- a/centreon-plugins/storage/qnap/snmp/mode/components/fan.pm +++ b/centreon-plugins/storage/qnap/snmp/mode/components/fan.pm @@ -23,44 +23,48 @@ package storage::qnap::snmp::mode::components::fan; use strict; use warnings; -# In MIB 'NAS.mib' -my $mapping = { - description => { oid => '.1.3.6.1.4.1.24681.1.2.15.1.2' }, # sysFanDescr - speed => { oid => '.1.3.6.1.4.1.24681.1.2.15.1.3' } # sysFanSpeed +my $map_status = { + 0 => 'ok', -1 => 'fail' }; -my $oid_systemFanTable = '.1.3.6.1.4.1.24681.1.2.15'; -sub load { - my ($self) = @_; +my $mapping = { + legacy => { + description => { oid => '.1.3.6.1.4.1.24681.1.2.15.1.2' }, # sysFanDescr + speed => { oid => '.1.3.6.1.4.1.24681.1.2.15.1.3' } # sysFanSpeed + }, + ex => { + description => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.2.2.1.2' }, # systemFanID + status => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.2.2.1.4', map => $map_status }, # systemFanStatus + speed => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.2.2.1.5' }, # systemFanSpeed + }, + es => { + description => { oid => '.1.3.6.1.4.1.24681.2.2.15.1.2' }, # es-SysFanDescr + speed => { oid => '.1.3.6.1.4.1.24681.2.2.15.1.3' } # es-SysFanSpeed + } +}; + +sub load {} + +sub check_fan_result { + my ($self, %options) = @_; - push @{$self->{request}}, { - oid => $oid_systemFanTable, - start => $mapping->{description}->{oid}, - end => $mapping->{speed}->{oid} - }; -} - -sub check { - my ($self) = @_; - - $self->{output}->output_add(long_msg => "Checking fans"); - $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; - return if ($self->check_filter(section => 'fan')); - - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_systemFanTable}})) { - next if ($oid !~ /^$mapping->{description}->{oid}\.(.*)$/); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$options{snmp_result}})) { + next if ($oid !~ /^$mapping->{ $options{type} }->{description}->{oid}\.(.*)$/); my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_systemFanTable}, instance => $instance); + $self->{fan_checked} = 1; + + my $result = $self->{snmp}->map_instance(mapping => $mapping->{ $options{type} }, results => $options{snmp_result}, instance => $instance); + + next if ($self->check_filter(section => 'fan', instance => $instance)); + $self->{components}->{fan}->{total}++; $result->{speed} = defined($result->{speed}) ? $result->{speed} : 'unknown'; - - next if ($self->check_filter(section => 'fan', instance => $instance)); - - $self->{components}->{fan}->{total}++; + $result->{status} = defined($result->{status}) ? $result->{status} : 'n/a'; $self->{output}->output_add( long_msg => sprintf( - "fan '%s' speed is '%s' [instance: %s]", - $result->{description}, $result->{speed}, $instance + "fan '%s' speed is %s [instance: %s, status: %s]", + $result->{description}, $result->{speed}, $instance, + $result->{status} ) ); @@ -86,4 +90,51 @@ sub check { } } +sub check_fan_es { + my ($self, %options) = @_; + + my $snmp_result = $self->{snmp}->get_table( + oid => '.1.3.6.1.4.1.24681.2.2.15', # es-SystemFanTable + start => $mapping->{es}->{description}->{oid} + ); + check_fan_result($self, type => 'es', snmp_result => $snmp_result); +} + +sub check_fan_legacy { + my ($self, %options) = @_; + + return if (defined($self->{fan_checked})); + + my $snmp_result = $self->{snmp}->get_table( + oid => '.1.3.6.1.4.1.24681.1.2.15', # systemFanTable + start => $mapping->{legacy}->{description}->{oid} + ); + check_fan_result($self, type => 'legacy', snmp_result => $snmp_result); +} + +sub check_fan_ex { + my ($self, %options) = @_; + + my $snmp_result = $self->{snmp}->get_table( + oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.2.2', # systemFan2Table + start => $mapping->{ex}->{status}->{oid} + ); + check_fan_result($self, type => 'ex', snmp_result => $snmp_result); +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking fans"); + $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; + return if ($self->check_filter(section => 'fan')); + + if ($self->{is_es} == 1) { + check_fan_es($self); + } else { + check_fan_ex($self); + check_fan_legacy($self); + } +} + 1; diff --git a/centreon-plugins/storage/qnap/snmp/mode/components/mdisk.pm b/centreon-plugins/storage/qnap/snmp/mode/components/mdisk.pm new file mode 100644 index 000000000..54020eb2f --- /dev/null +++ b/centreon-plugins/storage/qnap/snmp/mode/components/mdisk.pm @@ -0,0 +1,124 @@ +# +# Copyright 2021 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package storage::qnap::snmp::mode::components::mdisk; + +use strict; +use warnings; + +my $map_smartinfo = { + 2 => 'abnormal', + 1 => 'warning', + 0 => 'good', + -1 => 'error' +}; + +my $mapping = { + ex => { + description => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.6.2.1.2' }, # msatadiskID + status => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.6.2.1.4' }, # msatadiskSummary + smartinfo => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.6.2.1.5', map => $map_smartinfo }, # msatadiskSmartInfo + temperature => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.6.2.1.6' } # msatadiskTemperature + } +}; + +sub load {} + +sub check_mdisk_ex { + my ($self) = @_; + + my $snmp_result = $self->{snmp}->get_table( + oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.6.2', # msataDiskTable + start => $mapping->{ex}->{description}->{oid}, + end => $mapping->{ex}->{temperature}->{oid} + ); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) { + next if ($oid !~ /^$mapping->{ex}->{description}->{oid}\.(\d+)$/); + my $instance = $1; + + my $result = $self->{snmp}->map_instance(mapping => $mapping->{ex}, results => $snmp_result, instance => $instance); + + next if ($self->check_filter(section => 'mdisk', instance => $instance)); + + $self->{components}->{mdisk}->{total}++; + $self->{output}->output_add( + long_msg => sprintf( + "mDisk '%s' status is %s [instance: %s, temperature: %s, smart status: %s]", + $result->{description}, + $result->{status}, + $instance, + $result->{temperature}, + $result->{smartinfo} + ) + ); + my $exit = $self->get_severity(label => 'disk', section => 'mdisk', instance => $instance, value => $result->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "mDisk '%s' status is %s.", $result->{description}, $result->{status} + ) + ); + } + + $exit = $self->get_severity(section => 'smartdisk', value => $result->{smartinfo}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "mDisk '%s' smart status is %s.", $result->{description}, $result->{smartinfo} + ) + ); + } + + next if ($result->{temperature} !~ /([0-9]+)/); + + my $disk_temp = $1; + my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'mdisk', instance => $instance, value => $disk_temp); + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit2, + short_msg => sprintf( + "mDisk '%s' temperature is %s degree centigrade", $result->{description}, $disk_temp + ) + ); + } + $self->{output}->perfdata_add( + nlabel => 'hardware.mdisk.temperature.celsius', + unit => 'C', + instances => $instance, + value => $disk_temp + ); + } +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'Checking mdisks'); + $self->{components}->{mdisk} = { name => 'mdisks', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'mdisk')); + + if ($self->{is_es} == 0) { + check_mdisk_ex($self); + } +} + +1; diff --git a/centreon-plugins/storage/qnap/snmp/mode/components/psu.pm b/centreon-plugins/storage/qnap/snmp/mode/components/psu.pm index e030099e0..381ab5094 100644 --- a/centreon-plugins/storage/qnap/snmp/mode/components/psu.pm +++ b/centreon-plugins/storage/qnap/snmp/mode/components/psu.pm @@ -28,33 +28,27 @@ my $map_status = { }; my $mapping = { - status => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.3.2.1.4', map => $map_status }, # systemPowerStatus - speed => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.3.2.1.5' }, # systemPowerFanSpeed - temperature => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.3.2.1.6' } # systemPowerTemp + ex => { + status => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.3.2.1.4', map => $map_status }, # systemPowerStatus + speed => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.3.2.1.5' }, # systemPowerFanSpeed + temperature => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.3.2.1.6' } # systemPowerTemp + }, + es => { + status => { oid => '.1.3.6.1.4.1.24681.2.2.21.1.4' }, # es-SysPowerStatus + speed => { oid => '.1.3.6.1.4.1.24681.2.2.21.1.5' }, # es-SysPowerFanSpeed + temperature => { oid => '.1.3.6.1.4.1.24681.2.2.21.1.6' } # es-SysPowerTemp + } }; -my $oid_systemPowerTable = '.1.3.6.1.4.1.24681.1.4.1.1.1.1.3.2'; -sub load { - my ($self) = @_; - - push @{$self->{request}}, { - oid => $oid_systemPowerTable, - start => $mapping->{status}->{oid}, - end => $mapping->{temperature}->{oid} - }; -} +sub load {} -sub check { - my ($self) = @_; +sub check_psu_result { + my ($self, %options) = @_; - $self->{output}->output_add(long_msg => "Checking power supplies"); - $self->{components}->{psu} = { name => 'psu', total => 0, skip => 0 }; - return if ($self->check_filter(section => 'psu')); - - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_systemPowerTable}})) { - next if ($oid !~ /^$mapping->{status}->{oid}\.(.*)$/); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$options{snmp_result}})) { + next if ($oid !~ /^$mapping->{ $options{type} }->{status}->{oid}\.(.*)$/); my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_systemPowerTable}, instance => $instance); + my $result = $self->{snmp}->map_instance(mapping => $mapping->{ $options{type} }, results => $options{snmp_result}, instance => $instance); next if ($self->check_filter(section => 'psu', instance => $instance)); @@ -76,7 +70,7 @@ sub check { ); } - if ($result->{speed} =~ /[0-9]/) { + if ($result->{speed} !~ /[0-9]/) { my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'psu.fanspeed', instance => $instance, value => $result->{speed}); if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { $self->{output}->output_add( @@ -117,4 +111,38 @@ sub check { } } +sub check_psu_es { + my ($self, %options) = @_; + + my $snmp_result = $self->{snmp}->get_table( + oid => '.1.3.6.1.4.1.24681.2.2.21', # es-SystemPowerTable + start => $mapping->{es}->{status}->{oid} + ); + check_psu_result($self, type => 'es', snmp_result => $snmp_result); +} + +sub check_psu_ex { + my ($self, %options) = @_; + + my $snmp_result = $self->{snmp}->get_table( + oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.3.2', # systemPowerTable + start => $mapping->{ex}->{status}->{oid} + ); + check_psu_result($self, type => 'ex', snmp_result => $snmp_result); +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking power supplies"); + $self->{components}->{psu} = { name => 'psu', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'psu')); + + if ($self->{is_es} == 1) { + check_psu_es($self); + } else { + check_psu_ex($self); + } +} + 1; diff --git a/centreon-plugins/storage/qnap/snmp/mode/components/raid.pm b/centreon-plugins/storage/qnap/snmp/mode/components/raid.pm index 6735e3bb1..fda5922db 100644 --- a/centreon-plugins/storage/qnap/snmp/mode/components/raid.pm +++ b/centreon-plugins/storage/qnap/snmp/mode/components/raid.pm @@ -23,29 +23,21 @@ package storage::qnap::snmp::mode::components::raid; use strict; use warnings; -# In MIB 'NAS.mib' -my $oid_raidStatus = '.1.3.6.1.4.1.24681.1.4.1.1.1.2.1.2.1.5'; +sub load {} -sub load { - my ($self) = @_; - - push @{$self->{request}}, { oid => $oid_raidStatus }; -} - -sub check { +sub check_raid_ex { my ($self) = @_; - $self->{output}->output_add(long_msg => "Checking raids"); - $self->{components}->{raid} = {name => 'raids', total => 0, skip => 0}; - return if ($self->check_filter(section => 'raid')); - - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raidStatus}})) { + my $snmp_result = $self->{snmp}->get_table( + oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.2.1.2.1.5', # raidStatus + ); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) { $oid =~ /\.(\d+)$/; my $instance = $1; next if ($self->check_filter(section => 'raid', instance => $instance)); - - my $status = $self->{results}->{$oid_raidStatus}->{$oid}; + + my $status = $snmp_result->{$oid}; $self->{components}->{raid}->{total}++; $self->{output}->output_add( long_msg => sprintf( @@ -65,4 +57,16 @@ sub check { } } +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking raids"); + $self->{components}->{raid} = {name => 'raids', total => 0, skip => 0}; + return if ($self->check_filter(section => 'raid')); + + if ($self->{is_es} == 0) { + check_raid_ex($self); + } +} + 1; diff --git a/centreon-plugins/storage/qnap/snmp/mode/components/temperature.pm b/centreon-plugins/storage/qnap/snmp/mode/components/temperature.pm index 8181aaea1..95d46d226 100644 --- a/centreon-plugins/storage/qnap/snmp/mode/components/temperature.pm +++ b/centreon-plugins/storage/qnap/snmp/mode/components/temperature.pm @@ -23,40 +23,33 @@ package storage::qnap::snmp::mode::components::temperature; use strict; use warnings; -# In MIB 'NAS.mib' my $oid_CPU_Temperature_entry = '.1.3.6.1.4.1.24681.1.2.5'; my $oid_CPU_Temperature = '.1.3.6.1.4.1.24681.1.2.5.0'; my $oid_SystemTemperature_entry = '.1.3.6.1.4.1.24681.1.2.6'; my $oid_SystemTemperature = '.1.3.6.1.4.1.24681.1.2.6.0'; my $mapping = { - cpu_temp => { oid => '.1.3.6.1.4.1.24681.1.2.5' }, # cpu-Temperature - system_temp => { oid => '.1.3.6.1.4.1.24681.1.2.6' }, # systemTemperature + legacy => { + cpu_temp => { oid => '.1.3.6.1.4.1.24681.1.2.5' }, # cpu-Temperature + system_temp => { oid => '.1.3.6.1.4.1.24681.1.2.6' } # systemTemperature + }, + ex => { + cpu_temp => { oid => '.1.3.6.1.4.1.24681.1.3.5' }, # cpu-TemperatureEX + system_temp => { oid => '.1.3.6.1.4.1.24681.1.3.6' } # systemTemperatureEX + }, + es => { + cpu_temp => { oid => '.1.3.6.1.4.1.24681.2.2.5' }, # es-CPU-Temperature + system_temp => { oid => '.1.3.6.1.4.1.24681.2.2.6' } # es-SystemTemperature1 + } }; -my $oid_systemInfo = '.1.3.6.1.4.1.24681.1.2'; +sub load {} -sub load { - my ($self) = @_; - - push @{$self->{request}}, { - oid => $oid_systemInfo, - start => $mapping->{cpu_temp}->{oid}, - end => $mapping->{system_temp}->{oid} - }; -} +sub check_temp_result { + my ($self, %options) = @_; -sub check { - my ($self) = @_; - - $self->{output}->output_add(long_msg => "Checking temperatures"); - $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; - return if ($self->check_filter(section => 'temperature')); - - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_systemInfo}, instance => 0); - - $result->{cpu_temp} = defined($result->{cpu_temp}) ? $result->{cpu_temp} : 'unknown'; - if ($result->{cpu_temp} =~ /([0-9]+)\s*C/ && !$self->check_filter(section => 'temperature', instance => 'cpu')) { + $options{result}->{cpu_temp} = defined($options{result}->{cpu_temp}) ? $options{result}->{cpu_temp} : 'unknown'; + if ($options{result}->{cpu_temp} =~ /([0-9]+)\s*C/ && !$self->check_filter(section => 'temperature', instance => 'cpu')) { my $value = $1; $self->{components}->{temperature}->{total}++; $self->{output}->output_add( @@ -70,7 +63,7 @@ sub check { $self->{output}->output_add( severity => $exit, short_msg => sprintf( - "CPU Temperature is '%s' degree centigrade", $value + "CPU temperature is '%s' degree centigrade", $value ) ); } @@ -82,13 +75,13 @@ sub check { ); } - $result->{system_temp} = defined($result->{system_temp}) ? $result->{system_temp} : 'unknown'; - if ($result->{system_temp} =~ /([0-9]+)\s*C/ && !$self->check_filter(section => 'temperature', instance => 'system')) { + $options{result}->{system_temp} = defined($options{result}->{system_temp}) ? $options{result}->{system_temp} : 'unknown'; + if ($options{result}->{system_temp} =~ /([0-9]+)\s*C/ && !$self->check_filter(section => 'temperature', instance => 'system')) { my $value = $1; $self->{components}->{temperature}->{total}++; $self->{output}->output_add( long_msg => sprintf( - "system Temperature is '%s' degree centigrade", + "system temperature is '%s' degree centigrade", $value ) ); @@ -97,7 +90,7 @@ sub check { $self->{output}->output_add( severity => $exit, short_msg => sprintf( - "System Temperature is '%s' degree centigrade", $value + "System temperature is '%s' degree centigrade", $value ) ); } @@ -110,4 +103,43 @@ sub check { } } +sub check_temp_es { + my ($self, %options) = @_; + + my $snmp_result = $self->{snmp}->get_leef( + oids => [ map($_->{oid} . '.0', values(%{$mapping->{es}})) ] + ); + my $result = $self->{snmp}->map_instance(mapping => $mapping->{es}, results => $snmp_result, instance => 0); + check_temp_result($self, result => $result); +} + +sub check_temp { + my ($self, %options) = @_; + + my $snmp_result = $self->{snmp}->get_leef( + oids => [ map($_->{oid} . '.0', values(%{$mapping->{ex}}), values(%{$mapping->{legacy}})) ], + ); + my $result = $self->{snmp}->map_instance(mapping => $mapping->{ex}, results => $snmp_result, instance => 0); + if (defined($result->{cpu_tem})) { + check_temp_result($self, result => $result); + } else { + $result = $self->{snmp}->map_instance(mapping => $mapping->{legacy}, results => $snmp_result, instance => 0); + check_temp_result($self, result => $result); + } +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking temperatures"); + $self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'temperature')); + + if ($self->{is_es} == 1) { + check_temp_es($self); + } else { + check_temp($self); + } +} + 1; diff --git a/centreon-plugins/storage/qnap/snmp/mode/hardware.pm b/centreon-plugins/storage/qnap/snmp/mode/hardware.pm index 9aa25c988..73c331dc6 100644 --- a/centreon-plugins/storage/qnap/snmp/mode/hardware.pm +++ b/centreon-plugins/storage/qnap/snmp/mode/hardware.pm @@ -35,18 +35,33 @@ sub set_system { $self->{thresholds} = { disk => [ + ['good', 'OK'], + ['warning', 'WARNING'], + ['abnormal', 'CRITICAL'], + + ['in-use', 'OK'], # es ['noDisk', 'OK'], ['ready', 'OK'], ['invalid', 'CRITICAL'], ['rwError', 'CRITICAL'], ['unknown', 'UNKNOWN'], - - ['abnormal', 'WARNING'], - ['good', 'OK'], - ['warning', 'WARNING'], ['error', 'CRITICAL'] ], + fan => [ + ['ok', 'OK'], + ['n/a', 'OK'], + ['fail', 'CRITICAL'] + ], + psu => [ + ['ok', 'OK'], + ['fail', 'CRITICAL'] + ], smartdisk => [ + ['good', 'OK'], + ['warning', 'WARNING'], + ['abnormal', 'CRITICAL'], + ['error', 'CRITICAL'], + ['GOOD', 'OK'], ['NORMAL', 'OK'], ['--', 'OK'], @@ -57,22 +72,24 @@ sub set_system { ['Synchronizing', 'OK'], ['degraded', 'WARNING'], ['.*', 'CRITICAL'] - ], - psu => [ - ['ok', 'OK'], - ['fail', 'CRITICAL'] ] }; $self->{components_path} = 'storage::qnap::snmp::mode::components'; - $self->{components_module} = ['disk', 'fan', 'psu', 'raid', 'temperature']; + $self->{components_module} = ['disk', 'fan', 'mdisk', 'psu', 'raid', 'temperature']; } sub snmp_execute { my ($self, %options) = @_; $self->{snmp} = $options{snmp}; - $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); + + $self->{is_es} = 0; + my $oid_es_uptime = '.1.3.6.1.4.1.24681.2.2.4.0'; + my $snmp_result = $self->{snmp}->get_leef(oids => [$oid_es_uptime]); # es-SystemUptime + if (defined($snmp_result->{$oid_es_uptime})) { + $self->{is_es} = 1; + } } sub new { @@ -91,14 +108,14 @@ __END__ =head1 MODE -Check hardware (NAS.mib) (Fans, Temperatures, Disks, Raid). +Check hardware. =over 8 =item B<--component> Which component to check (Default: '.*'). -Can be: 'disk', 'fan', 'psu', 'raid', 'temperature'. +Can be: 'disk', 'fan', 'mdisk', 'psu', 'raid', 'temperature'. =item B<--filter> diff --git a/centreon-plugins/storage/qnap/snmp/mode/memory.pm b/centreon-plugins/storage/qnap/snmp/mode/memory.pm index 07e61b4af..b2426fdc6 100644 --- a/centreon-plugins/storage/qnap/snmp/mode/memory.pm +++ b/centreon-plugins/storage/qnap/snmp/mode/memory.pm @@ -20,37 +20,65 @@ package storage::qnap::snmp::mode::memory; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); 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' }, - }); +sub custom_ram_usage_output { + my ($self, %options) = @_; - return $self; + return sprintf( + 'Memory total: %s %s used: %s %s (%.2f%%) free: %s %s (%.2f%%)', + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} + ); } -sub check_options { +sub set_counters { my ($self, %options) = @_; - $self->SUPER::init(%options); + + $self->{maps_counters_type} = [ + { name => 'ram', type => 0, skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{ram} = [ + { label => 'memory-usage', nlabel => 'memory.usage.bytes', set => { + key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_ram_usage_output'), + perfdatas => [ + { template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 } + ] + } + }, + { label => 'memory-usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => { + key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_ram_usage_output'), + perfdatas => [ + { template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 } + ] + } + }, + { label => 'memory-usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => { + key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'prct_free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_ram_usage_output'), + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%' } + ] + } + } + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + bless $self, $class; - 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(); - } + return $self; } sub convert_bytes { @@ -59,8 +87,10 @@ sub convert_bytes { my %units = (K => 1, M => 2, G => 3, T => 4); if ($options{value} !~ /^\s*([0-9\.\,]+)\s*(.)/) { - $self->{output}->output_add(severity => 'UNKNOWN', - output => "Cannot convert value '" . $options{value} . "'"); + $self->{output}->output_add( + severity => 'UNKNOWN', + output => "Cannot convert value '" . $options{value} . "'" + ); $self->{output}->display(); $self->{output}->exit(); } @@ -73,47 +103,50 @@ sub convert_bytes { return $bytes; } -sub run { +my $mapping = { + legacy => { + ram_total => { oid => '.1.3.6.1.4.1.24681.1.2.2' }, # systemTotalMem + ram_free => { oid => '.1.3.6.1.4.1.24681.1.2.3' } # systemFreeMem + }, + ex => { + ram_total => { oid => '.1.3.6.1.4.1.24681.1.3.2' }, # systemTotalMemEX + ram_free => { oid => '.1.3.6.1.4.1.24681.1.3.3' } # systemFreeMemEX + }, + es => { + ram_total => { oid => '.1.3.6.1.4.1.24681.2.2.2' }, # es-SystemTotalMem + ram_free => { oid => '.1.3.6.1.4.1.24681.2.2.3' } # es-SystemFreeMem + } +}; + +sub check_memory { my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - my $oid_SystemTotalMem = '.1.3.6.1.4.1.24681.1.2.2.0'; - my $oid_SystemFreeMem = '.1.3.6.1.4.1.24681.1.2.3.0'; + return 0 if (defined($self->{ram}->{total})); - my $result = $self->{snmp}->get_leef( - oids => [ $oid_SystemTotalMem, $oid_SystemFreeMem ], + my $result = $options{snmp}->map_instance(mapping => $mapping->{ $options{type} }, results => $options{snmp_result}, instance => 0); + return 0 if (!defined($result->{ram_free})); + + $result->{ram_total} = $self->convert_bytes(value => $result->{ram_total}); + $result->{ram_free} = $self->convert_bytes(value => $result->{ram_free}); + $self->{ram} = { + total => $result->{ram_total}, + used => $result->{ram_total} - $result->{ram_free}, + free => $result->{ram_free}, + prct_used => 100 - ($result->{ram_free} * 100 / $result->{ram_total}), + prct_free => $result->{ram_free} * 100 / $result->{ram_total} + }; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_leef( + oids => [ map($_->{oid} . '.0', values(%{$mapping->{legacy}}), values(%{$mapping->{ex}}), values(%{$mapping->{es}})) ], nothing_quit => 1 ); - - my $total_size = $self->convert_bytes(value => $result->{$oid_SystemTotalMem}); - my $memory_free = $self->convert_bytes(value => $result->{$oid_SystemFreeMem}); - my $memory_used = $total_size - $memory_free; - - my $prct_used = $memory_used * 100 / $total_size; - my $prct_free = 100 - $prct_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(severity => $exit, - short_msg => sprintf("Memory Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", - $total_value . " " . $total_unit, - $used_value . " " . $used_unit, $prct_used, - $free_value . " " . $free_unit, $prct_free)); - - $self->{output}->perfdata_add( - label => 'used', unit => 'B', - nlabel => 'memory.usage.bytes', - value => int($memory_used), - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1), - min => 0, max => int($total_size) - ); - - $self->{output}->display(); - $self->{output}->exit(); + $self->check_memory(snmp => $options{snmp}, type => 'ex', snmp_result => $snmp_result); + $self->check_memory(snmp => $options{snmp}, type => 'es', snmp_result => $snmp_result); + $self->check_memory(snmp => $options{snmp}, type => 'legacy', snmp_result => $snmp_result); } 1; @@ -122,17 +155,14 @@ __END__ =head1 MODE -Check memory usage (NAS.mib). +Check memory. =over 8 -=item B<--warning> +=item B<--warning-*> B<--critical-*> -Threshold warning in percent. - -=item B<--critical> - -Threshold critical in percent. +Thresholds. +Can be: 'memory-usage' (B), 'memory-usage-free' (B), 'memory-usage-prct' (%). =back diff --git a/centreon-plugins/storage/qnap/snmp/mode/pools.pm b/centreon-plugins/storage/qnap/snmp/mode/pools.pm new file mode 100644 index 000000000..e491f8435 --- /dev/null +++ b/centreon-plugins/storage/qnap/snmp/mode/pools.pm @@ -0,0 +1,281 @@ +# +# Copyright 2021 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package storage::qnap::snmp::mode::pools; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + "status: %s", + $self->{result_values}->{status} + ); +} + +sub custom_space_usage_output { + my ($self, %options) = @_; + + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); + return sprintf( + "space usage total: %s used: %s (%.2f%%) free: %s (%.2f%%)", + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free} + ); +} + +sub pool_long_output { + my ($self, %options) = @_; + + return sprintf( + "checking pool '%s'", + $options{instance_value}->{name} + ); +} + +sub prefix_pool_output { + my ($self, %options) = @_; + + return sprintf( + "pool '%s' ", + $options{instance_value}->{name} + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'pools', type => 3, cb_prefix_output => 'prefix_pool_output', cb_long_output => 'pool_long_output', + indent_long_output => ' ', message_multiple => 'All pools are ok', + group => [ + { name => 'status', type => 0, skipped_code => { -10 => 1 } }, + { name => 'space', type => 0, skipped_code => { -10 => 1 } } + ] + } + ]; + + $self->{maps_counters}->{status} = [ + { + label => 'pool-status', + type => 2, + warning_default => '%{status} =~ /degraded|warning/i', + critical_default => '%{status} =~ /error|critical/i', + set => { + key_values => [ + { name => 'status' }, { name => 'name' } + ], + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold_ng + } + } + ]; + + $self->{maps_counters}->{space} = [ + { label => 'space-usage', nlabel => 'pool.space.usage.bytes', set => { + key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'name' } ], + closure_custom_output => $self->can('custom_space_usage_output'), + perfdatas => [ + { template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'name' } + ] + } + }, + { label => 'space-usage-free', display_ok => 0, nlabel => 'pool.space.free.bytes', set => { + key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'name' } ], + closure_custom_output => $self->can('custom_space_usage_output'), + perfdatas => [ + { template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'name' } + ] + } + }, + { label => 'space-usage-prct', display_ok => 0, nlabel => 'pool.space.usage.percentage', set => { + key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'prct_free' }, { name => 'total' }, { name => 'name' } ], + closure_custom_output => $self->can('custom_space_usage_output'), + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'name' } + ] + } + } + ]; +} + +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-name:s' => { name => 'filter_name' } + }); + + return $self; +} + +sub convert_bytes { + my ($self, %options) = @_; + my $multiple = defined($options{network}) ? 1000 : 1024; + my %units = (K => 1, M => 2, G => 3, T => 4); + + if ($options{value} !~ /^\s*([0-9\.\,]+)\s*(.)/) { + $self->{output}->output_add( + severity => 'UNKNOWN', + output => "Cannot convert value '" . $options{value} . "'" + ); + $self->{output}->display(); + $self->{output}->exit(); + } + my ($bytes, $unit) = ($1, uc($2)); + + for (my $i = 0; $i < $units{$unit}; $i++) { + $bytes *= $multiple; + } + + return $bytes; +} + +my $map_status = { + 0 => 'ready', + -1 => 'warning', + -2 => 'notReady', + -3 => 'error' +}; + +my $mapping = { + ex => { + name => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.2.2.2.1.2' }, # poolID + total => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.2.2.2.1.3' }, # poolCapacity + free => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.2.2.2.1.4' }, # poolFreeSize + status => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.2.2.2.1.5', map => $map_status } # poolStatus + }, + es => { + name => { oid => '.1.3.6.1.4.1.24681.2.2.23.1.2' }, # es-SysPoolID + total => { oid => '.1.3.6.1.4.1.24681.2.2.23.1.3' }, # es-SysPoolCapacity + free => { oid => '.1.3.6.1.4.1.24681.2.2.23.1.4' }, # es-SysPoolFreeSize + status => { oid => '.1.3.6.1.4.1.24681.2.2.23.1.5' } # es-SysPoolStatus + } +}; + +sub check_pools { + my ($self, %options) = @_; + + return 0 if (scalar(keys %{$options{snmp_result}}) <= 0); + + foreach (keys %{$options{snmp_result}}) { + next if (! /^$mapping->{ $options{type} }->{name}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping->{ $options{type} }, results => $options{snmp_result}, instance => $instance); + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $result->{name} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping pool $result->{name}", debug => 1); + next; + } + + if (defined($options{convert})) { + $result->{total} = $self->convert_bytes(value => $result->{total}); + $result->{free} = $self->convert_bytes(value => $result->{free}); + } + + $self->{pools}->{$instance} = { + name => $result->{name}, + status => { + name => $result->{name}, + status => $result->{status} + } + }; + if (defined($result->{total}) && $result->{total} > 0) { + $self->{pools}->{$instance}->{space} = { + name => $result->{name}, + total => $result->{total}, + free => $result->{free}, + used => $result->{total} - $result->{free}, + prct_free => $result->{free} * 100 / $result->{total}, + prct_used => ($result->{total} - $result->{free}) * 100 / $result->{total} + }; + } + } + + return 1; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{pools} = {}; + + my $snmp_result = $options{snmp}->get_table( + oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.2.2.2' # poolTable + ); + return if ($self->check_pools(snmp => $options{snmp}, type => 'ex', snmp_result => $snmp_result)); + + $snmp_result = $options{snmp}->get_table( + oid => '.1.3.6.1.4.1.24681.2.2.23', # es-SystemPoolTable + nothing_quit => 1 + ); + $self->check_pools(snmp => $options{snmp}, type => 'es', snmp_result => $snmp_result, convert => 1); +} + +1; + +__END__ + +=head1 MODE + +Check pools. + +=over 8 + +=item B<--filter-name> + +Filter pools by name (can be a regexp). + +=item B<--unknown-pool-status> + +Set unknown threshold for status. +Can used special variables like: %{status}, %{name} + +=item B<--warning-pool-status> + +Set warning threshold for status (Default: '%{status} =~ /degraded|warning/i'). +Can used special variables like: %{status}, %{name} + +=item B<--critical-pool-status> + +Set critical threshold for status (Default: '%{status} =~ /error|critical/i'). +Can used special variables like: %{status}, %{name} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'space-usage-prct', 'space-usage', 'space-usage-free'. + +=back + +=cut + diff --git a/centreon-plugins/storage/qnap/snmp/mode/volumes.pm b/centreon-plugins/storage/qnap/snmp/mode/volumes.pm new file mode 100644 index 000000000..9b70e9bc3 --- /dev/null +++ b/centreon-plugins/storage/qnap/snmp/mode/volumes.pm @@ -0,0 +1,274 @@ +# +# Copyright 2021 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package storage::qnap::snmp::mode::volumes; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + "status: %s", + $self->{result_values}->{status} + ); +} + +sub custom_space_usage_output { + my ($self, %options) = @_; + + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); + return sprintf( + "space usage total: %s used: %s (%.2f%%) free: %s (%.2f%%)", + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free} + ); +} + +sub volume_long_output { + my ($self, %options) = @_; + + return sprintf( + "checking volume '%s'", + $options{instance_value}->{name} + ); +} + +sub prefix_volume_output { + my ($self, %options) = @_; + + return sprintf( + "volume '%s' ", + $options{instance_value}->{name} + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'volumes', type => 3, cb_prefix_output => 'prefix_volume_output', cb_long_output => 'volume_long_output', + indent_long_output => ' ', message_multiple => 'All volumes are ok', + group => [ + { name => 'status', type => 0, skipped_code => { -10 => 1 } }, + { name => 'space', type => 0, skipped_code => { -10 => 1 } } + ] + } + ]; + + $self->{maps_counters}->{status} = [ + { + label => 'volume-status', + type => 2, + warning_default => '%{status} =~ /degraded|warning/i', + critical_default => '%{status} =~ /critical/i', + set => { + key_values => [ + { name => 'status' }, { name => 'name' } + ], + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold_ng + } + } + ]; + + $self->{maps_counters}->{space} = [ + { label => 'space-usage', nlabel => 'volume.space.usage.bytes', set => { + key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'name' } ], + closure_custom_output => $self->can('custom_space_usage_output'), + perfdatas => [ + { template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'name' } + ] + } + }, + { label => 'space-usage-free', display_ok => 0, nlabel => 'volume.space.free.bytes', set => { + key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'name' } ], + closure_custom_output => $self->can('custom_space_usage_output'), + perfdatas => [ + { template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'name' } + ] + } + }, + { label => 'space-usage-prct', display_ok => 0, nlabel => 'volume.space.usage.percentage', set => { + key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'prct_free' }, { name => 'total' }, { name => 'name' } ], + closure_custom_output => $self->can('custom_space_usage_output'), + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'name' } + ] + } + } + ]; +} + +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-name:s' => { name => 'filter_name' } + }); + + return $self; +} + +sub convert_bytes { + my ($self, %options) = @_; + my $multiple = defined($options{network}) ? 1000 : 1024; + my %units = (K => 1, M => 2, G => 3, T => 4); + + if ($options{value} !~ /^\s*([0-9\.\,]+)\s*(.)/) { + $self->{output}->output_add( + severity => 'UNKNOWN', + output => "Cannot convert value '" . $options{value} . "'" + ); + $self->{output}->display(); + $self->{output}->exit(); + } + my ($bytes, $unit) = ($1, uc($2)); + + for (my $i = 0; $i < $units{$unit}; $i++) { + $bytes *= $multiple; + } + + return $bytes; +} + +my $mapping = { + legacy => { + name => { oid => '.1.3.6.1.4.1.24681.1.2.17.1.2' }, # sysVolumeDescr + total => { oid => '.1.3.6.1.4.1.24681.1.2.17.1.4' }, # sysVolumeTotalSize + free => { oid => '.1.3.6.1.4.1.24681.1.2.17.1.5' }, # sysVolumeFreeSize + status => { oid => '.1.3.6.1.4.1.24681.1.2.17.1.6' } # sysVolumeStatus + }, + ex => { + total => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.2.3.2.1.3' }, # volumeCapacity + free => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.2.3.2.1.4' }, # volumeFreeSize + status => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.2.3.2.1.5' }, # volumeStatus + name => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.2.3.2.1.8' } # volumeName + } +}; + +sub check_volumes { + my ($self, %options) = @_; + + return 0 if (scalar(keys %{$options{snmp_result}}) <= 0); + + foreach (keys %{$options{snmp_result}}) { + next if (! /^$mapping->{ $options{type} }->{name}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping->{ $options{type} }, results => $options{snmp_result}, instance => $instance); + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $result->{name} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping volume $result->{name}", debug => 1); + next; + } + + if (defined($options{convert})) { + $result->{total} = $self->convert_bytes(value => $result->{total}); + $result->{free} = $self->convert_bytes(value => $result->{free}); + } + + $self->{volumes}->{$instance} = { + name => $result->{name}, + status => { + name => $result->{name}, + status => $result->{status} + } + }; + if (defined($result->{total}) && $result->{total} > 0) { + $self->{volumes}->{$instance}->{space} = { + name => $result->{name}, + total => $result->{total}, + free => $result->{free}, + used => $result->{total} - $result->{free}, + prct_free => $result->{free} * 100 / $result->{total}, + prct_used => ($result->{total} - $result->{free}) * 100 / $result->{total} + }; + } + } + + return 1; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{volumes} = {}; + + my $snmp_result = $options{snmp}->get_table( + oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.2.3.2' # volumeTable + ); + return if ($self->check_volumes(snmp => $options{snmp}, type => 'ex', snmp_result => $snmp_result)); + + $snmp_result = $options{snmp}->get_table( + oid => '.1.3.6.1.4.1.24681.1.2.17', # systemVolumeTable + nothing_quit => 1 + ); + $self->check_volumes(snmp => $options{snmp}, type => 'legacy', snmp_result => $snmp_result, convert => 1); +} + +1; + +__END__ + +=head1 MODE + +Check volumes. + +=over 8 + +=item B<--filter-name> + +Filter volumes by name (can be a regexp). + +=item B<--unknown-volume-status> + +Set unknown threshold for status. +Can used special variables like: %{status}, %{name} + +=item B<--warning-volume-status> + +Set warning threshold for status (Default: '%{status} =~ /degraded|warning/i'). +Can used special variables like: %{status}, %{name} + +=item B<--critical-volume-status> + +Set critical threshold for status (Default: '%{status} =~ /critical/i'). +Can used special variables like: %{status}, %{name} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'space-usage-prct', 'space-usage', 'space-usage-free'. + +=back + +=cut + diff --git a/centreon-plugins/storage/qnap/snmp/mode/volumeusage.pm b/centreon-plugins/storage/qnap/snmp/mode/volumeusage.pm deleted file mode 100644 index d2b382eca..000000000 --- a/centreon-plugins/storage/qnap/snmp/mode/volumeusage.pm +++ /dev/null @@ -1,233 +0,0 @@ -# -# Copyright 2021 Centreon (http://www.centreon.com/) -# -# Centreon is a full-fledged industry-strength solution that meets -# the needs in IT infrastructure and application monitoring for -# service performance. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -package storage::qnap::snmp::mode::volumeusage; - -use base qw(centreon::plugins::templates::counter); - -use strict; -use warnings; - -sub custom_usage_perfdata { - my ($self, %options) = @_; - - my ($label, $nlabel) = ('used', $self->{nlabel}); - my $value_perf = $self->{result_values}->{used}; - if (defined($self->{instance_mode}->{option_results}->{free})) { - ($label, $nlabel) = ('free', 'volume.space.free.bytes'); - $value_perf = $self->{result_values}->{free}; - } - - my %total_options = (); - if ($self->{instance_mode}->{option_results}->{units} eq '%') { - $total_options{total} = $self->{result_values}->{total}; - $total_options{cast_int} = 1; - } - - $self->{output}->perfdata_add( - label => $label, unit => 'B', - instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, - nlabel => $nlabel, - value => $value_perf, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options), - min => 0, max => $self->{result_values}->{total} - ); -} - -sub custom_usage_threshold { - my ($self, %options) = @_; - - my ($exit, $threshold_value); - $threshold_value = $self->{result_values}->{used}; - $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); - if ($self->{instance_mode}->{option_results}->{units} eq '%') { - $threshold_value = $self->{result_values}->{prct_used}; - $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); - } - $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' } ]); - return $exit; -} - -sub custom_usage_output { - my ($self, %options) = @_; - - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); - - my $msg = sprintf("Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", - $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); - return $msg; -} - -sub custom_usage_calc { - my ($self, %options) = @_; - - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - $self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_used'} + $options{new_datas}->{$self->{instance} . '_free'}; - $self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'}; - $self->{result_values}->{free} = $options{new_datas}->{$self->{instance} . '_free'}; - $self->{result_values}->{prct_free} = $self->{result_values}->{free} * 100 / $self->{result_values}->{total}; - $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; - return 0; -} - -sub set_counters { - my ($self, %options) = @_; - - $self->{maps_counters_type} = [ - { name => 'volume', type => 1, cb_prefix_output => 'prefix_volume_output', message_multiple => 'All volumes are ok' }, - ]; - - $self->{maps_counters}->{volume} = [ - { label => 'usage', nlabel => 'volume.space.usage.bytes', set => { - key_values => [ { name => 'display' }, { name => 'used' }, { name => 'free' } ], - closure_custom_calc => $self->can('custom_usage_calc'), - closure_custom_output => $self->can('custom_usage_output'), - closure_custom_perfdata => $self->can('custom_usage_perfdata'), - closure_custom_threshold_check => $self->can('custom_usage_threshold'), - } - }, - ]; -} - -sub prefix_volume_output { - my ($self, %options) = @_; - - return "Volume '" . $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-name:s" => { name => 'filter_name' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - }); - - return $self; -} - -my $mapping = { - SysVolumeDescr => { oid => '.1.3.6.1.4.1.24681.1.2.17.1.2' }, - SysVolumeFS => { oid => '.1.3.6.1.4.1.24681.1.2.17.1.3' }, - SysVolumeTotalSize => { oid => '.1.3.6.1.4.1.24681.1.2.17.1.4' }, - SysVolumeFreeSize => { oid => '.1.3.6.1.4.1.24681.1.2.17.1.5' }, -}; - -sub manage_selection { - my ($self, %options) = @_; - - $self->{volume} = {}; - my $oid_SysVolumeEntry = '.1.3.6.1.4.1.24681.1.2.17.1'; - my $snmp_result = $options{snmp}->get_table( - oid => $oid_SysVolumeEntry, - start => $mapping->{SysVolumeDescr}->{oid}, - end => $mapping->{SysVolumeFreeSize}->{oid}, - nothing_quit => 1 - ); - foreach my $oid (keys %$snmp_result) { - next if ($oid !~ /^$mapping->{SysVolumeDescr}->{oid}\.(\d+)/); - my $instance = $1; - my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); - if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && - $result->{SysVolumeDescr} !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "skipping '" . $result->{SysVolumeDescr} . "': no matching filter."); - next; - } - - my $free = $self->convert_bytes(value => $result->{SysVolumeFreeSize}); - my $total = $self->convert_bytes(value => $result->{SysVolumeTotalSize}); - if ($total == 0) { - $self->{output}->output_add(long_msg => "skipping '" . $result->{SysVolumeDescr} . "': total size is 0."); - next; - } - - $self->{volume}->{$instance} = { - display => $result->{SysVolumeDescr}, - free => $free, used => $total - $free - }; - } - - if (scalar(keys %{$self->{volume}}) <= 0) { - $self->{output}->add_option_msg(short_msg => "No entry found."); - $self->{output}->option_exit(); - } -} - -sub convert_bytes { - my ($self, %options) = @_; - my $multiple = defined($options{network}) ? 1000 : 1024; - my %units = (K => 1, M => 2, G => 3, T => 4); - - if ($options{value} !~ /^\s*([0-9\.\,]+)\s*(.)/) { - $self->{output}->output_add(severity => 'UNKNOWN', - output => "Cannot convert value '" . $options{value} . "'"); - $self->{output}->display(); - $self->{output}->exit(); - } - my ($bytes, $unit) = ($1, uc($2)); - - for (my $i = 0; $i < $units{$unit}; $i++) { - $bytes *= $multiple; - } - - return $bytes; -} - -1; - -__END__ - -=head1 MODE - -Check volume usages. - -=over 8 - -=item B<--warning-usage> - -Threshold warning. - -=item B<--critical-usage> - -Threshold critical. - -=item B<--units> - -Units of thresholds (Default: '%') ('%', 'B'). - -=item B<--free> - -Thresholds are on free space left. - -=item B<--filter-name> - -Filter volume name (can be a regexp). - -=back - -=cut diff --git a/centreon-plugins/storage/qnap/snmp/plugin.pm b/centreon-plugins/storage/qnap/snmp/plugin.pm index 364be6214..78d8f29a4 100644 --- a/centreon-plugins/storage/qnap/snmp/plugin.pm +++ b/centreon-plugins/storage/qnap/snmp/plugin.pm @@ -30,18 +30,19 @@ sub new { bless $self, $class; $self->{version} = '0.1'; - %{$self->{modes}} = ( - 'cpu' => 'snmp_standard::mode::cpu', - 'hardware' => 'storage::qnap::snmp::mode::hardware', - 'interfaces' => 'snmp_standard::mode::interfaces', - 'list-interfaces' => 'snmp_standard::mode::listinterfaces', - 'list-storages' => 'snmp_standard::mode::liststorages', - 'memory' => 'storage::qnap::snmp::mode::memory', - 'storage' => 'snmp_standard::mode::storage', - 'time' => 'snmp_standard::mode::ntp', - 'uptime' => 'snmp_standard::mode::uptime', - 'volume-usage' => 'storage::qnap::snmp::mode::volumeusage' - ); + $self->{modes} = { + 'cpu' => 'snmp_standard::mode::cpu', + 'hardware' => 'storage::qnap::snmp::mode::hardware', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'list-storages' => 'snmp_standard::mode::liststorages', + 'memory' => 'storage::qnap::snmp::mode::memory', + 'pools' => 'storage::qnap::snmp::mode::pools', + 'storage' => 'snmp_standard::mode::storage', + 'time' => 'snmp_standard::mode::ntp', + 'uptime' => 'snmp_standard::mode::uptime', + 'volumes' => 'storage::qnap::snmp::mode::volumes' + }; return $self; }