Skip to content

Commit cd21084

Browse files
author
Elias Ohm
committed
spare disks in shared mode, optional aggregte spare-count spares cluster- or node wide, fix filter to query only disks from home-node
* add handling of spare disks in "shared" mode (partitioned or formated disks) these are logically not assigned to a specific nodes spare disk capacity so are shown at a _SHARED_ node and not shown in single-node mode * add a suboption "aggregate" that allows to sum up/aggregate all disks in the cluster (if run against a specific "node" the "shared" mode disks are accounted for the node) * fix query-building to find only disks for the specific home-node (the error was not visible before because it was post-filtered in result function) * fix broken branching conditions within these function (see also district09#86)
1 parent d023c0f commit cd21084

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

Diff for: check_netapp_ontap.pl

+29-10
Original file line numberDiff line numberDiff line change
@@ -174,19 +174,26 @@ sub calc_disk_health {
174174
##############################################
175175

176176
sub get_spare_info {
177-
my ($nahStorage, $strVHost, $strWarning, $strCritical) = @_;
177+
my ($nahStorage, $strVHost, $strWarning, $strCritical, $strSuboption) = @_;
178178
my $nahSpareIterator = NaElement->new("storage-disk-get-iter");
179179
my $nahQuery = NaElement->new("query");
180180
my $nahSpareInfo = NaElement->new("storage-disk-info");
181181
my $nahSpareOwnerInfo = NaElement->new("disk-ownership-info");
182182
my $strActiveTag = "";
183183
my %hshSpareInfo;
184+
my $aggregateNode = undef;
185+
186+
if (defined($strSuboption)) {
187+
my @arySuboption = split(",",$strSuboption);
188+
if ("aggregate" ~~ @arySuboption) { $aggregateNode = '_ALL_'; }
189+
}
184190

185191
if (defined($strVHost)) {
186192
$nahSpareIterator->child_add($nahQuery);
187193
$nahQuery->child_add($nahSpareInfo);
188194
$nahSpareInfo->child_add($nahSpareOwnerInfo);
189-
$nahSpareOwnerInfo->child_add_string("home-node", $strVHost);
195+
$nahSpareOwnerInfo->child_add_string("home-node-name", $strVHost);
196+
if (defined($aggregateNode)) { $aggregateNode = $strVHost; }
190197
}
191198

192199
while(defined($strActiveTag)) {
@@ -218,8 +225,15 @@ sub get_spare_info {
218225
my $spareInfo = $raidInfo->child_get("disk-spare-info");
219226
my $zeroed = $spareInfo->child_get_string('is-zeroed');
220227

221-
$hshSpareInfo{$nodeName}{$strSpareName}{'status'} = $containertype;
222-
$hshSpareInfo{$nodeName}{$strSpareName}{'zeroed'} = $zeroed;
228+
$hshSpareInfo{$aggregateNode||$nodeName}{$strSpareName}{'status'} = $containertype;
229+
$hshSpareInfo{$aggregateNode||$nodeName}{$strSpareName}{'zeroed'} = $zeroed;
230+
} elsif ($containertype eq "shared") {
231+
my $sharedInfo = $raidInfo->child_get("disk-shared-info");
232+
my $aggregateList = $sharedInfo->child_get("aggregate-list");
233+
next SPARE if (defined($aggregateList));
234+
235+
$hshSpareInfo{$aggregateNode||'_SHARED_'}{$strSpareName}{'status'} = $containertype;
236+
$hshSpareInfo{$aggregateNode||'_SHARED_'}{$strSpareName}{'zeroed'} = undef;
223237
} else {
224238
next SPARE;
225239
}
@@ -242,7 +256,7 @@ sub calc_spare_health {
242256
next NODE;
243257
}
244258

245-
my ($spareCount, $unassignedCount, $unknownCount, $notZeroedCount) = (0, 0, 0, 0);
259+
my ($spareCount, $unassigneSpareCount, $sharedSpareCount, $unassignedCount, $unknownCount, $notZeroedCount) = (0, 0, 0, 0, 0, 0);
246260
my $strNewMessage;
247261

248262
foreach my $strSpare (keys %{$hrefSpareInfo->{$node}}) {
@@ -253,14 +267,17 @@ sub calc_spare_health {
253267
$notZeroedCount++;
254268
}
255269
my $status = $hrefSpareInfo->{$node}->{$strSpare}->{'status'};
256-
if (defined($status && $status eq "spare")) {
257-
$spareCount++;
258-
} elsif (defined($status && $status eq "unassigned")) {
270+
if (defined($status) && $status eq "spare") {
271+
$unassigneSpareCount++;
272+
} elsif (defined($status) && $status eq "unassigned") {
259273
$unassignedCount++;
274+
} elsif (defined($status) && $status eq "shared") {
275+
$sharedSpareCount++;
260276
} else {
261277
$unknownCount++;
262278
}
263279
}
280+
$spareCount = $unassigneSpareCount + $sharedSpareCount;
264281

265282
if ($spareCount < $strCritical) {
266283
$critStatus++;
@@ -272,7 +289,7 @@ sub calc_spare_health {
272289
$unknownStatus++;
273290
}
274291

275-
$strNewMessage = sprintf("%s: %d spare disks (%s not zeroed) and %s unassigned", $node, $spareCount, $notZeroedCount, $unassignedCount);
292+
$strNewMessage = sprintf("%s: %d spare (%d shared, %s not zeroed) and %s unassigned", $node, $spareCount, $sharedSpareCount, $notZeroedCount, $unassignedCount);
276293
$strOutput = get_nagios_description($strOutput, $strNewMessage);
277294
}
278295

@@ -1968,6 +1985,8 @@ sub help {
19681985
desc: Check the number of spare disks
19691986
thresh: Warning / critical required spare disks. Default thresholds are 2 / 1.
19701987
node: The node option restricts this check by cluster-node name.
1988+
(The spare disks already assigned to shared pools do not belong to a specific nodes aggregate, thus are not shown then.)
1989+
suboption: aggregate (sums up all spare disks in a cluster or on a node, includes also the shared disks on their home-node)
19711990
19721991
* For keyword thresholds, if you want to ignore alerts for that particular keyword you set it at the same threshold that the alert defaults to.
19731992
@@ -2362,7 +2381,7 @@ sub filter_object {
23622381
$strWarning //= 2;
23632382
$strCritical //= 1;
23642383

2365-
my $hrefSpareInfo = get_spare_info($nahStorage, $strVHost, $strWarning, $strCritical);
2384+
my $hrefSpareInfo = get_spare_info($nahStorage, $strVHost, $strWarning, $strCritical, $strSuboption);
23662385

23672386
if (defined($strModifier)) {
23682387
$hrefSpareInfo = filter_object($hrefSpareInfo, $strModifier);

0 commit comments

Comments
 (0)