Tweak
This commit is contained in:
parent
98ee8b8de4
commit
f3dfb138ad
@ -5,12 +5,14 @@
|
||||
// Change directory to here
|
||||
$thisDir=DirName(__FILE__);
|
||||
|
||||
|
||||
// Make sure we're root
|
||||
$whoami=Trim(Shell_Exec("whoami"));
|
||||
if($whoami!='root'){
|
||||
die("Please run as root (Currently: $whoami)");
|
||||
}
|
||||
|
||||
|
||||
// First parameter should be path to config file
|
||||
$config_path=$argv[1];
|
||||
if(!File_Exists($config_path)){
|
||||
@ -19,7 +21,8 @@ if(!File_Exists($config_path)){
|
||||
if(!Is_File($config_path)){
|
||||
die("\nConfig file ... isn't a file?: {$config_path}\n");
|
||||
}
|
||||
$config_path=RealPath($config_path);
|
||||
$config_path = RealPath($config_path);
|
||||
|
||||
|
||||
// Second could be a test type (optional)
|
||||
$bStartTests_short=false;
|
||||
@ -36,11 +39,13 @@ if(IsSet($argv[2])){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Load config
|
||||
$config=LoadConfig($config_path);
|
||||
$config = LoadConfig($config_path);
|
||||
|
||||
|
||||
// Show information about each drive
|
||||
foreach($config['devices'] as $name=>$device){
|
||||
foreach ($config['devices'] as $name=>$device ) {
|
||||
|
||||
//
|
||||
$match=true;
|
||||
@ -74,13 +79,14 @@ foreach($config['devices'] as $name=>$device){
|
||||
|
||||
// Ask smartctl for status
|
||||
$command="smartctl --all --device {$device_safe} {$path_safe}";
|
||||
print "\nCOMMAND: {$command}";
|
||||
$output_lines=false;
|
||||
Exec($command,$output_lines,$smart_return_code);
|
||||
$lines=Implode("\n",$output_lines);
|
||||
|
||||
// Output any messages indicated by smartctl
|
||||
$messages=CheckNamedBits($smart_return_code);
|
||||
foreach($messages as $message){
|
||||
$messages = CheckNamedBits($smart_return_code);
|
||||
foreach ($messages as $message) {
|
||||
print "\nMESSAGE: {$message}";
|
||||
}
|
||||
|
||||
@ -188,14 +194,14 @@ function CheckNamedBits($return_code)
|
||||
|
||||
//
|
||||
$map=Array(
|
||||
'0'=>"Command line did not parse.",
|
||||
'1'=>"Device open failed, device did not return an IDENTIFY DEVICE structure, or device is in a low-power mode",
|
||||
'2'=>"Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data structure",
|
||||
'3'=>"SMART status check returned \"DISK FAILING\".",
|
||||
'4'=>"We found prefail Attributes <= threshold.",
|
||||
'5'=>"SMART status check returned \"DISK OK\" but we found that some (usage or prefail) Attributes have been <= threshold at some time in the past.",
|
||||
'6'=>"The device error log contains records of errors.",
|
||||
'7'=>"The device self-test log contains records of errors. [ATA only] Failed self-tests outdated by a newer successful extended self-test are ignored."
|
||||
'0' => "Command line did not parse.",
|
||||
'1' => "Device open failed, device did not return an IDENTIFY DEVICE structure, or device is in a low-power mode",
|
||||
'2' => "Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data structure",
|
||||
'3' => "SMART status check returned \"DISK FAILING\".",
|
||||
'4' => "We found prefail Attributes <= threshold.",
|
||||
'5' => "SMART status check returned \"DISK OK\" but we found that some (usage or prefail) Attributes have been <= threshold at some time in the past.",
|
||||
'6' => "The device error log contains records of errors.",
|
||||
'7' => "The device self-test log contains records of errors. [ATA only] Failed self-tests outdated by a newer successful extended self-test are ignored."
|
||||
);
|
||||
|
||||
//
|
||||
@ -209,10 +215,10 @@ function CheckNamedBits($return_code)
|
||||
}
|
||||
|
||||
//
|
||||
function CheckBitPosition($toCheck,$index)
|
||||
function CheckBitPosition($toCheck, $index)
|
||||
{
|
||||
//
|
||||
$value=Pow(2,$index);
|
||||
$value=Pow(2, $index);
|
||||
|
||||
//
|
||||
$bIsSet=false;
|
||||
|
Loading…
Reference in New Issue
Block a user