Files
iTop/status.php
Guy Couronné d4d16f43ac Add status.php for getting iTop's status (#56)
Allow for HAProxy and monitoring to get iTop's status
 Add tests for status

Signed-off-by: Guy Couronné <gcouronne:@sapiens.biz>
2019-04-17 09:21:45 +02:00

27 lines
732 B
PHP

<?php
//Include status functions
require_once(dirname(__FILE__) . '/status.inc.php');
//Do check Status
try
{
\StatusStartup();
$aResult = array('status' => STATUS_RUNNING, 'code' => \RestResult::OK, 'message' => '');
}
catch (\Exception $e)
{
$iCode = (defined('\RestResult::INTERNAL_ERROR')) ? \RestResult::INTERNAL_ERROR : 100;
$aResult = array('status' => STATUS_ERROR, 'code' => $iCode, 'message' => $e->getMessage());
http_response_code(500);
}
//Set headers, based on webservices/rest.php
$sContentType = 'application/json';
header('Content-type: ' . $sContentType);
header('Access-Control-Allow-Origin: *');
//Output result
$sResponse = json_encode($aResult);
echo $sResponse;