fix datadomain unitialized value

This commit is contained in:
garnier-quentin 2020-02-12 17:10:47 +01:00
parent df7ab970d2
commit 61b5858838
2 changed files with 54 additions and 53 deletions

View File

@ -74,10 +74,12 @@ sub custom_used_output {
my ($used_value, $used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
return sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$total_value . " " . $total_unit,
$used_value . " " . $used_unit, $self->{result_values}->{used_prct},
$free_value . " " . $free_unit, $self->{result_values}->{free_prct});
return sprintf(
"Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$total_value . " " . $total_unit,
$used_value . " " . $used_unit, $self->{result_values}->{used_prct},
$free_value . " " . $free_unit, $self->{result_values}->{free_prct}
);
}
sub new {
@ -86,10 +88,10 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
'name' => { name => 'use_name' },
'filesystem:s' => { name => 'filesystem' },
'regexp' => { name => 'use_regexp' },
'regexp-isensitive' => { name => 'use_regexpi' },
'name' => { name => 'use_name' },
'filesystem:s' => { name => 'filesystem' },
'regexp' => { name => 'use_regexp' },
'regexp-isensitive' => { name => 'use_regexpi' },
});
return $self;
@ -119,8 +121,10 @@ sub manage_selection {
nothing_quit => 1
);
if (!($self->{os_version} = storage::emc::DataDomain::lib::functions::get_version(value => $self->{results}->{$oid_sysDescr}->{$oid_sysDescr . '.0'}))) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => 'Cannot get DataDomain OS version.');
$self->{output}->output_add(
severity => 'UNKNOWN',
short_msg => 'Cannot get DataDomain OS version.'
);
$self->{output}->display();
$self->{output}->exit();
}

View File

@ -66,10 +66,7 @@ sub set_counters {
sub prefix_repl_output {
my ($self, %options) = @_;
if ($self->{multiple} == 1) {
return "Replication '" . $options{instance_value}->{display} . "' ";
}
return "Replication ";
return "Replication '" . $options{instance_value}->{display} . "' ";
}
sub new {
@ -78,9 +75,9 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
"unknown-status:s" => { name => 'unknown_status', default => '' },
"warning-status:s" => { name => 'warning_status', default => '%{state} =~ /initializing|recovering/i' },
"critical-status:s" => { name => 'critical_status', default => '%{state} =~ /disabledNeedsResync|uninitialized/i' },
'unknown-status:s' => { name => 'unknown_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '%{state} =~ /initializing|recovering/i' },
'critical-status:s' => { name => 'critical_status', default => '%{state} =~ /disabledNeedsResync|uninitialized/i' },
});
return $self;
@ -99,14 +96,18 @@ my $oid_replicationInfoEntry = '.1.3.6.1.4.1.19746.1.8.1.1.1';
sub manage_selection {
my ($self, %options) = @_;
$self->{global} = {};
$self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_sysDescr },
{ oid => $oid_replicationInfoEntry },
],
nothing_quit => 1);
my $snmp_result = $options{snmp}->get_multiple_table(
oids => [
{ oid => $oid_sysDescr },
{ oid => $oid_replicationInfoEntry },
],
nothing_quit => 1
);
if (!($self->{os_version} = storage::emc::DataDomain::lib::functions::get_version(value => $self->{results}->{$oid_sysDescr}->{$oid_sysDescr . '.0'}))) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => 'Cannot get DataDomain OS version.');
$self->{output}->output_add(
severity => 'UNKNOWN',
short_msg => 'Cannot get DataDomain OS version.'
);
$self->{output}->display();
$self->{output}->exit();
}
@ -139,15 +140,16 @@ sub manage_selection {
replSyncedAsOfTime => { oid => '.1.3.6.1.4.1.19746.1.8.1.1.1.14' },
};
foreach my $oid (keys %{$self->{results}->{$oid_replicationInfoEntry}}) {
$self->{repl} = {};
foreach my $oid (keys %{$snmp_result->{$oid_replicationInfoEntry}}) {
next if ($oid !~ /^$mapping->{replState}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_replicationInfoEntry}, instance => $instance);
$self->{repl}->{$instance} = { display => $result->{replSource} . '/' . $result->{replDestination},
state => $result->{replState},
offset => (time() - $result->{replSyncedAsOfTime})
};
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_replicationInfoEntry}, instance => $instance);
$self->{repl}->{$instance} = {
display => $result->{replSource} . '/' . $result->{replDestination},
state => $result->{replState},
offset => (time() - $result->{replSyncedAsOfTime})
};
}
}
@ -181,14 +183,9 @@ Can used special variables like: %{state}
Set critical threshold for status (Default: '%{state} =~ /disabledNeedsResync|uninitialized/i').
Can used special variables like: %{state}
=item B<--warning-*>
=item B<--warning-*> B<--critical-*>
Threshold warning.
Can be: 'offset'.
=item B<--critical-*>
Threshold critical.
Thresholds.
Can be: 'offset'.
=back