Thursday, October 15, 2015

PHP disk_free_space

$diskFreeSpace = round(disk_free_space($data_drive) / 1024 / 1024 / 1024);
Nice little uptimeRobot alert script:
isset($_REQUEST['threshold']) ? $driveThresold=$_REQUEST['threshold'] : $driveThresold=11; 
   
function killMe($input) { 
   header('HTTP/1.1 500 Internal Server Error'); 
   die();
}

function allGood($input) { 
   header("Content-Type:text/plain") ;
   die($input);
}

$diskFreeSpace = round(disk_free_space($data_drive) / 1024 / 1024 / 1024);
$diskfreespace < $driveThresold ? killMe($diskfreespace) : allGood(strval($diskfreespace));
die();

No comments: