Se você tiver a placa SuperMicro IPMI, um cavalheiro aqui escreveu um plugin do Nagios para consultar a interface IPMI para essas métricas.
#!/usr/bin/php -q
<?
/*
* check_ipmi for checking Supermicro IPMI on remote machine
* Gary Stimson 28aug2006
*/
$sIpmiTool = '/usr/bin/ipmitool';
if ($argc!=4)
{
print "Usage: ".$argv[0]." user password host\n";
exit(3);
}
$sUser = $argv[1];
$sPass = $argv[2];
$sHost = $argv[3];
$rExec = 0;
$aChassisLines= array();
$sCmd = "$sIpmiTool -U $sUser -P $sPass -H $sHost chassis status";
$s = exec($sCmd, &$aChassisLines, &$rExec);
if ($rExec)
{
print "Warning: Error running ipmitool command: $sCmd:" . implode("\n",$aChassisLines) . "\n";
exit(1);
}
$aChassisStatus=array();
foreach($aChassisLines as $sLine)
{
$aMatch = array();
if (preg_match('/(.*): (.*)/', $sLine, $aMatch))
{
$aChassisStatus[trim($aMatch[1])] = $aMatch[2];
}
}
if (count($aChassisStatus) < 8)
{
print "CRITICAL: Could not parse output from chassis list.";
exit(2);
}
if ($aChassisStatus['System Power'] != 'on')
{
print "OK: Switched off";
exit(0);
}
$iR = 0;
$asR = array();
$aChassisChecks = array('Power Overload', 'Main Power Fault', 'Power Control Fault', 'Drive Fault', 'Cooling/Fan Fault');
foreach ($aChassisChecks as $sCheck)
{
if ($aChassisStatus[$sCheck] != 'false')
{
$iR = 2;
$asR[] = $sCheck;
}
}
$rExec = 0;
$aSDRLines = array();
$sCmd = "$sIpmiTool -U $sUser -P $sPass -H $sHost sdr list";
$s = exec($sCmd, &$aSDRLines, &$rExec);
if ($rExec)
{
print "Warning: Error running ipmitool command: $sCmd:" . implode("\n",$aSDRLines) . "\n";
exit(1);
}
if (count($aSDRLines) < 10)
{
$iR = 2;
$sR = "Could not get sdr list. Machine uncontactable or other fault.";
}
$bParseErrorDone = false;
foreach($aSDRLines as $sLine)
{
$aFields = explode('|',$sLine);
if (count($aFields) < 3)
{
continue;
}
$sCaption = trim($aFields[0]);
$sDetail = trim($aFields[1]);
$sStatus = trim($aFields[2]);
// Power supply always seems to have 'cr' status so omit it from this check
// It is checked by the chassis check anyway
// Ignore Intrusion as well.
if ($sCaption != 'Power Supply' && $sCaption != 'Intrusion' && $sStatus != 'ok')
{
$iR = 2;
$asR[] = "$sCaption status '$sStatus': $sDetail";
}
}
$sR = implode('; ', $asR);
switch($iR)
{
case 0:
print "OK\n";
exit(0);
case 1:
print "Warning: $sR\n";
exit(1);
case 2:
print "CRITICAL: $sR\n";
exit(2);
}
?>