| 1 |
# |
| 2 |
# Copyright 2024 Centreon (http://www.centreon.com/) |
| 3 |
# |
| 4 |
# Centreon is a full-fledged industry-strength solution that meets |
| 5 |
# the needs in IT infrastructure and application monitoring for |
| 6 |
# service performance. |
| 7 |
# |
| 8 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 |
# you may not use this file except in compliance with the License. |
| 10 |
# You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, software |
| 15 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
# See the License for the specific language governing permissions and |
| 18 |
# limitations under the License. |
| 19 |
# |
| 20 |
|
| 21 |
package network::citrix::netscaler::snmp::mode::components::temperature; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my $mapping = { |
| 27 |
sysHealthCounterName => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.7.1.1' }, |
| 28 |
sysHealthCounterValue => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.7.1.2' }, |
| 29 |
}; |
| 30 |
my $oid_nsSysHealthEntry = '.1.3.6.1.4.1.5951.4.1.1.41.7.1'; |
| 31 |
|
| 32 |
sub load {} |
| 33 |
|
| 34 |
sub check { |
| 35 |
my ($self) = @_; |
| 36 |
|
| 37 |
$self->{output}->output_add(long_msg => "Checking temperatures"); |
| 38 |
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; |
| 39 |
return if ($self->check_filter(section => 'temperature')); |
| 40 |
|
| 41 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_nsSysHealthEntry}})) { |
| 42 |
next if ($oid !~ /^$mapping->{sysHealthCounterName}->{oid}\.(.*)$/); |
| 43 |
my $instance = $1; |
| 44 |
next if ($self->{results}->{$oid_nsSysHealthEntry}->{$oid} !~ /temperature/i); |
| 45 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_nsSysHealthEntry}, instance => $instance); |
| 46 |
|
| 47 |
next if ($self->check_filter(section => 'temperature', instance => $instance)); |
| 48 |
if ($result->{sysHealthCounterValue} == 0) { |
| 49 |
$self->{output}->output_add(long_msg => sprintf("skipping temperature '%s' (counter is 0)", |
| 50 |
$result->{sysHealthCounterName})); |
| 51 |
next; |
| 52 |
} |
| 53 |
|
| 54 |
$self->{components}->{temperature}->{total}++; |
| 55 |
$self->{output}->output_add(long_msg => sprintf("temperature '%s' is %s C [instance = %s]", |
| 56 |
$result->{sysHealthCounterName}, $result->{sysHealthCounterValue}, $instance)); |
| 57 |
|
| 58 |
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{sysHealthCounterValue}); |
| 59 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 60 |
$self->{output}->output_add(severity => $exit, |
| 61 |
short_msg => sprintf("Temperature '%s' is %s C", $result->{sysHealthCounterName}, $result->{sysHealthCounterValue})); |
| 62 |
} |
| 63 |
$self->{output}->perfdata_add( |
| 64 |
label => 'temp', unit => 'C', |
| 65 |
nlabel => 'hardware.temperature.celsius', |
| 66 |
instances => $result->{sysHealthCounterName}, |
| 67 |
value => $result->{sysHealthCounterValue}, |
| 68 |
warning => $warn, |
| 69 |
critical => $crit, min => 0 |
| 70 |
); |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
1; |