ezservermonitor-web/libs/services.php

37 lines
799 B
PHP
Raw Normal View History

2014-06-18 04:11:11 -04:00
<?php
require 'Utils/Config.class.php';
$Config = new Config();
$datas = array();
if (count($Config->get('services')) > 0)
{
foreach ($Config->get('services') as $service)
{
$host = $service['host'];
$sock = @fsockopen($host, $service['port'], $num, $error, 5);
2014-06-18 04:11:11 -04:00
if ($sock)
{
$datas[] = array(
'port' => $service['port'],
'name' => $service['name'],
'status' => 1,
);
fclose($sock);
}
else
{
$datas[] = array(
'port' => $service['port'],
'name' => $service['name'],
'status' => 0,
);
}
}
}
echo json_encode($datas);