enh(cisco/standard/snmp): add fcs-errors + minor environment enhancement (#2883)

This commit is contained in:
qgarnier 2021-06-16 16:15:14 +02:00 committed by GitHub
parent ed5c34ebc4
commit bc5af3af46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 205 additions and 136 deletions

View File

@ -40,7 +40,6 @@ my %map_fan_state2 = (
my $oid_ciscoEnvMonFanStatusEntry = '.1.3.6.1.4.1.9.9.13.1.4.1'; # CISCO-ENVMON-MIB
my $oid_cefcFanTrayOperStatus = '.1.3.6.1.4.1.9.9.117.1.4.1.1.1'; # CISCO-ENTITY-SENSOR-MIB
my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2';
sub load {
my ($self) = @_;
@ -77,9 +76,13 @@ sub check_fan_envmon {
);
my $exit = $self->get_severity(section => 'fan', instance => $instance, value => $result->{ciscoEnvMonFanState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("fan '%s' status is %s",
$result->{ciscoEnvMonFanStatusDescr}, $result->{ciscoEnvMonFanState}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"fan '%s' status is %s",
$result->{ciscoEnvMonFanStatusDescr}, $result->{ciscoEnvMonFanState}
)
);
}
}
}
@ -88,28 +91,30 @@ sub check_fan_entity {
my ($self) = @_;
my $mapping = {
cefcFanTrayOperStatus => { oid => '.1.3.6.1.4.1.9.9.117.1.4.1.1.1', map => \%map_fan_state2 },
cefcFanTrayOperStatus => { oid => '.1.3.6.1.4.1.9.9.117.1.4.1.1.1', map => \%map_fan_state2 }
};
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cefcFanTrayOperStatus}})) {
$oid =~ /\.([0-9]+)$/;
my $instance = $1;
my $fan_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
my $fan_descr = $self->{results}->{ $self->{physical_name} }->{ $self->{physical_name} . '.' . $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, name => $fan_descr));
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"Fan '%s' status is %s [instance: %s]",
"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)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan '%s/%s' status is %s", $fan_descr, $instance, $result->{cefcFanTrayOperStatus}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Fan '%s/%s' status is %s", $fan_descr, $instance, $result->{cefcFanTrayOperStatus})
);
}
}
}
@ -118,7 +123,7 @@ sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking fans");
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
$self->{components}->{fan} = { name => 'fans', total => 0, skip => 0 };
return if ($self->check_filter(section => 'fan'));
check_fan_envmon($self);

View File

@ -50,15 +50,14 @@ my %map_module_state = (
24 => 'mdr',
25 => 'fwMismatchFound',
26 => 'fwDownloadSuccess',
27 => 'fwDownloadFailure',
27 => 'fwDownloadFailure'
);
# In MIB 'CISCO-ENTITY-FRU-CONTROL-MIB'
my $mapping = {
cefcModuleOperStatus => { oid => '.1.3.6.1.4.1.9.9.117.1.2.1.1.2', map => \%map_module_state },
cefcModuleOperStatus => { oid => '.1.3.6.1.4.1.9.9.117.1.2.1.1.2', map => \%map_module_state }
};
my $oid_cefcModuleOperStatus = '.1.3.6.1.4.1.9.9.117.1.2.1.1.2';
my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2';
sub load {
my ($self) = @_;
@ -77,18 +76,26 @@ sub check {
$oid =~ /\.([0-9]+)$/;
my $instance = $1;
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}->{$self->{physical_name} }->{ $self->{physical_name} . '.' . $instance };
next if ($self->check_filter(section => 'module', instance => $instance, name => $module_descr));
$self->{components}->{module}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Module '%s' status is %s [instance: %s]",
$module_descr, $result->{cefcModuleOperStatus}, $instance));
$self->{output}->output_add(
long_msg => sprintf(
"module '%s' status is %s [instance: %s]",
$module_descr, $result->{cefcModuleOperStatus}, $instance
)
);
my $exit = $self->get_severity(section => 'module', instance => $instance, value => $result->{cefcModuleOperStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Module '%s/%s' status is %s", $module_descr,
$instance, $result->{cefcModuleOperStatus}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Module '%s/%s' status is %s",
$module_descr, $instance, $result->{cefcModuleOperStatus}
)
);
}
}
}

View File

@ -32,10 +32,9 @@ my %map_physical_state = (
# In MIB 'CISCO-ENTITY-SENSOR-MIB'
my $mapping = {
cefcPhysicalStatus => { oid => '.1.3.6.1.4.1.9.9.117.1.5.1.1.1', map => \%map_physical_state },
cefcPhysicalStatus => { oid => '.1.3.6.1.4.1.9.9.117.1.5.1.1.1', map => \%map_physical_state }
};
my $oid_cefcPhysicalStatus = '.1.3.6.1.4.1.9.9.117.1.5.1.1.1';
my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2';
sub load {
my ($self) = @_;
@ -45,7 +44,7 @@ sub load {
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking physicals");
$self->{components}->{physical} = {name => 'physical', total => 0, skip => 0};
return if ($self->check_filter(section => 'physical'));
@ -54,23 +53,31 @@ sub check {
$oid =~ /\.([0-9]+)$/;
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcPhysicalStatus}, instance => $instance);
my $physical_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
my $physical_descr = $self->{results}->{ $self->{physical_name} }->{ $self->{physical_name} . '.' . $instance};
if (!defined($physical_descr)) {
$self->{output}->output_add(long_msg => sprintf("skipped instance '%s': no description", $instance));
next;
}
next if ($self->check_filter(section => 'physical', instance => $instance, name => $physical_descr));
$self->{components}->{physical}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Physical '%s' status is %s [instance: %s]",
$physical_descr, $result->{cefcPhysicalStatus}, $instance));
$self->{output}->output_add(
long_msg => sprintf(
"physical '%s' status is %s [instance: %s]",
$physical_descr, $result->{cefcPhysicalStatus}, $instance
)
);
my $exit = $self->get_severity(section => 'physical', instance => $instance, value => $result->{cefcPhysicalStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Physical '%s/%s' status is %s", $physical_descr,
$instance, $result->{cefcPhysicalStatus}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Physical '%s/%s' status is %s",
$physical_descr, $instance, $result->{cefcPhysicalStatus}
)
);
}
}
}

View File

@ -36,7 +36,7 @@ my %map_psu_state1 = (
3 => 'critical',
4 => 'shutdown',
5 => 'not present',
6 => 'not functioning',
6 => 'not functioning'
);
my %map_psu_state2 = (
1 => 'offEnvOther',
@ -50,12 +50,11 @@ my %map_psu_state2 = (
9 => 'onButFanFail',
10 => 'offCooling',
11 => 'offConnectorRating',
12 => 'onButInlinePowerFail',
12 => 'onButInlinePowerFail'
);
my $oid_ciscoEnvMonSupplyStatusEntry = '.1.3.6.1.4.1.9.9.13.1.5.1'; # CISCO-ENVMON-MIB
my $oid_cefcFRUPowerOperStatus = '.1.3.6.1.4.1.9.9.117.1.1.2.1.2'; # CISCO-ENTITY-SENSOR-MIB
my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2';
sub load {
my ($self) = @_;
@ -69,9 +68,9 @@ sub check_psu_envmon {
my $mapping = {
ciscoEnvMonSupplyStatusDescr => { oid => '.1.3.6.1.4.1.9.9.13.1.5.1.2' },
ciscoEnvMonSupplyState => { oid => '.1.3.6.1.4.1.9.9.13.1.5.1.3', map => \%map_psu_state1 },
ciscoEnvMonSupplySource => { oid => '.1.3.6.1.4.1.9.9.13.1.5.1.4', map => \%map_psu_source },
ciscoEnvMonSupplySource => { oid => '.1.3.6.1.4.1.9.9.13.1.5.1.4', map => \%map_psu_source }
};
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_ciscoEnvMonSupplyStatusEntry}})) {
next if ($oid !~ /^$mapping->{ciscoEnvMonSupplyStatusDescr}->{oid}\./);
$oid =~ /\.([0-9]+)$/;
@ -84,41 +83,57 @@ sub check_psu_envmon {
$self->absent_problem(section => 'psu', instance => $instance, name => $result->{ciscoEnvMonSupplyStatusDescr}));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s] [source: %s]",
$result->{ciscoEnvMonSupplyStatusDescr}, $result->{ciscoEnvMonSupplyState},
$instance, $result->{ciscoEnvMonSupplySource}
));
$self->{output}->output_add(
long_msg => sprintf(
"power supply '%s' status is %s [instance: %s] [source: %s]",
$result->{ciscoEnvMonSupplyStatusDescr}, $result->{ciscoEnvMonSupplyState},
$instance, $result->{ciscoEnvMonSupplySource}
)
);
my $exit = $self->get_severity(section => 'psu', instance => $instance, value => $result->{ciscoEnvMonSupplyState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s' status is %s",
$result->{ciscoEnvMonSupplyStatusDescr}, $result->{ciscoEnvMonSupplyState}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Power supply '%s' status is %s",
$result->{ciscoEnvMonSupplyStatusDescr}, $result->{ciscoEnvMonSupplyState}
)
);
}
}
}
sub check_psu_entity {
my ($self) = @_;
my $mapping = {
cefcFRUPowerOperStatus => { oid => '.1.3.6.1.4.1.9.9.117.1.1.2.1.2', map => \%map_psu_state2 },
cefcFRUPowerOperStatus => { oid => '.1.3.6.1.4.1.9.9.117.1.1.2.1.2', map => \%map_psu_state2 }
};
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cefcFRUPowerOperStatus}})) {
$oid =~ /\.([0-9]+)$/;
my $instance = $1;
my $psu_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
my $psu_descr = $self->{results}->{ $self->{physical_name} }->{ $self->{physical_name} . '.' . $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, name => $psu_descr));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s]",
$psu_descr, $result->{cefcFRUPowerOperStatus}, $instance));
$self->{output}->output_add(
long_msg => sprintf(
"Power supply '%s' status is %s [instance: %s]",
$psu_descr, $result->{cefcFRUPowerOperStatus}, $instance
)
);
my $exit = $self->get_severity(section => 'psu', instance => $instance, value => $result->{cefcFRUPowerOperStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s/%s' status is %s", $psu_descr, $instance, $result->{cefcFRUPowerOperStatus}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Power supply '%s/%s' status is %s",
$psu_descr, $instance, $result->{cefcFRUPowerOperStatus}
)
);
}
}
}
@ -127,7 +142,7 @@ sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking power supplies");
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0};
$self->{components}->{psu} = { name => 'psus', total => 0, skip => 0 };
return if ($self->check_filter(section => 'psu'));
check_psu_envmon($self);

View File

@ -43,7 +43,7 @@ my %map_sensor_type = (
11 => 'cmm',
12 => 'truthvalue',
13 => 'specialEnum',
14 => 'dBm',
14 => 'dBm'
);
my %map_scale = (
1 => -24, # yocto,
@ -62,13 +62,13 @@ my %map_scale = (
14 => 18, #exa
15 => 15, #peta
16 => 21, #zetta
17 => 24, #yotta
17 => 24 #yotta
);
my %map_severity = (
1 => 'other',
10 => 'minor',
20 => 'major',
30 => 'critical',
30 => 'critical'
);
my %map_relation = (
1 => 'lessThan',
@ -76,7 +76,7 @@ my %map_relation = (
3 => 'greaterThan',
4 => 'greaterOrEqual',
5 => 'equalTo',
6 => 'notEqualTo',
6 => 'notEqualTo'
);
my %perfdata_unit = (
'other' => '',
@ -92,7 +92,7 @@ my %perfdata_unit = (
'cmm' => '',
'truthvalue' => '',
'specialEnum' => '',
'dBm' => 'dBm',
'dBm' => 'dBm'
);
# In MIB 'CISCO-ENTITY-SENSOR-MIB'
@ -102,16 +102,15 @@ my $mapping = {
entSensorPrecision => { oid => '.1.3.6.1.4.1.9.9.91.1.1.1.1.3' },
entSensorValue => { oid => '.1.3.6.1.4.1.9.9.91.1.1.1.1.4' },
entSensorStatus => { oid => '.1.3.6.1.4.1.9.9.91.1.1.1.1.5', map => \%map_sensor_status },
entSensorValueUpdateRate => { oid => '.1.3.6.1.4.1.9.9.91.1.1.1.1.7' }, # 0 means no threshold check
entSensorValueUpdateRate => { oid => '.1.3.6.1.4.1.9.9.91.1.1.1.1.7' } # 0 means no threshold check
};
my $mapping2 = {
entSensorThresholdSeverity => { oid => '.1.3.6.1.4.1.9.9.91.1.2.1.1.2', map => \%map_severity },
entSensorThresholdRelation => { oid => '.1.3.6.1.4.1.9.9.91.1.2.1.1.3', map => \%map_relation },
entSensorThresholdValue => { oid => '.1.3.6.1.4.1.9.9.91.1.2.1.1.4' },
entSensorThresholdValue => { oid => '.1.3.6.1.4.1.9.9.91.1.2.1.1.4' }
};
my $oid_entSensorValueEntry = '.1.3.6.1.4.1.9.9.91.1.1.1.1';
my $oid_entSensorThresholdEntry = '.1.3.6.1.4.1.9.9.91.1.2.1.1';
my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2';
sub load {
my ($self) = @_;
@ -201,10 +200,10 @@ sub check {
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_entSensorValueEntry}, instance => $instance);
next if (!defined($self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance}));
my $sensor_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
next if (!defined($self->{results}->{ $self->{physical_name} }->{ $self->{physical_name} . '.' . $instance }));
my $sensor_descr = $self->{results}->{ $self->{physical_name} }->{ $self->{physical_name} . '.' . $instance };
next if ($self->check_filter(section => 'sensor', instance => $result->{entSensorType} . '.' . $instance));
next if ($self->check_filter(section => 'sensor', instance => $result->{entSensorType} . '.' . $instance, name => $sensor_descr));
$self->{components}->{sensor}->{total}++;
$result->{entSensorValue} = defined($result->{entSensorValue}) ?
@ -212,7 +211,7 @@ sub check {
$self->{output}->output_add(
long_msg => sprintf(
"Sensor '%s' status is '%s' [instance: %s] [value: %s %s]",
"sensor '%s' status is '%s' [instance: %s] [value: %s %s]",
$sensor_descr, $result->{entSensorStatus},
$instance,
defined($result->{entSensorValue}) ? $result->{entSensorValue} : '-',
@ -233,7 +232,12 @@ sub check {
next if (!defined($result->{entSensorValue}) || $result->{entSensorValue} !~ /[0-9]/);
my $component = 'sensor.' . $result->{entSensorType};
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => $component, instance => $instance, value => $result->{entSensorValue});
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(
section => $component,
instance => $instance,
name => $sensor_descr,
value => $result->{entSensorValue}
);
if ($checked == 0) {
my $warn_th = get_default_warning_threshold($self, instance => $instance, result => $result);
my $crit_th = get_default_critical_threshold($self, instance => $instance, result => $result);

View File

@ -29,7 +29,7 @@ my %map_temperature_state = (
3 => 'critical',
4 => 'shutdown',
5 => 'not present',
6 => 'not functioning',
6 => 'not functioning'
);
# In MIB 'CISCO-ENVMON-MIB'
@ -37,43 +37,47 @@ my $mapping = {
ciscoEnvMonTemperatureStatusDescr => { oid => '.1.3.6.1.4.1.9.9.13.1.3.1.2' },
ciscoEnvMonTemperatureStatusValue => { oid => '.1.3.6.1.4.1.9.9.13.1.3.1.3' },
ciscoEnvMonTemperatureThreshold => { oid => '.1.3.6.1.4.1.9.9.13.1.3.1.4' },
ciscoEnvMonTemperatureState => { oid => '.1.3.6.1.4.1.9.9.13.1.3.1.6', map => \%map_temperature_state },
ciscoEnvMonTemperatureState => { oid => '.1.3.6.1.4.1.9.9.13.1.3.1.6', map => \%map_temperature_state }
};
my $oid_ciscoEnvMonTemperatureStatusEntry = '.1.3.6.1.4.1.9.9.13.1.3.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_ciscoEnvMonTemperatureStatusEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking temperatures");
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
$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_ciscoEnvMonTemperatureStatusEntry}})) {
next if ($oid !~ /^$mapping->{ciscoEnvMonTemperatureState}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonTemperatureStatusEntry}, instance => $instance);
next if ($self->check_filter(section => 'temperature', instance => $instance, name => $result->{ciscoEnvMonTemperatureStatusDescr}));
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"Temperature '%s' status is %s [instance: %s] [value: %s C]",
"temperature '%s' status is %s [instance: %s] [value: %s C]",
$result->{ciscoEnvMonTemperatureStatusDescr}, $result->{ciscoEnvMonTemperatureState},
$instance, defined($result->{ciscoEnvMonTemperatureStatusValue}) ? $result->{ciscoEnvMonTemperatureStatusValue} : '-'
)
);
my $exit = $self->get_severity(section => 'temperature', instance => $instance, value => $result->{ciscoEnvMonTemperatureState});
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->{ciscoEnvMonTemperatureStatusDescr}, $result->{ciscoEnvMonTemperatureState}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Temperature '%s' status is %s",
$result->{ciscoEnvMonTemperatureStatusDescr}, $result->{ciscoEnvMonTemperatureState}
)
);
}
next if (!defined($result->{ciscoEnvMonTemperatureStatusValue}));
@ -88,8 +92,10 @@ sub check {
$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 degree centigrade", $result->{ciscoEnvMonTemperatureStatusDescr}, $result->{ciscoEnvMonTemperatureStatusValue}));
$self->{output}->output_add(
severity => $exit2,
short_msg => sprintf("Temperature '%s' is %s degree centigrade", $result->{ciscoEnvMonTemperatureStatusDescr}, $result->{ciscoEnvMonTemperatureStatusValue})
);
}
$self->{output}->perfdata_add(
label => "temp", unit => 'C',

View File

@ -29,7 +29,7 @@ my %map_voltage_state = (
3 => 'critical',
4 => 'shutdown',
5 => 'not present',
6 => 'not functioning',
6 => 'not functioning'
);
# In MIB 'CISCO-ENVMON-MIB'
@ -38,39 +38,47 @@ my $mapping = {
ciscoEnvMonVoltageStatusValue => { oid => '.1.3.6.1.4.1.9.9.13.1.2.1.3' },
ciscoEnvMonVoltageThresholdLow => { oid => '.1.3.6.1.4.1.9.9.13.1.2.1.4' },
ciscoEnvMonVoltageThresholdHigh => { oid => '.1.3.6.1.4.1.9.9.13.1.2.1.5' },
ciscoEnvMonVoltageState => { oid => '.1.3.6.1.4.1.9.9.13.1.2.1.7', map => \%map_voltage_state },
ciscoEnvMonVoltageState => { oid => '.1.3.6.1.4.1.9.9.13.1.2.1.7', map => \%map_voltage_state }
};
my $oid_ciscoEnvMonVoltageStatusEntry = '.1.3.6.1.4.1.9.9.13.1.2.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_ciscoEnvMonVoltageStatusEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking voltages");
$self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0};
$self->{components}->{voltage} = { name => 'voltages', total => 0, skip => 0 };
return if ($self->check_filter(section => 'voltage'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_ciscoEnvMonVoltageStatusEntry}})) {
next if ($oid !~ /^$mapping->{ciscoEnvMonVoltageState}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonVoltageStatusEntry}, instance => $instance);
next if ($self->check_filter(section => 'voltage', instance => $instance, name => $result->{ciscoEnvMonVoltageStatusDescr}));
$self->{components}->{voltage}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Voltage '%s' status is %s [instance: %s] [value: %s C]",
$result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageState},
$instance, $result->{ciscoEnvMonVoltageStatusValue}));
$self->{output}->output_add(
long_msg => sprintf(
"voltage '%s' status is %s [instance: %s] [value: %s C]",
$result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageState},
$instance, $result->{ciscoEnvMonVoltageStatusValue}
)
);
my $exit = $self->get_severity(section => 'voltage', instance => $instance, value => $result->{ciscoEnvMonVoltageState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Voltage '%s' status is %s",
$result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageState}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Voltage '%s' status is %s",
$result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageState}
)
);
}
$result->{ciscoEnvMonVoltageStatusValue} = $result->{ciscoEnvMonVoltageStatusValue} / 1000;
@ -85,14 +93,16 @@ sub check {
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-voltage-instance-' . $instance);
}
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit2,
short_msg => sprintf("Voltage '%s' is %.3f V", $result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageStatusValue}));
$self->{output}->output_add(
severity => $exit2,
short_msg => sprintf("Voltage '%s' is %.3f V", $result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageStatusValue})
);
}
$self->{output}->perfdata_add(
label => "voltage", unit => 'V',
label => 'voltage', unit => 'V',
nlabel => 'hardware.voltage.volt',
instances => $result->{ciscoEnvMonVoltageStatusDescr},
value => sprintf("%.3f", $result->{ciscoEnvMonVoltageStatusValue}),
value => sprintf('%.3f', $result->{ciscoEnvMonVoltageStatusValue}),
warning => $warn,
critical => $crit
);

View File

@ -97,8 +97,7 @@ sub set_system {
$self->{components_module} = ['fan', 'psu', 'temperature', 'voltage', 'module', 'physical', 'sensor'];
}
my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2';
my $oid_ciscoEnvMonPresent = ".1.3.6.1.4.1.9.9.13.1.1";
my $oid_ciscoEnvMonPresent = '.1.3.6.1.4.1.9.9.13.1.1';
my %map_type_mon = (
1 => 'oldAgs',
@ -120,11 +119,12 @@ sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{physical_name} = defined($self->{option_results}->{use_physical_name}) ? '.1.3.6.1.2.1.47.1.1.1.1.7' : '.1.3.6.1.2.1.47.1.1.1.1.2';
push @{$self->{request}}, { oid => $oid_entPhysicalDescr }, { oid => $oid_ciscoEnvMonPresent };
push @{$self->{request}}, { oid => $self->{physical_name} }, { oid => $oid_ciscoEnvMonPresent };
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
while (my ($key, $value) = each %{$self->{results}->{$oid_entPhysicalDescr}}) {
$self->{results}->{$oid_entPhysicalDescr}->{$key} = centreon::plugins::misc::trim($value);
while (my ($key, $value) = each %{$self->{results}->{ $self->{physical_name} }}) {
$self->{results}->{ $self->{physical_name} }->{$key} = centreon::plugins::misc::trim($value);
}
$self->{output}->output_add(
long_msg => sprintf(
@ -140,7 +140,8 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
$options{options}->add_options(arguments => {
'use-physical-name' => { name => 'use_physical_name' }
});
return $self;
@ -170,6 +171,10 @@ Can also exclude specific instance: --filter=fan,1
Add literal description for instance value (used in filter, absent-problem and threshold options).
=item B<--use-physical-name>
Use entPhysicalName OID instead of entPhysicalDescr.
=item B<--absent-problem>
Return an error if an entity is not 'present' (default is skipping) (comma seperated list)

View File

@ -88,11 +88,9 @@ sub set_oids_status {
sub set_oids_errors {
my ($self, %options) = @_;
$self->{oid_ifInDiscards} = '.1.3.6.1.2.1.2.2.1.13';
$self->{oid_ifInErrors} = '.1.3.6.1.2.1.2.2.1.14';
$self->{oid_ifOutDiscards} = '.1.3.6.1.2.1.2.2.1.19';
$self->{oid_ifOutErrors} = '.1.3.6.1.2.1.2.2.1.20';
$self->SUPER::set_oids_errors(%options);
$self->{oid_ifInFCSError} = '.1.3.6.1.2.1.10.7.2.1.3'; # dot3StatsFCSErrors
$self->{oid_ifInCrc} = '.1.3.6.1.4.1.9.2.2.1.1.12';
}
@ -109,6 +107,15 @@ sub set_counters_errors {
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
closure_custom_threshold_check => $self->can('custom_errors_threshold')
}
},
{ label => 'in-fcserror', filter => 'add_errors', nlabel => 'interface.packets.in.fcserror.count', set => {
key_values => [ { name => 'infcserror', diff => 1 }, { name => 'total_in_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
closure_custom_calc => $self->can('custom_errors_calc'),
closure_custom_calc_extra_options => { label_ref1 => 'in', label_ref2 => 'fcserror' },
closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets In FCS Error : %s',
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
closure_custom_threshold_check => $self->can('custom_errors_threshold')
}
}
;
}
@ -127,13 +134,13 @@ sub new {
sub load_errors {
my ($self, %options) = @_;
$self->set_oids_errors();
$self->{snmp}->load(
oids => [
$self->{oid_ifInDiscards}, $self->{oid_ifInErrors},
$self->{oid_ifOutDiscards}, $self->{oid_ifOutErrors},
$self->{oid_ifInCrc}
$self->{oid_ifInCrc}, $self->{oid_ifInFCSError}
],
instances => $self->{array_interface_selected}
);
@ -156,6 +163,7 @@ sub add_result_errors {
$self->{int}->{$options{instance}}->{outdiscard} = $self->{results}->{$self->{oid_ifOutDiscards} . '.' . $options{instance}};
$self->{int}->{$options{instance}}->{outerror} = $self->{results}->{$self->{oid_ifOutErrors} . '.' . $options{instance}};
$self->{int}->{$options{instance}}->{incrc} = $self->{results}->{$self->{oid_ifInCrc} . '.' . $options{instance}};
$self->{int}->{$options{instance}}->{infcserror} = $self->{results}->{$self->{oid_ifInFCSError} . '.' . $options{instance}};
}
sub add_result_status {
@ -243,7 +251,7 @@ Can used special variables like: %{admstatus}, %{opstatus}, %{duplexstatus}, %{e
Thresholds.
Can be: 'total-port', 'total-admin-up', 'total-admin-down', 'total-oper-up', 'total-oper-down',
'in-traffic', 'out-traffic', 'in-crc', 'in-error', 'in-discard', 'out-error', 'out-discard',
'in-traffic', 'out-traffic', 'in-crc', 'in-fcserror', 'in-error', 'in-discard', 'out-error', 'out-discard',
'in-ucast', 'in-bcast', 'in-mcast', 'out-ucast', 'out-bcast', 'out-mcast',
'speed' (b/s).

View File

@ -65,10 +65,12 @@ sub custom_usage_output {
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});
$msg = sprintf("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});
$msg = sprintf(
'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}
);
} else {
$msg = sprintf("Usage : %.2f %%", $self->{result_values}->{prct_used});
}
@ -91,39 +93,39 @@ sub custom_usage_calc {
return 0;
}
sub prefix_memory_output {
my ($self, %options) = @_;
return "Memory '" . $options{instance_value}->{display} . "' ";
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'memory', type => 1, cb_prefix_output => 'prefix_memory_output', message_multiple => 'All memories are ok', skipped_code => { -10 => 1 } },
{ name => 'memory', type => 1, cb_prefix_output => 'prefix_memory_output', message_multiple => 'All memories are ok', skipped_code => { -10 => 1 } }
];
$self->{maps_counters}->{memory} = [
{ label => 'usage', nlabel => 'memory.usage.percentage', set => {
key_values => [ { name => 'display' }, { name => 'used' }, { name => 'total' }, { name => 'prct_used' } ],
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'),
closure_custom_threshold_check => $self->can('custom_usage_threshold')
}
},
}
];
}
sub prefix_memory_output {
my ($self, %options) = @_;
return "Memory '" . $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-pool:s' => { name => 'filter_pool' },
'check-order:s' => { name => 'check_order', default => 'enhanced_pool,pool,process,system_ext' },
'filter-pool:s' => { name => 'filter_pool' },
'check-order:s' => { name => 'check_order', default => 'enhanced_pool,pool,process,system_ext' }
});
return $self;
@ -132,7 +134,7 @@ sub new {
my $mapping_memory_pool = {
ciscoMemoryPoolName => { oid => '.1.3.6.1.4.1.9.9.48.1.1.1.2' },
ciscoMemoryPoolUsed => { oid => '.1.3.6.1.4.1.9.9.48.1.1.1.5' }, # in B
ciscoMemoryPoolFree => { oid => '.1.3.6.1.4.1.9.9.48.1.1.1.6' }, # in B
ciscoMemoryPoolFree => { oid => '.1.3.6.1.4.1.9.9.48.1.1.1.6' } # in B
};
my $oid_ciscoMemoryPoolEntry = '.1.3.6.1.4.1.9.9.48.1.1.1';
@ -140,12 +142,12 @@ sub check_memory_pool {
my ($self, %options) = @_;
return if ($self->{checked_memory} == 1);
my $snmp_result = $self->{snmp}->get_table(
oid => $oid_ciscoMemoryPoolEntry,
start => $mapping_memory_pool->{ciscoMemoryPoolName}->{oid}, end => $mapping_memory_pool->{ciscoMemoryPoolFree}->{oid}
);
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping_memory_pool->{ciscoMemoryPoolName}->{oid}\.(.*)$/);
my $instance = $1;