Merge pull request #2390 from centreon/fix-synology
fix synology upgrade
This commit is contained in:
commit
63b41a114c
|
@ -24,23 +24,23 @@ use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{maps_counters_type} = [
|
$self->{maps_counters_type} = [
|
||||||
{ name => 'global', type => 1, cb_prefix_output => 'prefix_output' }
|
{ name => 'global', type => 0 }
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{global} = [
|
$self->{maps_counters}->{global} = [
|
||||||
{ label => 'status', set => {
|
{ label => 'status', type => 2, warning_default => '%{upgrade} ne "unavailable"', set => {
|
||||||
key_values => [
|
key_values => [
|
||||||
{ name => 'model' }, { name => 'version' }, { name => 'upgrade' }
|
{ name => 'model' }, { name => 'version' }, { name => 'upgrade' }
|
||||||
],
|
],
|
||||||
closure_custom_output => $self->can('custom_status_output'),
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
closure_custom_perfdata => sub { return 0; },
|
closure_custom_perfdata => sub { return 0; },
|
||||||
closure_custom_threshold_check => \&catalog_status_threshold
|
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -49,13 +49,12 @@ sub set_counters {
|
||||||
sub custom_status_output {
|
sub custom_status_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
return 'version is \'' . $self->{result_values}->{version} . '\', upgrade is \'' . $self->{result_values}->{upgrade} . '\''
|
return sprintf(
|
||||||
}
|
"'%s': version is '%s', upgrade is '%s'",
|
||||||
|
$options{instance_value}->{model},
|
||||||
sub prefix_output {
|
$self->{result_values}->{version},
|
||||||
my ($self, %options) = @_;
|
$self->{result_values}->{upgrade}
|
||||||
|
);
|
||||||
return '\'' . $options{instance_value}->{model} . '\' : ';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
|
@ -64,46 +63,31 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'warning-status:s' => { name => 'warning_status', default => '%{upgrade} ne "unavailable"' },
|
|
||||||
'critical-status:s' => { name => 'critical_status', default => '' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
my $map_states = {
|
||||||
my ($self, %options) = @_;
|
1 => 'available', 2 => 'unavailable',
|
||||||
$self->SUPER::check_options(%options);
|
3 => 'connecting', 4 => 'disconnected',
|
||||||
|
|
||||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
|
||||||
}
|
|
||||||
|
|
||||||
my %states = (
|
|
||||||
1 => 'available',
|
|
||||||
2 => 'unavailable',
|
|
||||||
3 => 'connecting',
|
|
||||||
4 => 'disconnected',
|
|
||||||
5 => 'others'
|
5 => 'others'
|
||||||
);
|
};
|
||||||
|
|
||||||
my $mapping = {
|
my $mapping = {
|
||||||
modelName => { oid => '.1.3.6.1.4.1.6574.1.5.1' },
|
model => { oid => '.1.3.6.1.4.1.6574.1.5.1' }, # modelName
|
||||||
version => { oid => '.1.3.6.1.4.1.6574.1.5.3' },
|
version => { oid => '.1.3.6.1.4.1.6574.1.5.3' }, # version
|
||||||
upgradeAvailable => { oid => '.1.3.6.1.4.1.6574.1.5.4' }
|
upgrade => { oid => '.1.3.6.1.4.1.6574.1.5.4', map => $map_states } # upgradeAvailable
|
||||||
};
|
};
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $results = $options{snmp}->get_leef(
|
my $snmp_result = $options{snmp}->get_leef(
|
||||||
oids => [ map($_->{oid} . '.0', values(%$mapping)) ],
|
oids => [ map($_->{oid} . '.0', values(%$mapping)) ],
|
||||||
nothing_quit => 1
|
nothing_quit => 1
|
||||||
);
|
);
|
||||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => 0);
|
$self->{global} = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => 0);
|
||||||
|
|
||||||
$self->{global}->{0}->{model} = $result->{modelName};
|
|
||||||
$self->{global}->{0}->{version} = $result->{version};
|
|
||||||
$self->{global}->{0}->{upgrade} = $states{$result->{upgradeAvailable}};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue