@@ -174,19 +174,26 @@ sub calc_disk_health {
174
174
# #############################################
175
175
176
176
sub get_spare_info {
177
- my ($nahStorage , $strVHost , $strWarning , $strCritical ) = @_ ;
177
+ my ($nahStorage , $strVHost , $strWarning , $strCritical , $strSuboption ) = @_ ;
178
178
my $nahSpareIterator = NaElement-> new(" storage-disk-get-iter" );
179
179
my $nahQuery = NaElement-> new(" query" );
180
180
my $nahSpareInfo = NaElement-> new(" storage-disk-info" );
181
181
my $nahSpareOwnerInfo = NaElement-> new(" disk-ownership-info" );
182
182
my $strActiveTag = " " ;
183
183
my %hshSpareInfo ;
184
+ my $aggregateNode = undef ;
185
+
186
+ if (defined ($strSuboption )) {
187
+ my @arySuboption = split (" ," ,$strSuboption );
188
+ if (" aggregate" ~~ @arySuboption ) { $aggregateNode = ' _ALL_' ; }
189
+ }
184
190
185
191
if (defined ($strVHost )) {
186
192
$nahSpareIterator -> child_add($nahQuery );
187
193
$nahQuery -> child_add($nahSpareInfo );
188
194
$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 ; }
190
197
}
191
198
192
199
while (defined ($strActiveTag )) {
@@ -218,8 +225,15 @@ sub get_spare_info {
218
225
my $spareInfo = $raidInfo -> child_get(" disk-spare-info" );
219
226
my $zeroed = $spareInfo -> child_get_string(' is-zeroed' );
220
227
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 ;
223
237
} else {
224
238
next SPARE;
225
239
}
@@ -242,7 +256,7 @@ sub calc_spare_health {
242
256
next NODE;
243
257
}
244
258
245
- my ($spareCount , $unassignedCount , $unknownCount , $notZeroedCount ) = (0, 0, 0, 0);
259
+ my ($spareCount , $unassigneSpareCount , $sharedSpareCount , $ unassignedCount , $unknownCount , $notZeroedCount ) = (0, 0, 0, 0, 0, 0);
246
260
my $strNewMessage ;
247
261
248
262
foreach my $strSpare (keys %{$hrefSpareInfo -> {$node }}) {
@@ -253,14 +267,17 @@ sub calc_spare_health {
253
267
$notZeroedCount ++;
254
268
}
255
269
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" ) {
259
273
$unassignedCount ++;
274
+ } elsif (defined ($status ) && $status eq " shared" ) {
275
+ $sharedSpareCount ++;
260
276
} else {
261
277
$unknownCount ++;
262
278
}
263
279
}
280
+ $spareCount = $unassigneSpareCount + $sharedSpareCount ;
264
281
265
282
if ($spareCount < $strCritical ) {
266
283
$critStatus ++;
@@ -272,7 +289,7 @@ sub calc_spare_health {
272
289
$unknownStatus ++;
273
290
}
274
291
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 );
276
293
$strOutput = get_nagios_description($strOutput , $strNewMessage );
277
294
}
278
295
@@ -1968,6 +1985,8 @@ sub help {
1968
1985
desc: Check the number of spare disks
1969
1986
thresh: Warning / critical required spare disks. Default thresholds are 2 / 1.
1970
1987
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)
1971
1990
1972
1991
* 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.
1973
1992
@@ -2362,7 +2381,7 @@ sub filter_object {
2362
2381
$strWarning //= 2;
2363
2382
$strCritical //= 1;
2364
2383
2365
- my $hrefSpareInfo = get_spare_info($nahStorage , $strVHost , $strWarning , $strCritical );
2384
+ my $hrefSpareInfo = get_spare_info($nahStorage , $strVHost , $strWarning , $strCritical , $strSuboption );
2366
2385
2367
2386
if (defined ($strModifier )) {
2368
2387
$hrefSpareInfo = filter_object($hrefSpareInfo , $strModifier );
0 commit comments