(plugin) hardware::sensors::jacarta::snmp - support interseptor (#3637)
This commit is contained in:
parent
b6d368a241
commit
eb5c702e01
|
@ -24,28 +24,199 @@ use strict;
|
|||
use warnings;
|
||||
use hardware::sensors::jacarta::snmp::mode::components::resources qw(%map_default_status %map_state);
|
||||
|
||||
my $mapping = {
|
||||
isDeviceMonitorHumidityName => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.2.1.2' },
|
||||
isDeviceMonitorHumidity => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.2.1.3' },
|
||||
isDeviceMonitorHumidityAlarm => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.2.1.4', map => \%map_default_status },
|
||||
};
|
||||
my $mapping2 = {
|
||||
isDeviceConfigHumidityLowWarning => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.3' },
|
||||
isDeviceConfigHumidityLowCritical => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.4' },
|
||||
isDeviceConfigHumidityHighWarning => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.5' },
|
||||
isDeviceConfigHumidityHighCritical => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.6' },
|
||||
isDeviceConfigHumidityLowWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.9', map => \%map_state },
|
||||
isDeviceConfigHumidityLowCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.10', map => \%map_state },
|
||||
isDeviceConfigHumidityHighWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.11', map => \%map_state },
|
||||
isDeviceConfigHumidityHighCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.12', map => \%map_state },
|
||||
};
|
||||
my $oid_isDeviceMonitorHumidityEntry = '.1.3.6.1.4.1.19011.1.3.2.1.3.1.2.1';
|
||||
my $oid_isDeviceConfigHumidityEntry = '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1';
|
||||
sub load {}
|
||||
|
||||
sub load {
|
||||
sub check_inSeptPro {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_isDeviceMonitorHumidityEntry }, { oid => $oid_isDeviceConfigHumidityEntry };
|
||||
my $mapping = {
|
||||
name => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.2.1.2' }, # isDeviceMonitorHumidityName
|
||||
current => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.2.1.3' }, # isDeviceMonitorHumidity
|
||||
alarm => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.2.1.4', map => \%map_default_status } # isDeviceMonitorHumidityAlarm
|
||||
};
|
||||
my $mapping_config = {
|
||||
lowWarning => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.3' }, # isDeviceConfigHumidityLowWarning
|
||||
lowCritical => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.4' }, # isDeviceConfigHumidityLowCritical
|
||||
highWarning => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.5' }, # isDeviceConfigHumidityHighWarning
|
||||
highCritical => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.6' }, # isDeviceConfigHumidityHighCritical
|
||||
lowWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.9', map => \%map_state }, # isDeviceConfigHumidityLowWarningState
|
||||
lowCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.10', map => \%map_state }, # isDeviceConfigHumidityLowCriticalState
|
||||
highWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.11', map => \%map_state }, # isDeviceConfigHumidityHighWarningState
|
||||
highCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1.12', map => \%map_state } # isDeviceConfigHumidityHighCriticalState
|
||||
};
|
||||
my $oid_humEntry = '.1.3.6.1.4.1.19011.1.3.2.1.3.1.2.1'; # isDeviceMonitorHumidityEntry
|
||||
my $oid_configHumEntry = '.1.3.6.1.4.1.19011.1.3.2.1.3.2.3.1'; # isDeviceConfigHumidityEntry
|
||||
|
||||
my $snmp_result = $self->{snmp}->get_multiple_table(
|
||||
oids => [
|
||||
{ oid => $oid_humEntry, end => $mapping->{alarm}->{oid} } ,
|
||||
{ oid => $oid_configHumEntry, start => $mapping_config->{lowWarning}->{oid}, end => $mapping_config->{lowWarning}->{highCriticalState} }
|
||||
]
|
||||
);
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$snmp_result->{$oid_humEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{alarm}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_humEntry}, instance => $instance);
|
||||
my $result2 = $self->{snmp}->map_instance(mapping => $mapping_config, results => $snmp_result->{$oid_configHumEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'humidity', instance => $instance));
|
||||
$self->{components}->{humidity}->{total}++;
|
||||
|
||||
$result->{current} *= 0.01;
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"humidity '%s' status is '%s' [instance: %s] [value: %s]",
|
||||
$result->{name},
|
||||
$result->{alarm},
|
||||
$instance,
|
||||
$result->{current}
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'humidity', value => $result->{alarm});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Humdity '%s' status is '%s'", $result->{name}, $result->{alarm})
|
||||
);
|
||||
}
|
||||
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'humidity', instance => $instance, value => $result->{current});
|
||||
if ($checked == 0) {
|
||||
$result2->{lowWarning} = ($result2->{lowWarningState} eq 'enabled') ? $result2->{lowWarning} * 0.01 : '';
|
||||
$result2->{lowCritical} = ($result2->{lowCriticalState} eq 'enabled') ? $result2->{lowCritical} * 0.01 : '';
|
||||
$result2->{highWarning} = ($result2->{highWarningState} eq 'enabled') ? $result2->{highWarning} * 0.01 : '';
|
||||
$result2->{highCritical} = ($result2->{highCriticalState} eq 'enabled') ? $result2->{highCritical} * 0.01 : '';
|
||||
my $warn_th = $result2->{lowWarning} . ':' . $result2->{highWarning};
|
||||
my $crit_th = $result2->{lowCritical} . ':' . $result2->{highCritical};
|
||||
$self->{perfdata}->threshold_validate(label => 'warning-humidity-instance-' . $instance, value => $warn_th);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical-humidity-instance-' . $instance, value => $crit_th);
|
||||
|
||||
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-humidity-instance-' . $instance);
|
||||
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-humidity-instance-' . $instance);
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit2,
|
||||
short_msg => sprintf("Humdity '%s' is %s %%", $result->{name}, $result->{current})
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => 'hardware.humidity.percentage',
|
||||
unit => '%',
|
||||
instances => $result->{name},
|
||||
value => $result->{current},
|
||||
warning => $warn,
|
||||
critical => $crit,
|
||||
min => 0, max => 100
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
sub check_inSept {
|
||||
my ($self) = @_;
|
||||
|
||||
my $devices = $self->getInSeptDevices();
|
||||
|
||||
my $mapping = {
|
||||
current => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.3.2.1.5' }, # inSeptsensorMonitorDeviceHumidity
|
||||
alarm => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.3.2.1.6', map => \%map_default_status } # inSeptsensorMonitorDeviceHumidityAlarm
|
||||
};
|
||||
my $mapping_config = {
|
||||
1 => {
|
||||
name => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.3.4.1' }, # inSeptsensorConfigSensor1HumdityName
|
||||
lowWarning => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.3.4.2' }, # inSeptsensorConfigSensor1HumidityLowWarning
|
||||
lowCritical => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.3.4.3' }, # inSeptsensorConfigSensor1HumidityLowCritical
|
||||
highWarning => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.3.4.4' }, # inSeptsensorConfigSensor1HumidityHighWarning
|
||||
highCritical => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.3.4.5' }, # inSeptsensorConfigSensor1HumidityHighCritical
|
||||
lowWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.3.4.8', map => \%map_state }, # inSeptsensorConfigSensor1HumidityLowWarningStatus
|
||||
lowCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.3.4.9', map => \%map_state }, # inSeptsensorConfigSensor1HumidityLowCriticalStatus
|
||||
highWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.3.4.10', map => \%map_state }, # inSeptsensorConfigSensor1HumidityHighWarningStatus
|
||||
highCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.3.4.11', map => \%map_state } # inSeptsensorConfigSensor1HumidityHighCriticalStatus
|
||||
},
|
||||
2 => {
|
||||
name => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.4.4.1' }, # inSeptsensorConfigSensor2HumdityName
|
||||
lowWarning => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.4.4.2' }, # inSeptsensorConfigSensor2HumidityLowWarning
|
||||
lowCritical => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.4.4.3' }, # inSeptsensorConfigSensor2HumidityLowCritical
|
||||
highWarning => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.4.4.4' }, # inSeptsensorConfigSensor2HumidityHighWarning
|
||||
highCritical => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.4.4.5' }, # inSeptsensorConfigSensor2HumidityHighCritical
|
||||
lowWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.4.4.8', map => \%map_state }, # inSeptsensorConfigSensor2HumidityLowWarningStatus
|
||||
lowCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.4.4.9', map => \%map_state }, # inSeptsensorConfigSensor2HumidityLowCriticalStatus
|
||||
highWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.4.4.10', map => \%map_state }, # inSeptsensorConfigSensor2HumidityHighWarningStatus
|
||||
highCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.4.4.11', map => \%map_state } # inSeptsensorConfigSensor2HumidityHighCriticalStatus
|
||||
}
|
||||
};
|
||||
my $oid_sensorEntry = '.1.3.6.1.4.1.19011.1.3.1.1.3.2.1'; # inSeptsensorMonitorSensorEntry
|
||||
|
||||
my $snmp_result = $self->{snmp}->get_table(oid => $oid_sensorEntry, start => $mapping->{current}->{oid}, end => $mapping->{alarm}->{oid});
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
|
||||
next if ($oid !~ /^$mapping->{alarm}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
|
||||
next if (!defined($devices->{$instance}) || $devices->{$instance}->{state} eq 'disabled');
|
||||
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
|
||||
my $snmp_config = $self->{snmp}->get_leef(oids => [ map($_->{oid} . '.0', values(%{$mapping_config->{$instance}})) ]);
|
||||
my $result2 = $self->{snmp}->map_instance(mapping => $mapping_config->{$instance}, results => $snmp_config, instance => 0);
|
||||
|
||||
next if ($self->check_filter(section => 'humidity', instance => $instance));
|
||||
$self->{components}->{humidity}->{total}++;
|
||||
|
||||
$result->{current} *= 0.1;
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"humidity '%s' status is '%s' [instance: %s] [value: %s]",
|
||||
$result2->{name},
|
||||
$result->{alarm},
|
||||
$instance,
|
||||
$result->{current}
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'humidity', value => $result->{alarm});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Humdity '%s' status is '%s'", $result2->{name}, $result->{alarm})
|
||||
);
|
||||
}
|
||||
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'humidity', instance => $instance, value => $result->{current});
|
||||
if ($checked == 0) {
|
||||
$result2->{lowWarning} = ($result2->{lowWarningState} eq 'enabled') ? $result2->{lowWarning} * 0.1 : '';
|
||||
$result2->{lowCritical} = ($result2->{lowCriticalState} eq 'enabled') ? $result2->{lowCritical} * 0.1 : '';
|
||||
$result2->{highWarning} = ($result2->{highWarningState} eq 'enabled') ? $result2->{highWarning} * 0.1 : '';
|
||||
$result2->{highCritical} = ($result2->{highCriticalState} eq 'enabled') ? $result2->{highCritical} * 0.1 : '';
|
||||
my $warn_th = $result2->{lowWarning} . ':' . $result2->{highWarning};
|
||||
my $crit_th = $result2->{lowCritical} . ':' . $result2->{highCritical};
|
||||
$self->{perfdata}->threshold_validate(label => 'warning-humidity-instance-' . $instance, value => $warn_th);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical-humidity-instance-' . $instance, value => $crit_th);
|
||||
|
||||
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-humidity-instance-' . $instance);
|
||||
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-humidity-instance-' . $instance);
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit2,
|
||||
short_msg => sprintf("Humdity '%s' is %s %%", $result2->{name}, $result->{current})
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => 'hardware.humidity.percentage',
|
||||
unit => '%',
|
||||
instances => $result2->{name},
|
||||
value => $result->{current},
|
||||
warning => $warn,
|
||||
critical => $crit,
|
||||
min => 0, max => 100
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
sub check {
|
||||
|
@ -55,59 +226,8 @@ sub check {
|
|||
$self->{components}->{humidity} = {name => 'humidities', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'humidity'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_isDeviceMonitorHumidityEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{isDeviceMonitorHumidityAlarm}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_isDeviceMonitorHumidityEntry}, instance => $instance);
|
||||
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_isDeviceConfigHumidityEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'humidity', instance => $instance));
|
||||
$self->{components}->{humidity}->{total}++;
|
||||
|
||||
$result->{isDeviceMonitorHumidity} *= 0.01;
|
||||
$self->{output}->output_add(long_msg => sprintf("humidity '%s' status is '%s' [instance = %s] [value = %s]",
|
||||
$result->{isDeviceMonitorHumidityName}, $result->{isDeviceMonitorHumidityAlarm}, $instance,
|
||||
$result->{isDeviceMonitorHumidity}));
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'humidity', value => $result->{isDeviceMonitorHumidityAlarm});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Humdity '%s' status is '%s'", $result->{isDeviceMonitorHumidityName}, $result->{isDeviceMonitorHumidityAlarm}));
|
||||
}
|
||||
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'humidity', instance => $instance, value => $result->{isDeviceMonitorHumidity});
|
||||
if ($checked == 0) {
|
||||
$result2->{isDeviceConfigHumidityLowWarning} = ($result2->{isDeviceConfigHumidityLowWarningState} eq 'enabled') ?
|
||||
$result2->{isDeviceConfigHumidityLowWarning} * 0.01 : '';
|
||||
$result2->{isDeviceConfigHumidityLowCritical} = ($result2->{isDeviceConfigHumidityLowCriticalState} eq 'enabled') ?
|
||||
$result2->{isDeviceConfigHumidityLowCritical} * 0.01 : '';
|
||||
$result2->{isDeviceConfigHumidityHighWarning} = ($result2->{isDeviceConfigHumidityHighWarningState} eq 'enabled') ?
|
||||
$result2->{isDeviceConfigHumidityHighWarning} * 0.01 : '';
|
||||
$result2->{isDeviceConfigHumidityHighCritical} = ($result2->{isDeviceConfigHumidityHighCriticalState} eq 'enabled') ?
|
||||
$result2->{isDeviceConfigHumidityHighCritical} * 0.01 : '';
|
||||
my $warn_th = $result2->{isDeviceConfigHumidityLowWarning} . ':' . $result2->{isDeviceConfigHumidityHighWarning};
|
||||
my $crit_th = $result2->{isDeviceConfigHumidityLowCritical} . ':' . $result2->{isDeviceConfigHumidityHighCritical};
|
||||
$self->{perfdata}->threshold_validate(label => 'warning-humidity-instance-' . $instance, value => $warn_th);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical-humidity-instance-' . $instance, value => $crit_th);
|
||||
|
||||
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-humidity-instance-' . $instance);
|
||||
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-humidity-instance-' . $instance);
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit2,
|
||||
short_msg => sprintf("Humdity '%s' is %s %%", $result->{isDeviceMonitorHumidityName}, $result->{isDeviceMonitorHumidity}));
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'humidity', unit => '%',
|
||||
nlabel => 'hardware.humidity.percentage',
|
||||
instances => $result->{isDeviceMonitorHumidityName},
|
||||
value => $result->{isDeviceMonitorHumidity},
|
||||
warning => $warn,
|
||||
critical => $crit,
|
||||
min => 0, max => 100
|
||||
);
|
||||
}
|
||||
check_inSeptPro($self) if ($self->{inSeptPro} == 1);
|
||||
check_inSept($self) if ($self->{inSept} == 1);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -24,45 +24,54 @@ use strict;
|
|||
use warnings;
|
||||
use hardware::sensors::jacarta::snmp::mode::components::resources qw(%map_input_status);
|
||||
|
||||
my $mapping = {
|
||||
isDeviceMonitorDigitalInName => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.3.1.2' },
|
||||
isDeviceMonitorDigitalIn => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.3.1.3' },
|
||||
isDeviceMonitorDigitalInAlarm => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.3.1.4', map => \%map_input_status },
|
||||
};
|
||||
my $oid_isDeviceMonitorDigitalInEntry = '.1.3.6.1.4.1.19011.1.3.2.1.3.1.3.1';
|
||||
sub load {}
|
||||
|
||||
sub load {
|
||||
sub check_inSeptPro {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_isDeviceMonitorDigitalInEntry };
|
||||
my $mapping = {
|
||||
name => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.3.1.2' }, # isDeviceMonitorDigitalInName
|
||||
alarm => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.3.1.4', map => \%map_input_status } # isDeviceMonitorDigitalInAlarm
|
||||
};
|
||||
my $oid_digitalEntry = '.1.3.6.1.4.1.19011.1.3.2.1.3.1.3.1';
|
||||
|
||||
my $snmp_result = $self->{snmp}->get_table(oid => $oid_digitalEntry);
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
|
||||
next if ($oid !~ /^$mapping->{alarm}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'input', instance => $instance));
|
||||
$self->{components}->{input}->{total}++;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"input '%s' status is '%s' [instance: %s]",
|
||||
$result->{name}, $result->{alarm}, $instance
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(section => 'input', value => $result->{alarm});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Input '%s' status is '%s'", $result->{name}, $result->{alarm})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
return if ($self->{inSept} == 1);
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking digital inputs");
|
||||
$self->{components}->{input} = {name => 'inputs', total => 0, skip => 0};
|
||||
$self->{components}->{input} = { name => 'inputs', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'input'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_isDeviceMonitorDigitalInEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{isDeviceMonitorDigitalInAlarm}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_isDeviceMonitorDigitalInEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'input', instance => $instance));
|
||||
$self->{components}->{input}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("input '%s' status is '%s' [instance = %s]",
|
||||
$result->{isDeviceMonitorDigitalInName}, $result->{isDeviceMonitorDigitalInAlarm}, $instance,
|
||||
));
|
||||
|
||||
my $exit = $self->get_severity(section => 'input', value => $result->{isDeviceMonitorDigitalInAlarm});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Input '%s' status is '%s'", $result->{isDeviceMonitorDigitalInName}, $result->{isDeviceMonitorDigitalInAlarm}));
|
||||
next;
|
||||
}
|
||||
}
|
||||
check_inSeptPro($self) if ($self->{inSeptPro} == 1);
|
||||
}
|
||||
|
||||
1;
|
|
@ -38,17 +38,17 @@ our @EXPORT_OK = qw(%map_default_status %map_input_status %map_state);
|
|||
4 => 'below-low-warning',
|
||||
5 => 'below-low-critical',
|
||||
6 => 'above-high-warning',
|
||||
7 => 'above-high-critical',
|
||||
7 => 'above-high-critical'
|
||||
);
|
||||
|
||||
%map_input_status = (
|
||||
1 => 'normal',
|
||||
2 => 'triggered',
|
||||
2 => 'triggered'
|
||||
);
|
||||
|
||||
%map_state = (
|
||||
1 => 'enabled',
|
||||
2 => 'disabled',
|
||||
2 => 'disabled'
|
||||
);
|
||||
|
||||
1;
|
|
@ -24,29 +24,192 @@ use strict;
|
|||
use warnings;
|
||||
use hardware::sensors::jacarta::snmp::mode::components::resources qw(%map_default_status %map_state);
|
||||
|
||||
my $mapping = {
|
||||
isDeviceMonitorTemperatureName => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.1.1.2' },
|
||||
isDeviceMonitorTemperature => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.1.1.3' },
|
||||
isDeviceMonitorTemperatureAlarm => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.1.1.4', map => \%map_default_status },
|
||||
};
|
||||
my $mapping2 = {
|
||||
isDeviceConfigTemperatureLowWarning => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.3' },
|
||||
isDeviceConfigTemperatureLowCritical => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.4' },
|
||||
isDeviceConfigTemperatureHighWarning => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.5' },
|
||||
isDeviceConfigTemperatureHighCritical => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.6' },
|
||||
isDeviceConfigTemperatureLowWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.9', map => \%map_state },
|
||||
isDeviceConfigTemperatureLowCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.10', map => \%map_state },
|
||||
isDeviceConfigTemperatureHighWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.11', map => \%map_state },
|
||||
isDeviceConfigTemperatureHighCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.12', map => \%map_state },
|
||||
};
|
||||
sub load {}
|
||||
|
||||
my $oid_isDeviceMonitorTemperatureEntry = '.1.3.6.1.4.1.19011.1.3.2.1.3.1.1.1';
|
||||
my $oid_isDeviceConfigTemperatureEntry = '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1';
|
||||
|
||||
sub load {
|
||||
sub check_inSeptPro {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_isDeviceMonitorTemperatureEntry }, { oid => $oid_isDeviceConfigTemperatureEntry };
|
||||
my $mapping = {
|
||||
name => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.1.1.2' }, # isDeviceMonitorTemperatureName
|
||||
current => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.1.1.3' }, # isDeviceMonitorTemperature
|
||||
alarm => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.1.1.1.4', map => \%map_default_status } # isDeviceMonitorTemperatureAlarm
|
||||
};
|
||||
my $mapping_config = {
|
||||
lowWarning => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.3' }, # isDeviceConfigTemperatureLowWarning
|
||||
lowCritical => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.4' }, # isDeviceConfigTemperatureLowCritical
|
||||
highWarning => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.5' }, # isDeviceConfigTemperatureHighWarning
|
||||
highCritical => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.6' }, # isDeviceConfigTemperatureHighCritical
|
||||
lowWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.9', map => \%map_state }, # isDeviceConfigTemperatureLowWarningState
|
||||
lowCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.10', map => \%map_state }, # isDeviceConfigTemperatureLowCriticalState
|
||||
highWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.11', map => \%map_state }, # isDeviceConfigTemperatureHighWarningState
|
||||
highCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1.12', map => \%map_state } # isDeviceConfigTemperatureHighCriticalState
|
||||
};
|
||||
|
||||
my $oid_tempEntry = '.1.3.6.1.4.1.19011.1.3.2.1.3.1.1.1'; # isDeviceMonitorTemperatureEntry
|
||||
my $oid_configTempEntry = '.1.3.6.1.4.1.19011.1.3.2.1.3.2.2.1'; # isDeviceConfigTemperatureEntry
|
||||
|
||||
my $snmp_result = $self->{snmp}->get_multiple_table(
|
||||
oids => [
|
||||
{ oid => $oid_tempEntry, end => $mapping->{alarm}->{oid} } ,
|
||||
{ oid => $oid_configTempEntry, start => $mapping_config->{lowWarning}->{oid}, end => $mapping_config->{lowWarning}->{highCriticalState} }
|
||||
]
|
||||
);
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$snmp_result->{$oid_tempEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{alarm}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_tempEntry}, instance => $instance);
|
||||
my $result2 = $self->{snmp}->map_instance(mapping => $mapping_config, results => $snmp_result->{$oid_configTempEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'temperature', instance => $instance));
|
||||
$self->{components}->{temperature}->{total}++;
|
||||
|
||||
$result->{current} *= 0.01;
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"temperature '%s' status is '%s' [instance: %s] [value: %s]",
|
||||
$result->{name}, $result->{alarm}, $instance,
|
||||
$result->{current}
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'temperature', value => $result->{alarm});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Temperature '%s' status is '%s'", $result->{name}, $result->{alarm})
|
||||
);
|
||||
}
|
||||
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{current});
|
||||
if ($checked == 0) {
|
||||
$result2->{lowWarning} = ($result2->{lowWarningState} eq 'enabled') ? $result2->{lowWarning} * 0.01 : '';
|
||||
$result2->{lowCritical} = ($result2->{lowCriticalState} eq 'enabled') ? $result2->{lowCritical} * 0.01 : '';
|
||||
$result2->{highWarning} = ($result2->{highWarningState} eq 'enabled') ? $result2->{highWarning} * 0.01 : '';
|
||||
$result2->{highCritical} = ($result2->{highCriticalState} eq 'enabled') ? $result2->{highCritical} * 0.01 : '';
|
||||
my $warn_th = $result2->{lowWarning} . ':' . $result2->{highWarning};
|
||||
my $crit_th = $result2->{lowCritical} . ':' . $result2->{highCritical};
|
||||
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th);
|
||||
|
||||
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance);
|
||||
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance);
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit2,
|
||||
short_msg => sprintf("Temperature '%s' is %s %s", $result->{name}, $result->{current}, $self->{temperature_unit})
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => 'hardware.temperature.' . (($self->{temperature_unit} eq 'C') ? 'celsius' : 'fahrenheit'),
|
||||
unit => $self->{temperature_unit},
|
||||
instances => $result->{name},
|
||||
value => $result->{current},
|
||||
warning => $warn,
|
||||
critical => $crit
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
sub check_inSept {
|
||||
my ($self) = @_;
|
||||
|
||||
my $devices = $self->getInSeptDevices();
|
||||
|
||||
my $mapping = {
|
||||
current => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.3.2.1.3' }, # inSeptsensorMonitorDeviceTemperature
|
||||
alarm => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.3.2.1.4', map => \%map_default_status } # inSeptsensorMonitorDeviceTemperatureAlarm
|
||||
};
|
||||
my $mapping_config = {
|
||||
1 => {
|
||||
name => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.3.3.1' }, # inSeptsensorConfigSensor1TemperatureName
|
||||
lowWarning => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.3.3.2' }, # inSeptsensorConfigSensor1TemperatureLowWarning
|
||||
lowCritical => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.3.3.3' }, # inSeptsensorConfigSensor1TemperatureLowCritical
|
||||
highWarning => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.3.3.4' }, # inSeptsensorConfigSensor1TemperatureHighWarning
|
||||
highCritical => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.3.3.5' }, # inSeptsensorConfigSensor1TemperatureHighCritical
|
||||
lowWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.3.3.8', map => \%map_state }, # inSeptsensorConfigSensor1TemperatureLowWarningStatus
|
||||
lowCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.3.3.9', map => \%map_state }, # inSeptsensorConfigSensor1TemperatureLowCriticalStatus
|
||||
highWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.3.3.10', map => \%map_state }, # inSeptsensorConfigSensor1TemperatureHighWarningStatus
|
||||
highCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.3.3.11', map => \%map_state } # inSeptsensorConfigSensor1TemperatureHighCriticalStatus
|
||||
},
|
||||
2 => {
|
||||
name => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.4.3.1' }, # inSeptsensorConfigSensor2TemperatureName
|
||||
lowWarning => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.4.3.2' }, # inSeptsensorConfigSensor2TemperatureLowWarning
|
||||
lowCritical => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.4.3.3' }, # inSeptsensorConfigSensor2TemperatureLowCritical
|
||||
highWarning => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.4.3.4' }, # inSeptsensorConfigSensor2TemperatureHighWarning
|
||||
highCritical => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.4.3.5' }, # inSeptsensorConfigSensor2TemperatureHighCritical
|
||||
lowWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.4.3.8', map => \%map_state }, # inSeptsensorConfigSensor2TemperatureLowWarningStatus
|
||||
lowCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.4.3.9', map => \%map_state }, # inSeptsensorConfigSensor2TemperatureLowCriticalStatus
|
||||
highWarningState => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.4.3.10', map => \%map_state }, # inSeptsensorConfigSensor2TemperatureHighWarningStatus
|
||||
highCriticalState => { oid => '.1.3.6.1.4.1.19011.1.3.1.1.4.4.3.11', map => \%map_state } # inSeptsensorConfigSensor2TemperatureHighCriticalStatus
|
||||
}
|
||||
};
|
||||
my $oid_sensorEntry = '.1.3.6.1.4.1.19011.1.3.1.1.3.2.1'; # inSeptsensorMonitorSensorEntry
|
||||
|
||||
my $snmp_result = $self->{snmp}->get_table(oid => $oid_sensorEntry, start => $mapping->{current}->{oid}, end => $mapping->{alarm}->{oid});
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
|
||||
next if ($oid !~ /^$mapping->{alarm}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
|
||||
next if (!defined($devices->{$instance}) || $devices->{$instance}->{state} eq 'disabled');
|
||||
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
|
||||
my $snmp_config = $self->{snmp}->get_leef(oids => [ map($_->{oid} . '.0', values(%{$mapping_config->{$instance}})) ]);
|
||||
my $result2 = $self->{snmp}->map_instance(mapping => $mapping_config->{$instance}, results => $snmp_config, instance => 0);
|
||||
|
||||
next if ($self->check_filter(section => 'temperature', instance => $instance));
|
||||
$self->{components}->{temperature}->{total}++;
|
||||
|
||||
$result->{current} *= 0.1;
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"temperature '%s' status is '%s' [instance: %s] [value: %s]",
|
||||
$result2->{name}, $result->{alarm}, $instance,
|
||||
$result->{current}
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'temperature', value => $result->{alarm});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Temperature '%s' status is '%s'", $result2->{name}, $result->{alarm})
|
||||
);
|
||||
}
|
||||
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{current});
|
||||
if ($checked == 0) {
|
||||
$result2->{lowWarning} = ($result2->{lowWarningState} eq 'enabled') ? $result2->{lowWarning} * 0.1 : '';
|
||||
$result2->{lowCritical} = ($result2->{lowCriticalState} eq 'enabled') ? $result2->{lowCritical} * 0.1 : '';
|
||||
$result2->{highWarning} = ($result2->{highWarningState} eq 'enabled') ? $result2->{highWarning} * 0.1 : '';
|
||||
$result2->{highCritical} = ($result2->{highCriticalState} eq 'enabled') ? $result2->{highCritical} * 0.1 : '';
|
||||
my $warn_th = $result2->{lowWarning} . ':' . $result2->{highWarning};
|
||||
my $crit_th = $result2->{lowCritical} . ':' . $result2->{highCritical};
|
||||
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th);
|
||||
|
||||
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance);
|
||||
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance);
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit2,
|
||||
short_msg => sprintf("Temperature '%s' is %s %s", $result2->{name}, $result->{current}, $self->{temperature_unit})
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => 'hardware.temperature.' . (($self->{temperature_unit} eq 'C') ? 'celsius' : 'fahrenheit'),
|
||||
unit => $self->{temperature_unit},
|
||||
instances => $result2->{name},
|
||||
value => $result->{current},
|
||||
warning => $warn,
|
||||
critical => $crit
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
sub check {
|
||||
|
@ -56,58 +219,8 @@ sub check {
|
|||
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'temperature'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_isDeviceMonitorTemperatureEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{isDeviceMonitorTemperatureAlarm}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_isDeviceMonitorTemperatureEntry}, instance => $instance);
|
||||
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_isDeviceConfigTemperatureEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'temperature', instance => $instance));
|
||||
$self->{components}->{temperature}->{total}++;
|
||||
|
||||
$result->{isDeviceMonitorTemperature} *= 0.01;
|
||||
$self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s] [value = %s]",
|
||||
$result->{isDeviceMonitorTemperatureName}, $result->{isDeviceMonitorTemperatureAlarm}, $instance,
|
||||
$result->{isDeviceMonitorTemperature}));
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'temperature', value => $result->{isDeviceMonitorTemperatureAlarm});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Temperature '%s' status is '%s'", $result->{isDeviceMonitorTemperatureName}, $result->{isDeviceMonitorTemperatureAlarm}));
|
||||
}
|
||||
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{isDeviceMonitorTemperature});
|
||||
if ($checked == 0) {
|
||||
$result2->{isDeviceConfigTemperatureLowWarning} = ($result2->{isDeviceConfigTemperatureLowWarningState} eq 'enabled') ?
|
||||
$result2->{isDeviceConfigTemperatureLowWarning} * 0.01 : '';
|
||||
$result2->{isDeviceConfigTemperatureLowCritical} = ($result2->{isDeviceConfigTemperatureLowCriticalState} eq 'enabled') ?
|
||||
$result2->{isDeviceConfigTemperatureLowCritical} * 0.01 : '';
|
||||
$result2->{isDeviceConfigTemperatureHighWarning} = ($result2->{isDeviceConfigTemperatureHighWarningState} eq 'enabled') ?
|
||||
$result2->{isDeviceConfigTemperatureHighWarning} * 0.01 : '';
|
||||
$result2->{isDeviceConfigTemperatureHighCritical} = ($result2->{isDeviceConfigTemperatureHighCriticalState} eq 'enabled') ?
|
||||
$result2->{isDeviceConfigTemperatureHighCritical} * 0.01 : '';
|
||||
my $warn_th = $result2->{isDeviceConfigTemperatureLowWarning} . ':' . $result2->{isDeviceConfigTemperatureHighWarning};
|
||||
my $crit_th = $result2->{isDeviceConfigTemperatureLowCritical} . ':' . $result2->{isDeviceConfigTemperatureHighCritical};
|
||||
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th);
|
||||
|
||||
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance);
|
||||
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance);
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit2,
|
||||
short_msg => sprintf("Temperature '%s' is %s %s", $result->{isDeviceMonitorTemperatureName}, $result->{isDeviceMonitorTemperature}, $self->{temperature_unit}));
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'temperature', unit => $self->{temperature_unit},
|
||||
nlabel => 'hardware.temperature.' . (($self->{temperature_unit} eq 'C') ? 'celsius' : 'fahrenheit'),
|
||||
instances => $result->{isDeviceMonitorTemperatureName},
|
||||
value => $result->{isDeviceMonitorTemperature},
|
||||
warning => $warn,
|
||||
critical => $crit,
|
||||
);
|
||||
}
|
||||
check_inSeptPro($self) if ($self->{inSeptPro} == 1);
|
||||
check_inSept($self) if ($self->{inSept} == 1);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -57,17 +57,24 @@ sub snmp_execute {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
$self->{snmp} = $options{snmp};
|
||||
my $oid_isConfigTemperatureUnit = '.1.3.6.1.4.1.19011.1.3.2.1.2.16'; # .0
|
||||
push @{$self->{request}}, { oid => $oid_isConfigTemperatureUnit };
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
|
||||
my $oid_inSeptTempUnit = '.1.3.6.1.4.1.19011.1.3.1.1.2.16.0'; # inSeptConfigTemperatureUnit
|
||||
my $oid_inSeptProTempUnit = '.1.3.6.1.4.1.19011.1.3.2.1.2.16.0'; # isConfigTemperatureUnit
|
||||
my $result = $self->{snmp}->get_leef(oids => [$oid_inSeptTempUnit, $oid_inSeptProTempUnit]);
|
||||
|
||||
$self->{temperature_unit} = defined($self->{results}->{$oid_isConfigTemperatureUnit}->{$oid_isConfigTemperatureUnit . '.0'}) && $self->{results}->{$oid_isConfigTemperatureUnit}->{$oid_isConfigTemperatureUnit . '.0'} == 1 ?
|
||||
'C' : 'F';
|
||||
$self->{inSept} = 0;
|
||||
$self->{inSeptPro} = 0;
|
||||
if (defined($result->{$oid_inSeptProTempUnit})) {
|
||||
$self->{inSeptPro} = 1;
|
||||
$self->{temperature_unit} = $result->{$oid_inSeptProTempUnit} == 1 ? 'C' : 'F';
|
||||
} elsif (defined($result->{$oid_inSeptTempUnit})) {
|
||||
$self->{inSept} = 1;
|
||||
$self->{temperature_unit} = $result->{$oid_inSeptTempUnit} == 1 ? 'C' : 'F';
|
||||
}
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1);
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
@ -75,6 +82,28 @@ sub new {
|
|||
return $self;
|
||||
}
|
||||
|
||||
sub getInSeptDevices {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{inSeptDevices} if (defined($self->{inSeptDevices}));
|
||||
|
||||
my $oid_deviceName1 = '.1.3.6.1.4.1.19011.1.3.1.1.4.3.1.0';
|
||||
my $oid_deviceState1 = '.1.3.6.1.4.1.19011.1.3.1.1.4.3.2.0';
|
||||
my $oid_deviceName2 = '.1.3.6.1.4.1.19011.1.3.1.1.4.4.1.0';
|
||||
my $oid_deviceState2 = '.1.3.6.1.4.1.19011.1.3.1.1.4.4.2.0';
|
||||
my $result = $self->{snmp}->get_leef(oids => [
|
||||
$oid_deviceName1, $oid_deviceState1,
|
||||
$oid_deviceName2, $oid_deviceState2
|
||||
]);
|
||||
|
||||
$self->{inSeptDevices} = {
|
||||
1 => { name => $result->{$oid_deviceName1}, state => $result->{$oid_deviceState1} == 1 ? 'disabled' : 'auto' },
|
||||
2 => { name => $result->{$oid_deviceName2}, state => $result->{$oid_deviceState2} == 1 ? 'disabled' : 'auto' }
|
||||
};
|
||||
|
||||
return $self->{inSeptDevices};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
|
|
@ -29,10 +29,9 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
'sensors' => 'hardware::sensors::jacarta::snmp::mode::sensors',
|
||||
);
|
||||
$self->{modes} = {
|
||||
'sensors' => 'hardware::sensors::jacarta::snmp::mode::sensors'
|
||||
};
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue