diff --git a/internal/web/actions/default/clusters/cluster/node/boards/index.go b/internal/web/actions/default/clusters/cluster/node/boards/index.go index 33602374..e52ed4da 100644 --- a/internal/web/actions/default/clusters/cluster/node/boards/index.go +++ b/internal/web/actions/default/clusters/cluster/node/boards/index.go @@ -3,6 +3,7 @@ package boards import ( + "encoding/json" teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "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 } + // 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{} diff --git a/web/views/@default/clusters/cluster/node/boards/index.html b/web/views/@default/clusters/cluster/node/boards/index.html index 6661436f..0973cd03 100644 --- a/web/views/@default/clusters/cluster/node/boards/index.html +++ b/web/views/@default/clusters/cluster/node/boards/index.html @@ -102,6 +102,11 @@
+ +
+

缓存目录用量(使用:{{cacheDirUsed}}/总量:{{cacheDirTotal}}/剩余:{{cacheDirAvail}})

+
+
diff --git a/web/views/@default/clusters/cluster/node/boards/index.js b/web/views/@default/clusters/cluster/node/boards/index.js index cc536a74..bd44834d 100644 --- a/web/views/@default/clusters/cluster/node/boards/index.js +++ b/web/views/@default/clusters/cluster/node/boards/index.js @@ -35,12 +35,13 @@ Tea.context(function () { this.reloadHourlyRequestsChart() this.reloadTopDomainsChart() this.reloadCPUChart() + this.reloadCacheDirsChart() }) - this.$delay(function() { + this.$delay(function () { this.refreshBoard() }, 30000) - this.refreshBoard = function() { + this.refreshBoard = function () { this.$post("$") .params({ clusterId: this.clusterId, @@ -424,4 +425,33 @@ Tea.context(function () { 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 + "
使用:" + teaweb.formatBytes(v.used) + "
总量:" + teaweb.formatBytes(v.total) + "
比例:" + (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 + }) + } }) \ No newline at end of file