Refactor metrics retrieval and update chart visualization
This commit is contained in:
parent
1bb0d54dce
commit
1f5f51e3e5
@ -483,14 +483,12 @@ $schema://$host {
|
|||||||
public function getMetrics()
|
public function getMetrics()
|
||||||
{
|
{
|
||||||
if ($this->is_metrics_enabled) {
|
if ($this->is_metrics_enabled) {
|
||||||
$cpu = instant_remote_process(["cat /data/coolify/metrics/cpu.csv | grep 'Overall' | tail -200 | awk -F, '{print $1\",\" \$NF}'"], $this, false);
|
$from = now()->subMinutes(5)->toIso8601ZuluString();
|
||||||
$cpu = str($cpu)->replace("%", "");
|
$cpu = instant_remote_process(["docker exec coolify-sentinel sh -c 'curl http://localhost:8888/api/cpu/history?from=$from'"], $this, false);
|
||||||
ray($cpu);
|
$cpu = str($cpu)->explode("\n")->skip(1)->all();
|
||||||
$parsedCollection = collect($cpu)->flatMap(function ($item) {
|
$parsedCollection = collect($cpu)->flatMap(function ($item) {
|
||||||
return collect(explode("\n", trim($item)))->map(function ($line) {
|
return collect(explode("\n", trim($item)))->map(function ($line) {
|
||||||
list($time, $value) = explode(',', trim($line));
|
list($time, $value) = explode(',', trim($line));
|
||||||
// convert $time from nanoseconds to milliseconds for apexcharts
|
|
||||||
$time = (int) $time / 1000000;
|
|
||||||
return [(int) $time, (float) $value];
|
return [(int) $time, (float) $value];
|
||||||
});
|
});
|
||||||
})->toArray();
|
})->toArray();
|
||||||
|
@ -93,6 +93,7 @@
|
|||||||
return '#D9534F'
|
return '#D9534F'
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
|
|
||||||
xaxis: {
|
xaxis: {
|
||||||
type: 'datetime'
|
type: 'datetime'
|
||||||
},
|
},
|
||||||
@ -107,9 +108,12 @@
|
|||||||
enabled: true
|
enabled: true
|
||||||
},
|
},
|
||||||
chart: {
|
chart: {
|
||||||
|
stroke: {
|
||||||
|
curve: 'smooth',
|
||||||
|
},
|
||||||
height: 500,
|
height: 500,
|
||||||
width: "100%",
|
width: "100%",
|
||||||
type: "area",
|
type: "line",
|
||||||
toolbar: {
|
toolbar: {
|
||||||
show: true
|
show: true
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user