%PDF- %PDF-
Direktori : /home/waritko/ |
Current File : //home/waritko/shapers.php |
<?php include "dibi.php"; dibi::connect([ 'driver' => 'postgre', 'string' => 'host=127.0.0.1 port=5432 dbname=shapers user=waritko password=Nastenka112', 'persistent' => TRUE, ]); error_reporting(-1); $data = ""; while(!($data = shell_exec("curl -m 90 --silent http://shapers.technology:6543/stats/ALL.Brno | grep 'data = ' | cut -d '=' -f 2"))); // $data = file_get_contents("help.json"); $data = trim(trim($data), ";"); $data = str_replace("'", "\"", $data); $obj = json_decode($data); $maxts = (int)(dibi::query("select coalesce(max([unix]), 0) from brno")->fetchSingle()); foreach($obj as $o) { if($o->timestamp <= $maxts) continue; $params = array( "timestamp" => date("Y-m-d H:i:s", $o->timestamp), "unix" => floor($o->timestamp), "enl" => $o->enl, "res" => $o->res, "e8" => $o->e8, "r8" => $o->r8, "epower" => $o->epower, "rpower" => $o->rpower, "n" => $o->n, "rcmh" => $o->rcmh, "rrmh" => $o->rrmh, "rvrmh" => $o->rvrmh, "rs" => $o->rs, "rcs" => $o->rcs, "rrs" => $o->rrs, "rvrs" => $o->rvrs, "raxa" => $o->raxa ); // dibi::test("INSERT INTO [brno]", $params); dibi::query("INSERT INTO [brno]", $params); }