Can anyone explain following piece of code in https://github.com/simondeziel/custom-nagios-plugins/blob/master/plugins/check_megaraid_sas . (line num 220-223) Why this code is there
} elsif ( $slotnumber != 255 ) {
$pdbad++;
$status = 'CRITICAL';
}
It makes sense to look at the complete section:
That section loops over a list of PDs (Primary Disks?), and I assume that this file / program output contains a human readable status for every attached device. The code looks at every line and performs some actions depending on the content of that line:
$slotnumberis assigned whenever there isSlot Number : ...in the contents ofPDLIST. From looking at the logic, if there is aFirmware stateline that is notHotspare,OnlineorUnconfigured, and the$slotnumberis not 255, then something went horribly wrong and the status is consideredCRITICAL. The number of bad PDs ($pdbad) is then increased by one.