remove useless code
This commit is contained in:
parent
9c4654fbdb
commit
a426bccbf0
|
@ -23,23 +23,22 @@ package storage::synology::snmp::mode::components::disk;
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_disk_status = (
|
||||
my $map_disk_status = {
|
||||
1 => 'Normal',
|
||||
2 => 'Initialized',
|
||||
3 => 'NotInitialized',
|
||||
4 => 'SystemPartitionFailed',
|
||||
5 => 'Crashed',
|
||||
);
|
||||
5 => 'Crashed'
|
||||
};
|
||||
|
||||
my $mapping = {
|
||||
synoDiskdiskStatus => { oid => '.1.3.6.1.4.1.6574.2.1.1.5', map => \%map_disk_status },
|
||||
synoDiskdiskStatus => { oid => '.1.3.6.1.4.1.6574.2.1.1.5', map => $map_disk_status }
|
||||
};
|
||||
my $oid_synoDisk = '.1.3.6.1.4.1.6574.2.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_synoDisk };
|
||||
push @{$self->{request}}, { oid => $mapping->{synoDiskdiskStatus}->{oid} };
|
||||
}
|
||||
|
||||
sub check {
|
||||
|
@ -49,22 +48,28 @@ sub check {
|
|||
$self->{components}->{disk} = {name => 'disk', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'disk'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_synoDisk}})) {
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $mapping->{synoDiskdiskStatus}->{oid} }})) {
|
||||
next if ($oid !~ /^$mapping->{synoDiskdiskStatus}->{oid}\.(\d+)/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_synoDisk}, instance => $instance);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $mapping->{synoDiskdiskStatus}->{oid} }, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'disk', instance => $instance));
|
||||
$self->{components}->{disk}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("disk '%s' status is %s.",
|
||||
$instance, $result->{synoDiskdiskStatus}));
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"disk '%s' status is %s.",
|
||||
$instance, $result->{synoDiskdiskStatus}
|
||||
)
|
||||
);
|
||||
my $exit = $self->get_severity(section => 'disk', value => $result->{synoDiskdiskStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Disk '%s' status is %s", $instance, $result->{synoDiskdiskStatus}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Disk '%s' status is %s", $instance, $result->{synoDiskdiskStatus})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
1;
|
||||
|
|
|
@ -23,18 +23,20 @@ package storage::synology::snmp::mode::components::fan;
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_status = (1 => 'Normal', 2 => 'Failed');
|
||||
my $map_status = { 1 => 'Normal', 2 => 'Failed' };
|
||||
|
||||
my $mapping = {
|
||||
synoSystemsystemFanStatus => { oid => '.1.3.6.1.4.1.6574.1.4.1', map => \%map_status },
|
||||
synoSystemcpuFanStatus => { oid => '.1.3.6.1.4.1.6574.1.4.2', map => \%map_status },
|
||||
synoSystemsystemFanStatus => { oid => '.1.3.6.1.4.1.6574.1.4.1', map => $map_status },
|
||||
synoSystemcpuFanStatus => { oid => '.1.3.6.1.4.1.6574.1.4.2', map => map_status }
|
||||
};
|
||||
my $oid_fan = '.1.3.6.1.4.1.6574.1.4';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_fan };
|
||||
push @{$self->{request}}, {
|
||||
oid => $oid_fan
|
||||
};
|
||||
}
|
||||
|
||||
sub check {
|
||||
|
@ -48,25 +50,37 @@ sub check {
|
|||
if (!$self->check_filter(section => 'fan', instance => 'cpu')) {
|
||||
$self->{components}->{fan}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("cpu fan state is %s.",
|
||||
$result->{synoSystemcpuFanStatus}));
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"cpu fan state is %s.",
|
||||
$result->{synoSystemcpuFanStatus}
|
||||
)
|
||||
);
|
||||
my $exit = $self->get_severity(label => 'default', section => 'fan', instance => 'cpu', value => $result->{synoSystemcpuFanStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("CPU fan status is %s", $result->{synoSystemcpuFanStatus}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("CPU fan status is %s", $result->{synoSystemcpuFanStatus})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$self->check_filter(section => 'fan', instance => 'system')) {
|
||||
$self->{components}->{fan}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("system fan state is %s.",
|
||||
$result->{synoSystemsystemFanStatus}));
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"system fan state is %s.",
|
||||
$result->{synoSystemsystemFanStatus}
|
||||
)
|
||||
);
|
||||
my $exit = $self->get_severity(label => 'default', section => 'fan', instance => 'system', value => $result->{synoSystemsystemFanStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("System fan status is %s", $result->{synoSystemsystemFanStatus}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("System fan status is %s", $result->{synoSystemsystemFanStatus})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
1;
|
||||
|
|
|
@ -23,10 +23,10 @@ package storage::synology::snmp::mode::components::psu;
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_status = (1 => 'Normal', 2 => 'Failed');
|
||||
my $map_status = { 1 => 'Normal', 2 => 'Failed' };
|
||||
|
||||
my $mapping = {
|
||||
synoSystempowerStatus => { oid => '.1.3.6.1.4.1.6574.1.3', map => \%map_status },
|
||||
synoSystempowerStatus => { oid => '.1.3.6.1.4.1.6574.1.3', map => $map_status }
|
||||
};
|
||||
|
||||
sub load {
|
||||
|
@ -44,13 +44,19 @@ sub check {
|
|||
$self->{components}->{psu}->{total}++;
|
||||
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{synoSystempowerStatus}->{oid}}, instance => '0');
|
||||
$self->{output}->output_add(long_msg => sprintf("power supply status is %s.",
|
||||
$result->{synoSystempowerStatus}));
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"power supply status is %s.",
|
||||
$result->{synoSystempowerStatus}
|
||||
)
|
||||
);
|
||||
my $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{synoSystempowerStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Power Supply status is %s.", $result->{synoSystempowerStatus}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Power Supply status is %s.", $result->{synoSystempowerStatus})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
1;
|
||||
|
|
|
@ -23,7 +23,7 @@ package storage::synology::snmp::mode::components::raid;
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_raid_status = (
|
||||
my $map_raid_status = {
|
||||
1 => 'Normal',
|
||||
2 => 'Repairing',
|
||||
3 => 'Migrating',
|
||||
|
@ -44,19 +44,23 @@ my %map_raid_status = (
|
|||
18 => 'RaidExpandingUnfinishedSHR',
|
||||
19 => 'RaidConvertSHRToPool',
|
||||
20 => 'RaidMigrateSHR1ToSHR2',
|
||||
21 => 'RaidUnknownStatus',
|
||||
);
|
||||
21 => 'RaidUnknownStatus'
|
||||
};
|
||||
|
||||
my $mapping = {
|
||||
synoRaidraidName => { oid => '.1.3.6.1.4.1.6574.3.1.1.2' },
|
||||
synoRaidraidStatus => { oid => '.1.3.6.1.4.1.6574.3.1.1.3', map => \%map_raid_status },
|
||||
synoRaidraidStatus => { oid => '.1.3.6.1.4.1.6574.3.1.1.3', map => $map_raid_status }
|
||||
};
|
||||
my $oid_synoRaid = '.1.3.6.1.4.1.6574.3.1.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_synoRaid };
|
||||
push @{$self->{request}}, {
|
||||
oid => $oid_synoRaid,
|
||||
start => $mapping->{synoRaidraidName}->{oid},
|
||||
end => $mapping->{synoRaidraidStatus}->{oid}
|
||||
};
|
||||
}
|
||||
|
||||
sub check {
|
||||
|
@ -74,15 +78,24 @@ sub check {
|
|||
next if ($self->check_filter(section => 'raid', instance => $instance));
|
||||
$self->{components}->{raid}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("raid '%s' status is %s [instance: %s]",
|
||||
$result->{synoRaidraidName}, $result->{synoRaidraidStatus}, $instance));
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"raid '%s' status is %s [instance: %s]",
|
||||
$result->{synoRaidraidName}, $result->{synoRaidraidStatus}, $instance
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(section => 'raid', value => $result->{synoRaidraidStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Raid '%s' status is %s",
|
||||
$result->{synoRaidraidName}, $result->{synoRaidraidStatus}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Raid '%s' status is %s",
|
||||
$result->{synoRaidraidName}, $result->{synoRaidraidStatus}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
1;
|
||||
|
|
|
@ -23,10 +23,10 @@ package storage::synology::snmp::mode::components::system;
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_status = (1 => 'Normal', 2 => 'Failed');
|
||||
my $map_status = { 1 => 'Normal', 2 => 'Failed' };
|
||||
|
||||
my $mapping = {
|
||||
synoSystemsystemStatus => { oid => '.1.3.6.1.4.1.6574.1.1', map => \%map_status },
|
||||
synoSystemsystemStatus => { oid => '.1.3.6.1.4.1.6574.1.1', map => $map_status }
|
||||
};
|
||||
|
||||
sub load {
|
||||
|
@ -44,12 +44,18 @@ sub check {
|
|||
$self->{components}->{system}->{total}++;
|
||||
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{synoSystemsystemStatus}->{oid}}, instance => '0');
|
||||
$self->{output}->output_add(long_msg => sprintf("system partition status is %s.",
|
||||
$result->{synoSystemsystemStatus}));
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"system partition status is %s.",
|
||||
$result->{synoSystemsystemStatus}
|
||||
)
|
||||
);
|
||||
my $exit = $self->get_severity(label => 'default', section => 'system', value => $result->{synoSystemsystemStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("System status is %s.", $result->{synoSystemsystemStatus}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("System status is %s.", $result->{synoSystemsystemStatus})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ sub set_counters {
|
|||
key_values => [ { name => 'heartbeat_latency' } ],
|
||||
output_template => 'heartbeat latency: %s us',
|
||||
perfdatas => [
|
||||
{ value => 'heartbeat_latency', template => '%s', min => 0, unit => 'us' }
|
||||
{ template => '%s', min => 0, unit => 'us' }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'unknown-status:s' => { name => 'unknown_status', default => '' },
|
||||
'warning-status:s' => { name => 'warning_status', default => '%{cluster_status} =~ /warning/i || %{heartbeat_status} =~ /abnormal/i' },
|
||||
|
|
|
@ -28,7 +28,7 @@ use warnings;
|
|||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_overload_check_section_option} = '^(fan|psu|disk|system|raid)$';
|
||||
$self->{regexp_threshold_overload_check_section_option} = '^(?:fan|psu|disk|system|raid)$';
|
||||
|
||||
$self->{cb_hook2} = 'snmp_execute';
|
||||
|
||||
|
@ -36,14 +36,14 @@ sub set_system {
|
|||
# system, fan, psu
|
||||
default => [
|
||||
['Normal', 'OK'],
|
||||
['Failed', 'CRITICAL'],
|
||||
['Failed', 'CRITICAL']
|
||||
],
|
||||
disk => [
|
||||
['Normal', 'OK'],
|
||||
['Initialized', 'OK'],
|
||||
['NotInitialized', 'OK'],
|
||||
['SystemPartitionFailed', 'CRITICAL'],
|
||||
['Crashed', 'CRITICAL'],
|
||||
['Crashed', 'CRITICAL']
|
||||
],
|
||||
raid => [
|
||||
['Normal', 'OK'],
|
||||
|
@ -66,8 +66,8 @@ sub set_system {
|
|||
['RaidExpandingUnfinishedSHR', 'OK'],
|
||||
['RaidConvertSHRToPool', 'OK'],
|
||||
['RaidMigrateSHR1ToSHR2', 'OK'],
|
||||
['RaidUnknownStatus', 'UNKNOWN'],
|
||||
],
|
||||
['RaidUnknownStatus', 'UNKNOWN']
|
||||
]
|
||||
};
|
||||
|
||||
$self->{components_path} = 'storage::synology::snmp::mode::components';
|
||||
|
@ -85,11 +85,9 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_performance => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
});
|
||||
|
||||
|
||||
$options{options}->add_options(arguments => { });
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -126,4 +124,4 @@ Example: --threshold-overload='psu,CRITICAL,^(?!(on)$)'
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
=cut
|
||||
|
|
|
@ -29,7 +29,7 @@ sub set_counters {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0 },
|
||||
{ name => 'global', type => 0 }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
|
@ -37,10 +37,10 @@ sub set_counters {
|
|||
key_values => [ { name => 'temperature' } ],
|
||||
output_template => 'system temperature: %s C',
|
||||
perfdatas => [
|
||||
{ value => 'temperature', template => '%s', unit => 'C' },
|
||||
],
|
||||
{ template => '%s', unit => 'C' }
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ sub manage_selection {
|
|||
);
|
||||
|
||||
$self->{global} = {
|
||||
temperature => $snmp_result->{$oid_synoSystemtemperature},
|
||||
temperature => $snmp_result->{$oid_synoSystemtemperature}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ sub set_counters {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'global', type => 0, skipped_code => { -10 => 1 } }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
|
@ -37,26 +37,26 @@ sub set_counters {
|
|||
key_values => [ { name => 'ups_load' } ],
|
||||
output_template => 'ups load: %s%%',
|
||||
perfdatas => [
|
||||
{ value => 'ups_load', template => '%s', min => 0, max => 100, unit => '%' },
|
||||
],
|
||||
{ template => '%s', min => 0, max => 100, unit => '%' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'charge-remaining', nlabel => 'battery.charge.remaining.percent', set => {
|
||||
key_values => [ { name => 'charge_remain' } ],
|
||||
output_template => 'battery charge remaining: %s%%',
|
||||
perfdatas => [
|
||||
{ value => 'charge_remain', template => '%s', min => 0, max => 100, unit => '%' },
|
||||
],
|
||||
{ template => '%s', min => 0, max => 100, unit => '%' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'lifetime-remaining', nlabel => 'battery.lifetime.remaining.seconds', set => {
|
||||
key_values => [ { name => 'lifetime_remain' } ],
|
||||
output_template => 'battery estimated lifetime: %s seconds',
|
||||
perfdatas => [
|
||||
{ value => 'lifetime_remain', template => '%s', min => 0, unit => 's' },
|
||||
],
|
||||
{ template => '%s', min => 0, unit => 's' }
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.1';
|
||||
%{$self->{modes}} = (
|
||||
$self->{modes} = {
|
||||
'components' => 'storage::synology::snmp::mode::hardware',
|
||||
'cpu' => 'snmp_standard::mode::cpu',
|
||||
'ha' => 'storage::synology::snmp::mode::ha',
|
||||
|
@ -42,8 +42,8 @@ sub new {
|
|||
'temperature' => 'storage::synology::snmp::mode::temperature',
|
||||
'time' => 'snmp_standard::mode::ntp',
|
||||
'ups' => 'storage::synology::snmp::mode::ups',
|
||||
'uptime' => 'snmp_standard::mode::uptime',
|
||||
);
|
||||
'uptime' => 'snmp_standard::mode::uptime'
|
||||
};
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue