blob: a3f9e941cdf943c275484625a2099ba64a31db48 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
<?php
require '../autoload.php';
$Config = new Config();
$datas = array();
$available_protocols = array('tcp', 'udp', 'unix');
$show_port = $Config->get('services:show_port');
if (count($Config->get('services:list')) > 0)
{
foreach ($Config->get('services:list') as $service)
{
$host = $service['host'];
$port = $service['port'];
$name = $service['name'];
$protocol = isset($service['protocol']) && in_array($service['protocol'], $available_protocols) ? $service['protocol'] : 'tcp';
$socketProtocols = array('tcp', 'udp', 'unix');
if (in_array($protocol, $socketProtocols)) {
if (Misc::socketAvailable($host, $port, $protocol))
$status = 1;
else
$status = 0;
}
else {
$status = Misc::systemdServiceActive($host) ? 1 : 0;
}
$datas[] = array(
'port' => $show_port === true ? $port : '',
'name' => $name,
'status' => $status,
);
}
}
echo json_encode($datas);
|