fix datadomain unitialized value
This commit is contained in:
parent
df7ab970d2
commit
61b5858838
|
@ -28,11 +28,11 @@ use storage::emc::DataDomain::lib::functions;
|
|||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'fs', type => 1, cb_prefix_output => 'prefix_fs_output', message_multiple => 'All filesystems are ok.' },
|
||||
];
|
||||
|
||||
|
||||
$self->{maps_counters}->{fs} = [
|
||||
{ label => 'usage', set => {
|
||||
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'display' } ],
|
||||
|
@ -51,13 +51,13 @@ sub set_counters {
|
|||
|
||||
sub prefix_fs_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
return "Filesystem '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub custom_used_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
|
||||
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_free'} + $options{new_datas}->{$self->{instance} . '_used'};
|
||||
$self->{result_values}->{free} = $options{new_datas}->{$self->{instance} . '_free'};
|
||||
|
@ -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;
|
||||
|
@ -101,7 +103,7 @@ my ($oid_fileSystemResourceName, $oid_fileSystemSpaceUsed, $oid_fileSystemSpaceA
|
|||
|
||||
sub add_result {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->{fs}->{$options{instance}} = {};
|
||||
$self->{fs}->{$options{instance}}->{display} = $self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemResourceName . '.' . $options{instance}};
|
||||
$self->{fs}->{$options{instance}}->{free} = int($self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemSpaceAvail . '.' . $options{instance}} * 1024 * 1024 * 1024);
|
||||
|
@ -110,7 +112,7 @@ sub add_result {
|
|||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->{results} = $options{snmp}->get_multiple_table(
|
||||
oids => [
|
||||
{ oid => $oid_sysDescr },
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -133,7 +137,7 @@ sub manage_selection {
|
|||
$oid_fileSystemSpaceUsed = '.1.3.6.1.4.1.19746.1.3.2.1.1.4';
|
||||
$oid_fileSystemSpaceAvail = '.1.3.6.1.4.1.19746.1.3.2.1.1.5';
|
||||
}
|
||||
|
||||
|
||||
if (!defined($self->{option_results}->{use_name}) && defined($self->{option_results}->{filesystem})) {
|
||||
if (!defined($self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemResourceName . '.' . $self->{option_results}->{filesystem}})) {
|
||||
$self->{output}->add_option_msg(short_msg => "No filesystem found for id '" . $self->{option_results}->{filesystem} . "'.");
|
||||
|
@ -160,7 +164,7 @@ sub manage_selection {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (scalar(keys %{$self->{fs}}) <= 0 && !defined($options{disco})) {
|
||||
if (defined($self->{option_results}->{device})) {
|
||||
$self->{output}->add_option_msg(short_msg => "No filesystem found '" . $self->{option_results}->{filesystem} . "'.");
|
||||
|
|
|
@ -29,18 +29,18 @@ use storage::emc::DataDomain::lib::functions;
|
|||
|
||||
sub custom_status_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'};
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'repl', type => 1, cb_prefix_output => 'prefix_repl_output', message_multiple => 'All replications are ok' },
|
||||
];
|
||||
|
||||
|
||||
$self->{maps_counters}->{repl} = [
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
key_values => [ { name => 'state' } ],
|
||||
|
@ -65,22 +65,19 @@ 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 {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
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();
|
||||
}
|
||||
|
@ -131,23 +132,24 @@ sub manage_selection {
|
|||
$oid_replDestination = '.1.3.6.1.4.1.19746.1.8.1.1.1.7';
|
||||
$oid_replState = '.1.3.6.1.4.1.19746.1.8.1.1.1.2';
|
||||
}
|
||||
|
||||
|
||||
my $mapping = {
|
||||
replState => { oid => $oid_replState, map => \%map_state },
|
||||
replSource => { oid => $oid_replSource },
|
||||
replDestination => { oid => $oid_replDestination },
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue