Commit 783a9010 authored by Ad Schellevis's avatar Ad Schellevis

(SystemHealth) work in progress

parent ecf9eb5f
...@@ -36,7 +36,7 @@ use \OPNsense\Core\Backend; ...@@ -36,7 +36,7 @@ use \OPNsense\Core\Backend;
* Class ServiceController * Class ServiceController
* @package OPNsense\SystemHealth * @package OPNsense\SystemHealth
*/ */
class SystemHealthController extends ApiControllerBase class SystemhealthController extends ApiControllerBase
{ {
/** /**
...@@ -242,18 +242,7 @@ class SystemHealthController extends ApiControllerBase ...@@ -242,18 +242,7 @@ class SystemHealthController extends ApiControllerBase
$timestamp = $rowValues['timestamp'] * 1000; // javascript works with milliseconds $timestamp = $rowValues['timestamp'] * 1000; // javascript works with milliseconds
foreach ($data['columns'] as $key => $value) { foreach ($data['columns'] as $key => $value) {
$name = $value['name']; $name = $value['name'];
if ($value['type'] == "GAUGE") { $value = $rowValues['condensed_values'][$key];
// return values as float
$value = $rowValues['condensed_values'][$key];
} else {
// return values as int
if ((string)$rowValues['condensed_values'][$key] != "NaN") {
$value = (int)$rowValues['condensed_values'][$key];
} else {
$value = $rowValues['condensed_values'][$key];
}
}
if (!isset($d3_data[$key])) { if (!isset($d3_data[$key])) {
$d3_data[$key] = []; $d3_data[$key] = [];
$d3_data[$key]["area"] = true; $d3_data[$key]["area"] = true;
...@@ -263,7 +252,6 @@ class SystemHealthController extends ApiControllerBase ...@@ -263,7 +252,6 @@ class SystemHealthController extends ApiControllerBase
$d3_data[$key]["key"] = $name; $d3_data[$key]["key"] = $name;
} }
$d3_data[$key]["values"] = []; $d3_data[$key]["values"] = [];
} }
if ($value == "NaN") { if ($value == "NaN") {
...@@ -311,7 +299,7 @@ class SystemHealthController extends ApiControllerBase ...@@ -311,7 +299,7 @@ class SystemHealthController extends ApiControllerBase
"stepSize" => $data['condensed_step'], "stepSize" => $data['condensed_step'],
"from_timestamp" => $from_timestamp, "from_timestamp" => $from_timestamp,
"to_timestamp" => $to_timestamp, "to_timestamp" => $to_timestamp,
"count" => count($d3_data[0]['values']), "count" => isset($d3_data[0]) ? count($d3_data[0]['values']) : 0,
"data" => $d3_data "data" => $d3_data
]; ];
} }
...@@ -555,7 +543,7 @@ class SystemHealthController extends ApiControllerBase ...@@ -555,7 +543,7 @@ class SystemHealthController extends ApiControllerBase
if ($xml !== false) { if ($xml !== false) {
// we only use the average databases in any RRD, remove the rest to avoid strange behaviour. // we only use the average databases in any RRD, remove the rest to avoid strange behaviour.
for ($count = count($xml->rra) -1; $count >= 0; $count--) { for ($count = count($xml->rra) -1; $count >= 0; $count--) {
if ((string)$xml->rra[$count]->cf != "AVERAGE") { if (trim((string)$xml->rra[$count]->cf) != "AVERAGE") {
unset($xml->rra[$count]); unset($xml->rra[$count]);
} }
......
...@@ -32,7 +32,7 @@ namespace OPNsense\Diagnostics; ...@@ -32,7 +32,7 @@ namespace OPNsense\Diagnostics;
* Class IndexController * Class IndexController
* @package OPNsense\Proxy * @package OPNsense\Proxy
*/ */
class SystemHealthController extends \OPNsense\Base\IndexController class SystemhealthController extends \OPNsense\Base\IndexController
{ {
public function indexAction() public function indexAction()
{ {
......
[query.details] [list]
command:/Users/josschellevis/Development/opnsense/scripts/systemhealth/queryDetails.py command:/usr/local/opnsense/scripts/systemhealth/listReports.py
parameters: parameters:
type:script_output type:script_output
message:request rrd graph details message:list systemhealth items
[fetch]
command:/usr/local/opnsense/scripts/systemhealth/fetchData.py
parameters: %s
type:script_output
message:fetch systemhealth report data
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment