From ea7e86fc71bf3f3eaf0cb062c699a17439cfe8aa Mon Sep 17 00:00:00 2001 From: qgarnier Date: Thu, 29 Jul 2021 16:07:33 +0200 Subject: [PATCH] enh(dell/os10): hardware mode - add os version (#2998) --- network/dell/os10/snmp/mode/hardware.pm | 29 +++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/network/dell/os10/snmp/mode/hardware.pm b/network/dell/os10/snmp/mode/hardware.pm index 0292d9c3b..856b8e557 100644 --- a/network/dell/os10/snmp/mode/hardware.pm +++ b/network/dell/os10/snmp/mode/hardware.pm @@ -29,7 +29,8 @@ sub set_system { my ($self, %options) = @_; $self->{regexp_threshold_numeric_check_section_option} = '^(?:temperature)$'; - + + $self->{cb_hook1} = 'get_system_information'; $self->{cb_hook2} = 'snmp_execute'; $self->{thresholds} = { @@ -39,7 +40,7 @@ sub set_system { ['cardProblem', 'CRITICAL'], ['diagMode', 'OK'], ['cardAbsent', 'OK'], - ['offline', 'OK'], + ['offline', 'OK'] ], operational => [ ['up', 'OK'], @@ -49,14 +50,34 @@ sub set_system { ['dormant', 'OK'], ['notPresent', 'OK'], ['lowerLayerDown', 'OK'], - ['failed', 'CRITICAL'], - ], + ['failed', 'CRITICAL'] + ] }; $self->{components_path} = 'network::dell::os10::snmp::mode::components'; $self->{components_module} = ['card', 'temperature', 'fan', 'fantray', 'psu']; } +sub get_system_information { + my ($self, %options) = @_; + + my $oid_sysdescr = '.1.3.6.1.2.1.1.1.0'; + my $result = $options{snmp}->get_leef(oids => [$oid_sysdescr]); + + my $version = 'unknown'; + if (defined($result->{$oid_sysdescr}) && $result->{$oid_sysdescr} =~ /OS Version: ([0-9\.]+)/msi) { + $version = $1; + $version =~ s/\.$//; + } + $self->{output}->output_add( + long_msg => sprintf( + 'os version: %s', + $version + ) + ); +} + + sub snmp_execute { my ($self, %options) = @_;