Skip to content

Instantly share code, notes, and snippets.

@electricjesus
Created December 17, 2014 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save electricjesus/81325d9aea8521e8ce70 to your computer and use it in GitHub Desktop.
Save electricjesus/81325d9aea8521e8ce70 to your computer and use it in GitHub Desktop.
Script to test for server uptime [Magento]
<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
header("Content-type: application/json");
require_once "app/Mage.php";
Mage::app($_SERVER['MAGE_RUN_CODE'], $_SERVER['MAGE_RUN_TYPE']);
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$cfg = $readConnection->getConfig();
$conn = mysqli_connect($cfg['host'],$cfg['username'],$cfg['password']);
$connected = mysqli_ping($conn);
if($connected) {
echo "I'm OK!";
} else {
exit(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment