enhance raisecom snmp plugin
This commit is contained in:
parent
4dabc5181b
commit
6202d2ee7e
|
@ -29,8 +29,8 @@ my %map_fan_state = (
|
|||
);
|
||||
|
||||
my $mapping = {
|
||||
raisecomFanSpeedValue => { oid => '.1.3.6.1.4.1.8886.1.1.5.2.2.1.2' },
|
||||
raisecomFanWorkState => { oid => '.1.3.6.1.4.1.8886.1.1.5.2.2.1.3', map => \%map_fan_state },
|
||||
raisecomFanSpeedValue => { oid => '.1.3.6.1.4.1.8886.1.1.5.2.2.1.2' },
|
||||
raisecomFanWorkState => { oid => '.1.3.6.1.4.1.8886.1.1.5.2.2.1.3', map => \%map_fan_state },
|
||||
};
|
||||
my $oid_raisecomFanMonitorStateEntry = '.1.3.6.1.4.1.8886.1.1.5.2.2.1';
|
||||
|
||||
|
@ -59,19 +59,21 @@ sub check {
|
|||
$instance, $result->{raisecomFanWorkState}, $instance));
|
||||
my $exit = $self->get_severity(section => 'fan', value => $result->{raisecomFanWorkState});
|
||||
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'", $instance, $result->{raisecomFanWorkState}));
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Fan '%s' status is '%s'", $instance, $result->{raisecomFanWorkState}));
|
||||
}
|
||||
|
||||
my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'fan.speed', instance => $instance, value => $result->{raisecomFanSpeedValue});
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit2,
|
||||
short_msg => sprintf("Fan speed '%s' is %s rpm", $instance, $result->{raisecomFanSpeedValue}));
|
||||
$self->{output}->perfdata_add(label => 'fan_speed_' . $instance, unit => 'rpm',
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(label => 'fan_' . $instance, unit => 'rpm',
|
||||
value => $result->{raisecomFanSpeedValue},
|
||||
warning => $warn,
|
||||
critical => $crit,
|
||||
);
|
||||
}
|
||||
min => 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,9 +24,9 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
my $mapping = {
|
||||
raisecomTemperatureValue => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.1' },
|
||||
raisecomTemperatureThresholdLow => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.5' },
|
||||
raisecomTemperatureThresholdHigh => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.6' },
|
||||
raisecomTemperatureValue => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.1' },
|
||||
raisecomTemperatureThresholdLow => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.5' },
|
||||
raisecomTemperatureThresholdHigh => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.6' },
|
||||
};
|
||||
my $oid_raisecomTemperatureEntry = '.1.3.6.1.4.1.8886.1.1.4.2';
|
||||
|
||||
|
@ -57,7 +57,7 @@ sub check {
|
|||
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{raisecomTemperatureValue});
|
||||
if ($checked == 0) {
|
||||
my $warn_th = ':' . $result->{raisecomTemperatureThresholdLow};
|
||||
my $warn_th = $result->{raisecomTemperatureThresholdLow} . ':';
|
||||
my $crit_th = ':' . $result->{raisecomTemperatureThresholdHigh};
|
||||
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th);
|
||||
|
|
|
@ -24,9 +24,9 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
my $mapping = {
|
||||
raisecomVoltValue => { oid => '.1.3.6.1.4.1.8886.1.1.4.3.1.1.3' },
|
||||
raisecomVoltThresholdLow => { oid => '.1.3.6.1.4.1.8886.1.1.4.3.1.1.7' },
|
||||
raisecomVoltThresholdHigh => { oid => '.1.3.6.1.4.1.8886.1.1.4.3.1.1.8' },
|
||||
raisecomVoltValue => { oid => '.1.3.6.1.4.1.8886.1.1.4.3.1.1.3' },
|
||||
raisecomVoltThresholdLow => { oid => '.1.3.6.1.4.1.8886.1.1.4.3.1.1.7' },
|
||||
raisecomVoltThresholdHigh => { oid => '.1.3.6.1.4.1.8886.1.1.4.3.1.1.8' },
|
||||
};
|
||||
my $oid_raisecomVoltEntry = '.1.3.6.1.4.1.8886.1.1.4.3.1.1';
|
||||
|
||||
|
@ -51,13 +51,13 @@ sub check {
|
|||
next if ($self->check_filter(section => 'voltage', instance => $instance));
|
||||
$self->{components}->{voltage}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("voltage '%s' is %.2f V [instance: %s].",
|
||||
$self->{output}->output_add(long_msg => sprintf("voltage '%s' is %.2f mV [instance: %s].",
|
||||
$instance, $result->{raisecomVoltValue}, $instance
|
||||
));
|
||||
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{raisecomVoltValue});
|
||||
if ($checked == 0) {
|
||||
my $warn_th = ':' . $result->{raisecomVoltThresholdLow};
|
||||
my $warn_th = $result->{raisecomVoltThresholdLow} . ':';
|
||||
my $crit_th = ':' . $result->{raisecomVoltThresholdHigh};
|
||||
$self->{perfdata}->threshold_validate(label => 'warning-voltage-instance-' . $instance, value => $warn_th);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical-voltage-instance-' . $instance, value => $crit_th);
|
||||
|
@ -70,9 +70,9 @@ sub check {
|
|||
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Voltage '%s' is %.2f V", $instance, $result->{raisecomVoltValue}));
|
||||
short_msg => sprintf("Voltage '%s' is %.2f mV", $instance, $result->{raisecomVoltValue}));
|
||||
}
|
||||
$self->{output}->perfdata_add(label => 'volt_' . $instance, unit => 'V',
|
||||
$self->{output}->perfdata_add(label => 'volt_' . $instance, unit => 'mV',
|
||||
value => $result->{raisecomVoltValue},
|
||||
warning => $warn,
|
||||
critical => $crit,
|
||||
|
|
|
@ -31,49 +31,49 @@ sub set_counters {
|
|||
$self->{maps_counters_type} = [
|
||||
{ name => 'cpu', type => 0, cb_prefix_output => 'prefix_cpu_output' }
|
||||
];
|
||||
|
||||
|
||||
$self->{maps_counters}->{cpu} = [
|
||||
{ label => '1s', set => {
|
||||
key_values => [ { name => 'raisecomCPUUtilization1sec' } ],
|
||||
key_values => [ { name => 'oneSec' } ],
|
||||
output_template => '1 seconde : %.2f %%',
|
||||
perfdatas => [
|
||||
{ label => 'cpu_1s', value => 'raisecomCPUUtilization1sec_absolute', template => '%.2f',
|
||||
{ label => 'cpu_1s', value => 'oneSec_absolute', template => '%.2f',
|
||||
min => 0, max => 100, unit => '%' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => '5s', set => {
|
||||
key_values => [ { name => 'raisecomCPUUtilization5sec' } ],
|
||||
key_values => [ { name => 'fiveSec' } ],
|
||||
output_template => '5 secondes : %.2f %%',
|
||||
perfdatas => [
|
||||
{ label => 'cpu_5s', value => 'raisecomCPUUtilization5sec_absolute', template => '%.2f',
|
||||
{ label => 'cpu_5s', value => 'fiveSec_absolute', template => '%.2f',
|
||||
min => 0, max => 100, unit => '%' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => '1m', set => {
|
||||
key_values => [ { name => 'raisecomCPUUtilization1min' } ],
|
||||
key_values => [ { name => 'oneMin' } ],
|
||||
output_template => '1 minute : %.2f %%',
|
||||
perfdatas => [
|
||||
{ label => 'cpu_1m', value => 'raisecomCPUUtilization1min_absolute', template => '%.2f',
|
||||
{ label => 'cpu_1m', value => 'oneMin_absolute', template => '%.2f',
|
||||
min => 0, max => 100, unit => '%' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => '10m', set => {
|
||||
key_values => [ { name => 'raisecomCPUUtilization10min' } ],
|
||||
key_values => [ { name => 'tenMin' } ],
|
||||
output_template => '10 minutes : %.2f %%',
|
||||
perfdatas => [
|
||||
{ label => 'cpu_10m', value => 'raisecomCPUUtilization10min_absolute', template => '%.2f',
|
||||
{ label => 'cpu_10m', value => 'tenMin_absolute', template => '%.2f',
|
||||
min => 0, max => 100, unit => '%' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => '2h', set => {
|
||||
key_values => [ { name => 'raisecomCPUUtilization2h' } ],
|
||||
key_values => [ { name => 'twoHour' } ],
|
||||
output_template => '2 hours : %.2f %%',
|
||||
perfdatas => [
|
||||
{ label => 'cpu_2h', value => 'raisecomCPUUtilization2h_absolute', template => '%.2f',
|
||||
{ label => 'cpu_2h', value => 'twoHour_absolute', template => '%.2f',
|
||||
min => 0, max => 100, unit => '%' },
|
||||
],
|
||||
}
|
||||
|
@ -100,27 +100,28 @@ sub new {
|
|||
return $self;
|
||||
}
|
||||
|
||||
my %mapping_period = (1 => 'oneSec', 2 => 'fiveSec', 3 => 'oneMin', 4 => 'tenMin', 5 => 'twoHour');
|
||||
|
||||
my $mapping = {
|
||||
raisecomCPUUtilizationPeriod => { oid => '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.2', map => \%mapping_period },
|
||||
raisecomCPUUtilization => { oid => '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3' },
|
||||
};
|
||||
|
||||
my $oid_raisecomCPUUtilizationEntry = '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1';
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
# RAISECOM-SYSTEM-MIB
|
||||
my $oid_raisecomCPUUtilization1sec = '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3.1';
|
||||
my $oid_raisecomCPUUtilization5sec = '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3.2';
|
||||
my $oid_raisecomCPUUtilization1min = '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3.3';
|
||||
my $oid_raisecomCPUUtilization10min = '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3.4';
|
||||
my $oid_raisecomCPUUtilization2h = '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3.5';
|
||||
|
||||
my $results = $options{snmp}->get_leef(oids => [$oid_raisecomCPUUtilization1sec, $oid_raisecomCPUUtilization5sec,
|
||||
$oid_raisecomCPUUtilization1min, , $oid_raisecomCPUUtilization10min,
|
||||
$oid_raisecomCPUUtilization2h ],
|
||||
nothing_quit => 1);
|
||||
|
||||
$self->{cpu} = { raisecomCPUUtilization1sec => $results->{$oid_raisecomCPUUtilization1sec},
|
||||
raisecomCPUUtilization5sec => $results->{$oid_raisecomCPUUtilization5sec},
|
||||
raisecomCPUUtilization1min => $results->{$oid_raisecomCPUUtilization1min},
|
||||
raisecomCPUUtilization10min => $results->{$oid_raisecomCPUUtilization10min},
|
||||
raisecomCPUUtilization2h => $results->{$oid_raisecomCPUUtilization2h},
|
||||
};
|
||||
$self->{cpu} = {};
|
||||
my $snmp_result = $options{snmp}->get_table(oid => $oid_raisecomCPUUtilizationEntry,
|
||||
nothing_quit => 1);
|
||||
foreach my $oid (keys %{$snmp_result}) {
|
||||
next if ($oid !~ /^$mapping->{raisecomCPUUtilization}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
|
||||
$self->{cpu}->{$result->{raisecomCPUUtilizationPeriod}} = $result->{raisecomCPUUtilization};
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -141,12 +142,12 @@ Example: --filter-counters='^(1s|1m)$'
|
|||
=item B<--warning-*>
|
||||
|
||||
Threshold warning.
|
||||
Can be: '1s', '5s', '1m', '10m', '2h'
|
||||
Can be: '1s', '5s', '1m', '10m', '2h'.
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Threshold critical.
|
||||
Can be: '1s', '5s', '1m', '10m', '2h'
|
||||
Can be: '1s', '5s', '1m', '10m', '2h'.
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ sub set_system {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_overload_check_section_option} = '^(temperature|fan|voltage)$';
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan|voltage)$';
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan.speed|voltage)$';
|
||||
|
||||
$self->{cb_hook2} = 'snmp_execute';
|
||||
|
||||
|
@ -70,18 +70,18 @@ __END__
|
|||
|
||||
=head1 MODE
|
||||
|
||||
Check hardware (temperatures, fans, voltages).
|
||||
Check hardware.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--component>
|
||||
|
||||
Which component to check (Default: '.*').
|
||||
Can be: 'temperature'.
|
||||
Can be: 'temperature', 'fan', 'voltage'.
|
||||
|
||||
=item B<--filter>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu)
|
||||
Exclude some parts (comma seperated list) (Example: --filter=fan
|
||||
Can also exclude specific instance: --filter=fan,1
|
||||
|
||||
=item B<--no-component>
|
||||
|
@ -93,7 +93,7 @@ If total (with skipped) is 0. (Default: 'critical' returns).
|
|||
|
||||
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
|
||||
It used before default thresholds (order stays).
|
||||
Example: --threshold-overload='fan,CRITICAL,^(?!(good)$)'
|
||||
Example: --threshold-overload='fan,WARNING,twoHour'
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
|
|
|
@ -44,12 +44,12 @@ sub check_options {
|
|||
$self->SUPER::init(%options);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,12 +31,12 @@ sub new {
|
|||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
'cpu' => 'network::raisecom::snmp::mode::cpu',
|
||||
'memory' => 'network::raisecom::snmp::mode::memory',
|
||||
'interfaces' => 'snmp_standard::mode::interfaces',
|
||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||
'hardware' => 'network::raisecom::snmp::mode::hardware',
|
||||
);
|
||||
'cpu' => 'network::raisecom::snmp::mode::cpu',
|
||||
'hardware' => 'network::raisecom::snmp::mode::hardware',
|
||||
'interfaces' => 'snmp_standard::mode::interfaces',
|
||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||
'memory' => 'network::raisecom::snmp::mode::memory',
|
||||
);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue