fix replication bug

This commit is contained in:
garnier-quentin 2020-05-28 10:59:29 +02:00
parent f7594031df
commit 17694de50b
3 changed files with 28 additions and 21 deletions

View File

@ -42,10 +42,10 @@ sub set_counters {
perfdatas => [ perfdatas => [
{ value => 'used', label => 'used', cast_int => 1, { value => 'used', label => 'used', cast_int => 1,
unit => 'B', min => 0, max => 'total', threshold_total => 'total', unit => 'B', min => 0, max => 'total', threshold_total => 'total',
label_extra_instance => 1, instance_use => 'display' }, label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, }
]; ];
} }
@ -91,9 +91,9 @@ sub new {
'name' => { name => 'use_name' }, 'name' => { name => 'use_name' },
'filesystem:s' => { name => 'filesystem' }, 'filesystem:s' => { name => 'filesystem' },
'regexp' => { name => 'use_regexp' }, 'regexp' => { name => 'use_regexp' },
'regexp-isensitive' => { name => 'use_regexpi' }, 'regexp-isensitive' => { name => 'use_regexpi' }
}); });
return $self; return $self;
} }

View File

@ -90,9 +90,8 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ });
});
return $self; return $self;
} }
@ -103,8 +102,10 @@ sub get_version {
my $oid_sysDescr = '.1.3.6.1.2.1.1.1.0'; # 'Data Domain OS 5.4.1.1-411752' my $oid_sysDescr = '.1.3.6.1.2.1.1.1.0'; # 'Data Domain OS 5.4.1.1-411752'
my $result = $options{snmp}->get_leef(oids => [ $oid_sysDescr ]); my $result = $options{snmp}->get_leef(oids => [ $oid_sysDescr ]);
if (!($self->{os_version} = storage::emc::DataDomain::lib::functions::get_version(value => $result->{$oid_sysDescr}))) { if (!($self->{os_version} = storage::emc::DataDomain::lib::functions::get_version(value => $result->{$oid_sysDescr}))) {
$self->{output}->output_add(severity => 'UNKNOWN', $self->{output}->output_add(
short_msg => 'Cannot get DataDomain OS version.'); severity => 'UNKNOWN',
short_msg => 'Cannot get DataDomain OS version.'
);
$self->{output}->display(); $self->{output}->display();
$self->{output}->exit(); $self->{output}->exit();
} }

View File

@ -38,7 +38,7 @@ sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'repl', type => 1, cb_prefix_output => 'prefix_repl_output', message_multiple => 'All replications are ok' }, { name => 'repl', type => 1, cb_prefix_output => 'prefix_repl_output', message_multiple => 'All replications are ok' }
]; ];
$self->{maps_counters}->{repl} = [ $self->{maps_counters}->{repl} = [
@ -48,18 +48,18 @@ sub set_counters {
output_use => 'state', output_use => 'state',
closure_custom_calc => $self->can('custom_status_calc'), closure_custom_calc => $self->can('custom_status_calc'),
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
} }
}, },
{ label => 'offset', set => { { label => 'offset', set => {
key_values => [ { name => 'offset' }, { name => 'display' } ], key_values => [ { name => 'offset' }, { name => 'display' } ],
output_template => 'last time peer sync : %s seconds ago', output_template => 'last time peer sync : %s seconds ago',
perfdatas => [ perfdatas => [
{ label => 'offset', value => 'offset', template => '%s', { label => 'offset', template => '%s',
label_extra_instance => 1, instance_use => 'display' }, label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, }
]; ];
} }
@ -77,7 +77,7 @@ sub new {
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
'unknown-status:s' => { name => 'unknown_status', default => '' }, 'unknown-status:s' => { name => 'unknown_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '%{state} =~ /initializing|recovering/i' }, 'warning-status:s' => { name => 'warning_status', default => '%{state} =~ /initializing|recovering/i' },
'critical-status:s' => { name => 'critical_status', default => '%{state} =~ /disabledNeedsResync|uninitialized/i' }, 'critical-status:s' => { name => 'critical_status', default => '%{state} =~ /disabledNeedsResync|uninitialized/i' }
}); });
return $self; return $self;
@ -99,11 +99,12 @@ sub manage_selection {
my $snmp_result = $options{snmp}->get_multiple_table( my $snmp_result = $options{snmp}->get_multiple_table(
oids => [ oids => [
{ oid => $oid_sysDescr }, { oid => $oid_sysDescr },
{ oid => $oid_replicationInfoEntry }, { oid => $oid_replicationInfoEntry }
], ],
nothing_quit => 1 nothing_quit => 1
); );
if (!($self->{os_version} = storage::emc::DataDomain::lib::functions::get_version(value => $self->{results}->{$oid_sysDescr}->{$oid_sysDescr . '.0'}))) {
if (!($self->{os_version} = storage::emc::DataDomain::lib::functions::get_version(value => $snmp_result->{$oid_sysDescr}->{$oid_sysDescr . '.0'}))) {
$self->{output}->output_add( $self->{output}->output_add(
severity => 'UNKNOWN', severity => 'UNKNOWN',
short_msg => 'Cannot get DataDomain OS version.' short_msg => 'Cannot get DataDomain OS version.'
@ -111,7 +112,12 @@ sub manage_selection {
$self->{output}->display(); $self->{output}->display();
$self->{output}->exit(); $self->{output}->exit();
} }
if (scalar(keys %{$snmp_result->{$oid_replicationInfoEntry}}) <= 0) {
$self->{output}->add_option_msg(short_msg => 'no replication informations');
$self->{output}->option_exit();
}
my ($oid_replSource, $oid_replDestination, $oid_replState); my ($oid_replSource, $oid_replDestination, $oid_replState);
my %map_state = ( my %map_state = (
1 => 'enabled', 2 => 'disabled', 3 => 'disabledNeedsResync', 1 => 'enabled', 2 => 'disabled', 3 => 'disabledNeedsResync',
@ -137,7 +143,7 @@ sub manage_selection {
replState => { oid => $oid_replState, map => \%map_state }, replState => { oid => $oid_replState, map => \%map_state },
replSource => { oid => $oid_replSource }, replSource => { oid => $oid_replSource },
replDestination => { oid => $oid_replDestination }, replDestination => { oid => $oid_replDestination },
replSyncedAsOfTime => { oid => '.1.3.6.1.4.1.19746.1.8.1.1.1.14' }, replSyncedAsOfTime => { oid => '.1.3.6.1.4.1.19746.1.8.1.1.1.14' }
}; };
$self->{repl} = {}; $self->{repl} = {};