This commit is contained in:
garnier-quentin 2019-10-21 09:41:51 +02:00
parent 656ed0ee41
commit 178ca521b6
7 changed files with 50 additions and 35 deletions

View File

@ -63,16 +63,19 @@ sub check_fan_envmon {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonFanStatusEntry}, instance => $instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonFanStatusEntry}, instance => $instance);
next if ($self->check_filter(section => 'fan', instance => $instance)); next if ($self->check_filter(section => 'fan', instance => $instance, name => $result->{ciscoEnvMonFanStatusDescr}));
next if ($result->{ciscoEnvMonFanState} =~ /not present/i && next if ($result->{ciscoEnvMonFanState} =~ /not present/i &&
$self->absent_problem(section => 'fan', instance => $instance)); $self->absent_problem(section => 'fan', instance => $instance, name => $result->{ciscoEnvMonFanStatusDescr}));
$self->{components}->{fan}->{total}++; $self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("fan '%s' status is %s [instance: %s].", $self->{output}->output_add(
long_msg => sprintf(
"fan '%s' status is %s [instance: %s].",
$result->{ciscoEnvMonFanStatusDescr}, $result->{ciscoEnvMonFanState}, $result->{ciscoEnvMonFanStatusDescr}, $result->{ciscoEnvMonFanState},
$instance $instance
)); )
my $exit = $self->get_severity(section => 'fan', value => $result->{ciscoEnvMonFanState}); );
my $exit = $self->get_severity(section => 'fan', instance => $instance, value => $result->{ciscoEnvMonFanState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("fan '%s' status is %s", short_msg => sprintf("fan '%s' status is %s",
@ -94,12 +97,16 @@ sub check_fan_entity {
my $fan_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance}; my $fan_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcFanTrayOperStatus}, instance => $instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcFanTrayOperStatus}, instance => $instance);
next if ($self->check_filter(section => 'fan', instance => $instance)); next if ($self->check_filter(section => 'fan', instance => $instance, name => $fan_descr));
$self->{components}->{fan}->{total}++; $self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Fan '%s' status is %s [instance: %s]", $self->{output}->output_add(
$fan_descr, $result->{cefcFanTrayOperStatus}, $instance)); long_msg => sprintf(
my $exit = $self->get_severity(section => 'fan', value => $result->{cefcFanTrayOperStatus}); "Fan '%s' status is %s [instance: %s]",
$fan_descr, $result->{cefcFanTrayOperStatus}, $instance
)
);
my $exit = $self->get_severity(section => 'fan', instance => $instance, value => $result->{cefcFanTrayOperStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan '%s/%s' status is %s", $fan_descr, $instance, $result->{cefcFanTrayOperStatus})); short_msg => sprintf("Fan '%s/%s' status is %s", $fan_descr, $instance, $result->{cefcFanTrayOperStatus}));

View File

@ -79,12 +79,12 @@ sub check {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcModuleOperStatus}, instance => $instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcModuleOperStatus}, instance => $instance);
my $module_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance}; my $module_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
next if ($self->check_filter(section => 'module', instance => $instance)); next if ($self->check_filter(section => 'module', instance => $instance, name => $module_descr));
$self->{components}->{module}->{total}++; $self->{components}->{module}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Module '%s' status is %s [instance: %s]", $self->{output}->output_add(long_msg => sprintf("Module '%s' status is %s [instance: %s]",
$module_descr, $result->{cefcModuleOperStatus}, $instance)); $module_descr, $result->{cefcModuleOperStatus}, $instance));
my $exit = $self->get_severity(section => 'module', value => $result->{cefcModuleOperStatus}); my $exit = $self->get_severity(section => 'module', instance => $instance, value => $result->{cefcModuleOperStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Module '%s/%s' status is %s", $module_descr, short_msg => sprintf("Module '%s/%s' status is %s", $module_descr,

View File

@ -61,12 +61,12 @@ sub check {
next; next;
} }
next if ($self->check_filter(section => 'physical', instance => $instance)); next if ($self->check_filter(section => 'physical', instance => $instance, name => $physical_descr));
$self->{components}->{physical}->{total}++; $self->{components}->{physical}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Physical '%s' status is %s [instance: %s]", $self->{output}->output_add(long_msg => sprintf("Physical '%s' status is %s [instance: %s]",
$physical_descr, $result->{cefcPhysicalStatus}, $instance)); $physical_descr, $result->{cefcPhysicalStatus}, $instance));
my $exit = $self->get_severity(section => 'physical', value => $result->{cefcPhysicalStatus}); my $exit = $self->get_severity(section => 'physical', instance => $instance, value => $result->{cefcPhysicalStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Physical '%s/%s' status is %s", $physical_descr, short_msg => sprintf("Physical '%s/%s' status is %s", $physical_descr,

View File

@ -79,16 +79,16 @@ sub check_psu_envmon {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonSupplyStatusEntry}, instance => $instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonSupplyStatusEntry}, instance => $instance);
next if ($self->check_filter(section => 'psu', instance => $instance)); next if ($self->check_filter(section => 'psu', instance => $instance, name => $result->{ciscoEnvMonSupplyStatusDescr}));
next if ($result->{ciscoEnvMonSupplyState} =~ /not present/i && next if ($result->{ciscoEnvMonSupplyState} =~ /not present/i &&
$self->absent_problem(section => 'psu', instance => $instance)); $self->absent_problem(section => 'psu', instance => $instance, name => $result->{ciscoEnvMonSupplyStatusDescr}));
$self->{components}->{psu}->{total}++; $self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s] [source: %s]", $self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s] [source: %s]",
$result->{ciscoEnvMonSupplyStatusDescr}, $result->{ciscoEnvMonSupplyState}, $result->{ciscoEnvMonSupplyStatusDescr}, $result->{ciscoEnvMonSupplyState},
$instance, $result->{ciscoEnvMonSupplySource} $instance, $result->{ciscoEnvMonSupplySource}
)); ));
my $exit = $self->get_severity(section => 'psu', value => $result->{ciscoEnvMonSupplyState}); my $exit = $self->get_severity(section => 'psu', instance => $instance, value => $result->{ciscoEnvMonSupplyState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s' status is %s", short_msg => sprintf("Power supply '%s' status is %s",
@ -110,12 +110,12 @@ sub check_psu_entity {
my $psu_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance}; my $psu_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcFRUPowerOperStatus}, instance => $instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcFRUPowerOperStatus}, instance => $instance);
next if ($self->check_filter(section => 'psu', instance => $instance)); next if ($self->check_filter(section => 'psu', instance => $instance, name => $psu_descr));
$self->{components}->{psu}->{total}++; $self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s]", $self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s]",
$psu_descr, $result->{cefcFRUPowerOperStatus}, $instance)); $psu_descr, $result->{cefcFRUPowerOperStatus}, $instance));
my $exit = $self->get_severity(section => 'psu', value => $result->{cefcFRUPowerOperStatus}); my $exit = $self->get_severity(section => 'psu', instance => $instance, value => $result->{cefcFRUPowerOperStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s/%s' status is %s", $psu_descr, $instance, $result->{cefcFRUPowerOperStatus})); short_msg => sprintf("Power supply '%s/%s' status is %s", $psu_descr, $instance, $result->{cefcFRUPowerOperStatus}));

View File

@ -59,13 +59,17 @@ sub check {
my $instance = $1; my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonTemperatureStatusEntry}, instance => $instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonTemperatureStatusEntry}, instance => $instance);
next if ($self->check_filter(section => 'temperature', instance => $instance)); next if ($self->check_filter(section => 'temperature', instance => $instance, name => $result->{ciscoEnvMonTemperatureStatusDescr}));
$self->{components}->{temperature}->{total}++; $self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Temperature '%s' status is %s [instance: %s] [value: %s C]", $self->{output}->output_add(
long_msg => sprintf(
"Temperature '%s' status is %s [instance: %s] [value: %s C]",
$result->{ciscoEnvMonTemperatureStatusDescr}, $result->{ciscoEnvMonTemperatureState}, $result->{ciscoEnvMonTemperatureStatusDescr}, $result->{ciscoEnvMonTemperatureState},
$instance, defined($result->{ciscoEnvMonTemperatureStatusValue}) ? $result->{ciscoEnvMonTemperatureStatusValue} : '-')); $instance, defined($result->{ciscoEnvMonTemperatureStatusValue}) ? $result->{ciscoEnvMonTemperatureStatusValue} : '-'
my $exit = $self->get_severity(section => 'temperature', value => $result->{ciscoEnvMonTemperatureState}); )
);
my $exit = $self->get_severity(section => 'temperature', instance => $instance, value => $result->{ciscoEnvMonTemperatureState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Temperature '%s' status is %s", short_msg => sprintf("Temperature '%s' status is %s",
@ -74,7 +78,7 @@ sub check {
next if (!defined($result->{ciscoEnvMonTemperatureStatusValue})); next if (!defined($result->{ciscoEnvMonTemperatureStatusValue}));
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{ciscoEnvMonTemperatureStatusValue}); my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, name => $result->{ciscoEnvMonTemperatureStatusDescr}, value => $result->{ciscoEnvMonTemperatureStatusValue});
if ($checked == 0) { if ($checked == 0) {
my $warn_th = undef; my $warn_th = undef;
my $crit_th = '~:' . $result->{ciscoEnvMonTemperatureThreshold}; my $crit_th = '~:' . $result->{ciscoEnvMonTemperatureThreshold};

View File

@ -60,13 +60,13 @@ sub check {
my $instance = $1; my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonVoltageStatusEntry}, instance => $instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonVoltageStatusEntry}, instance => $instance);
next if ($self->check_filter(section => 'voltage', instance => $instance)); next if ($self->check_filter(section => 'voltage', instance => $instance, name => $result->{ciscoEnvMonVoltageStatusDescr}));
$self->{components}->{voltage}->{total}++; $self->{components}->{voltage}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Voltage '%s' status is %s [instance: %s] [value: %s C]", $self->{output}->output_add(long_msg => sprintf("Voltage '%s' status is %s [instance: %s] [value: %s C]",
$result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageState}, $result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageState},
$instance, $result->{ciscoEnvMonVoltageStatusValue})); $instance, $result->{ciscoEnvMonVoltageStatusValue}));
my $exit = $self->get_severity(section => 'voltage', value => $result->{ciscoEnvMonVoltageState}); my $exit = $self->get_severity(section => 'voltage', instance => $instance, value => $result->{ciscoEnvMonVoltageState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Voltage '%s' status is %s", short_msg => sprintf("Voltage '%s' status is %s",
@ -74,7 +74,7 @@ sub check {
} }
$result->{ciscoEnvMonVoltageStatusValue} = $result->{ciscoEnvMonVoltageStatusValue} / 1000; $result->{ciscoEnvMonVoltageStatusValue} = $result->{ciscoEnvMonVoltageStatusValue} / 1000;
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{ciscoEnvMonVoltageStatusValue}); my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, name => $result->{ciscoEnvMonVoltageStatusDescr}, value => $result->{ciscoEnvMonVoltageStatusValue});
if ($checked == 0) { if ($checked == 0) {
my $warn_th = undef; my $warn_th = undef;
my $crit_th = ((defined($result->{ciscoEnvMonVoltageThresholdLow}) && $result->{ciscoEnvMonVoltageThresholdLow} =~ /\d/) ? sprintf("%.3f", $result->{ciscoEnvMonVoltageThresholdLow} / 1000) : 0) . ':' . my $crit_th = ((defined($result->{ciscoEnvMonVoltageThresholdLow}) && $result->{ciscoEnvMonVoltageThresholdLow} =~ /\d/) ? sprintf("%.3f", $result->{ciscoEnvMonVoltageThresholdLow} / 1000) : 0) . ':' .

View File

@ -164,6 +164,10 @@ Can be: 'fan', 'psu', 'temperature', 'voltage', 'module', 'physical', 'sensor'.
Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu)
Can also exclude specific instance: --filter=fan,1 Can also exclude specific instance: --filter=fan,1
=item B<--add-name-instance>
Add literal description for instance value (used in filter, absent-problem and threshold options).
=item B<--absent-problem> =item B<--absent-problem>
Return an error if an entity is not 'present' (default is skipping) (comma seperated list) Return an error if an entity is not 'present' (default is skipping) (comma seperated list)