mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
✨ 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>
This commit is contained in:
26
status.php
Normal file
26
status.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?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;
|
||||
Reference in New Issue
Block a user