lws: add ipcam_server stats
This commit is contained in:
parent
a58f4ef588
commit
ec1e287bf1
@ -86,5 +86,7 @@ return [
|
||||
'grafana_sensors_url' => '',
|
||||
'grafana_inverter_url' => '',
|
||||
|
||||
'ipcam_server_api_addr' => '',
|
||||
|
||||
'dhcp_hostname_overrides' => [],
|
||||
];
|
||||
|
@ -108,6 +108,21 @@ class MiscHandler extends RequestHandler
|
||||
$this->tpl->render_page('cams.twig');
|
||||
}
|
||||
|
||||
public function GET_cams_stat() {
|
||||
global $config;
|
||||
list($ip, $port) = explode(':', $config['ipcam_server_api_addr']);
|
||||
$body = jsonDecode(file_get_contents('http://'.$ip.':'.$port.'/api/timestamp/all'));
|
||||
|
||||
header('Content-Type: text/plain');
|
||||
$date_fmt = 'd.m.Y H:i:s';
|
||||
|
||||
foreach ($body['response'] as $cam => $data) {
|
||||
$fix = date($date_fmt, $data['fix']);
|
||||
$motion = date($date_fmt, $data['motion']);
|
||||
echo "$cam:\n motion: $motion\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
public function GET_debug() {
|
||||
print_r($_SERVER);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ $router->add('pump/', 'Misc pump_page');
|
||||
$router->add('phpinfo/', 'Misc phpinfo');
|
||||
$router->add('cams/', 'Misc cams');
|
||||
$router->add('cams/([\d,]+)/', 'Misc cams id=$(1)');
|
||||
$router->add('cams/stat/', 'Misc cams_stat');
|
||||
$router->add('debug/', 'Misc debug');
|
||||
|
||||
// auth
|
||||
|
@ -30,5 +30,6 @@
|
||||
{% for id, name in cameras %}
|
||||
<li class="list-group-item"><a href="/cams/{{ id }}/">{{ name }}</a> (<a href="/cams/{{ id }}/?high=1">HQ</a>)</li>
|
||||
{% endfor %}
|
||||
<li class="list-group-item"><a href="/cams/stat/">Статистика</a></li>
|
||||
</ul>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user