#!/usr/bin/php 0) { // Check if drivenum is valid if($drivenum > $slots) DisplayMessage(0, "Invavlid drive specified. Drive Number ($drivenum) cannot be higher than $slots."); // Check if drive specified is installed $driveoid = OID_HDDMODELS.".$drivenum"; $model = GetSnmpObjValue($host, $community, $driveoid); if($model === "--") DisplayMessage(0, "Invalid drive specified. The HDD slot $drivenum is not populated."); // Drive is installed, retrieve the temperature value. $driveoid = OID_HDDTEMPS.".$drivenum"; $ret = GetSnmpObjValue($host, $community, $driveoid); return $ret; } else { // No drive specified, check all drives and return maximum value. $ret = "-- C/-- F"; $maxtemp = 0; for($i = 1; $i <= $slots; $i++) { $driveoid = OID_HDDTEMPS.".$i"; $val = GetSnmpObjValue($host, $community, $driveoid); if($val !== "-- C/-- F" ) { $temp = GetSnmpObjValueTemperature($val); if($temp > $maxtemp) { $maxtemp = $temp; $ret = $val; } } } return $ret; } } // CheckHDD // Check if value is Ok, Warn, or Crit, return value to Nagios and shut down. function RetStatus($value, $check, $warning, $critical) { $tempValue = GetSnmpObjValueTemperature($value); if($tempValue >= $critical) DisplayMessage(2, "Critical - $check Temp - $value | Temperature=$tempValue".SCALE.";$warning;$critical;0;140"); elseif($tempValue >= $warning) DisplayMessage(1, "Warning - $check Temp - $value | Temperature=$tempValue".SCALE.";$warning;$critical;0;140"); else { DisplayMessage(0, "OK - $check Temp - $value | Temperature=$tempValue".SCALE.";$warning;$critical;0;140"); } } // RetStatus ?>