mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-09 16:50:26 +08:00
节点看板增加缓存目录用量
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
package boards
|
package boards
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/node/nodeutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/node/nodeutils"
|
||||||
@@ -140,6 +141,23 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
this.Data["loadValues"] = statMaps
|
this.Data["loadValues"] = statMaps
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CacheDirs
|
||||||
|
{
|
||||||
|
var statMaps = []maps.Map{}
|
||||||
|
for _, stat := range resp.CacheDirsValues {
|
||||||
|
var m = maps.Map{}
|
||||||
|
err = json.Unmarshal(stat.ValueJSON, &m)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
statMaps = append(statMaps, maps.Map{
|
||||||
|
"time": timeutil.FormatTime("H:i", stat.CreatedAt),
|
||||||
|
"value": m,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.Data["cacheDirValues"] = statMaps
|
||||||
|
}
|
||||||
|
|
||||||
// 指标
|
// 指标
|
||||||
{
|
{
|
||||||
var chartMaps = []maps.Map{}
|
var chartMaps = []maps.Map{}
|
||||||
|
|||||||
@@ -102,6 +102,11 @@
|
|||||||
<div class="chart-box" id="memory-chart" v-show="nodeStatusTab == 'memory'"></div>
|
<div class="chart-box" id="memory-chart" v-show="nodeStatusTab == 'memory'"></div>
|
||||||
<div class="chart-box" id="load-chart" v-show="nodeStatusTab == 'load'"></div>
|
<div class="chart-box" id="load-chart" v-show="nodeStatusTab == 'load'"></div>
|
||||||
|
|
||||||
|
<!-- 缓存 -->
|
||||||
|
<div class="ui divider"></div>
|
||||||
|
<h4>缓存目录用量<span v-if="cacheDirUsed.length > 0">(使用:{{cacheDirUsed}}/总量:{{cacheDirTotal}}/剩余:{{cacheDirAvail}})</span></h4>
|
||||||
|
<div class="chart-box" id="cache-dirs-chart"></div>
|
||||||
|
|
||||||
<!-- 指标 -->
|
<!-- 指标 -->
|
||||||
<div class="ui divider" v-if="metricCharts.length > 0"></div>
|
<div class="ui divider" v-if="metricCharts.length > 0"></div>
|
||||||
<metric-board>
|
<metric-board>
|
||||||
|
|||||||
@@ -35,12 +35,13 @@ Tea.context(function () {
|
|||||||
this.reloadHourlyRequestsChart()
|
this.reloadHourlyRequestsChart()
|
||||||
this.reloadTopDomainsChart()
|
this.reloadTopDomainsChart()
|
||||||
this.reloadCPUChart()
|
this.reloadCPUChart()
|
||||||
|
this.reloadCacheDirsChart()
|
||||||
})
|
})
|
||||||
this.$delay(function() {
|
this.$delay(function () {
|
||||||
this.refreshBoard()
|
this.refreshBoard()
|
||||||
}, 30000)
|
}, 30000)
|
||||||
|
|
||||||
this.refreshBoard = function() {
|
this.refreshBoard = function () {
|
||||||
this.$post("$")
|
this.$post("$")
|
||||||
.params({
|
.params({
|
||||||
clusterId: this.clusterId,
|
clusterId: this.clusterId,
|
||||||
@@ -424,4 +425,33 @@ Tea.context(function () {
|
|||||||
max: max
|
max: max
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.cacheDirUsed = ""
|
||||||
|
this.cacheDirTotal = ""
|
||||||
|
if (this.cacheDirValues.length > 0) {
|
||||||
|
this.cacheDirUsed = teaweb.formatBytes(this.cacheDirValues.$last().value.dirs[0].used)
|
||||||
|
this.cacheDirTotal = teaweb.formatBytes(this.cacheDirValues.$last().value.dirs[0].total)
|
||||||
|
this.cacheDirAvail = teaweb.formatBytes(this.cacheDirValues.$last().value.dirs[0].avail)
|
||||||
|
}
|
||||||
|
this.reloadCacheDirsChart = function () {
|
||||||
|
let axis = {unit: "%", divider: 1}
|
||||||
|
teaweb.renderLineChart({
|
||||||
|
id: "cache-dirs-chart",
|
||||||
|
name: "缓存目录用量",
|
||||||
|
values: this.cacheDirValues,
|
||||||
|
x: function (v) {
|
||||||
|
return v.time
|
||||||
|
},
|
||||||
|
tooltip: function (args, stats) {
|
||||||
|
var v = stats[args.dataIndex].value.dirs[0]
|
||||||
|
return stats[args.dataIndex].time + "<br/>使用:" + teaweb.formatBytes(v.used) + "<br/>总量:" + teaweb.formatBytes(v.total) + "<br/>比例:" + (Math.ceil(v.used * 100/v.total * 100) / 100) + "%"
|
||||||
|
},
|
||||||
|
value: function (v) {
|
||||||
|
v = v.value.dirs[0]
|
||||||
|
return (v.used * 100 / v.total) ;
|
||||||
|
},
|
||||||
|
axis: axis,
|
||||||
|
max: 100
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user