节点详情中显示更多信息(版本、CPU、负载等)

This commit is contained in:
刘祥超
2021-01-31 11:05:04 +08:00
parent 3ebb47d915
commit cc5a34c20e
3 changed files with 71 additions and 12 deletions

View File

@@ -143,6 +143,24 @@ func (this *NodeAction) RunGet(params struct {
status.IsActive = status.IsActive && time.Now().Unix()-status.UpdatedAt <= 60 // N秒之内认为活跃
}
// 检查是否有新版本
if len(status.OS) > 0 {
checkVersionResp, err := this.RPC().NodeRPC().CheckNodeLatestVersion(this.AdminContext(), &pb.CheckNodeLatestVersionRequest{
Os: status.OS,
Arch: status.Arch,
CurrentVersion: status.BuildVersion,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Data["shouldUpgrade"] = checkVersionResp.HasNewVersion
this.Data["newVersion"] = checkVersionResp.NewVersion
} else {
this.Data["shouldUpgrade"] = false
this.Data["newVersion"] = ""
}
// 分组
var groupMap maps.Map = nil
if node.Group != nil {
@@ -175,14 +193,20 @@ func (this *NodeAction) RunGet(params struct {
"isOn": node.IsOn,
"status": maps.Map{
"isActive": status.IsActive,
"updatedAt": status.UpdatedAt,
"hostname": status.Hostname,
"cpuUsage": status.CPUUsage,
"cpuUsageText": fmt.Sprintf("%.2f%%", status.CPUUsage*100),
"memUsage": status.MemoryUsage,
"memUsageText": fmt.Sprintf("%.2f%%", status.MemoryUsage*100),
"connectionCount": status.ConnectionCount,
"isActive": status.IsActive,
"updatedAt": status.UpdatedAt,
"hostname": status.Hostname,
"cpuUsage": status.CPUUsage,
"cpuUsageText": fmt.Sprintf("%.2f%%", status.CPUUsage*100),
"memUsage": status.MemoryUsage,
"memUsageText": fmt.Sprintf("%.2f%%", status.MemoryUsage*100),
"connectionCount": status.ConnectionCount,
"buildVersion": status.BuildVersion,
"cpuPhysicalCount": status.CPUPhysicalCount,
"cpuLogicalCount": status.CPULogicalCount,
"load1m": fmt.Sprintf("%.2f", status.Load1m),
"load5m": fmt.Sprintf("%.2f", status.Load5m),
"load15m": fmt.Sprintf("%.2f", status.Load15m),
},
"group": groupMap,

View File

@@ -37,7 +37,25 @@
</tr>
<tr v-if="dnsRecordName.length > 0 && dnsRecordValue.length > 0">
<td>DNS记录</td>
<td>{{dnsRecordName}} -&gt; {{dnsRecordValue}}
<td>
<table class="ui table celled">
<thead class="full-width">
<tr>
<th>记录名</th>
<th>记录类型</th>
<th>线路</th>
<th>记录值</th>
</tr>
</thead>
<tbody v-for="address in node.ipAddresses" v-if="address.canAccess">
<tr v-for="route in dnsRoutes">
<td>{{dnsRecordName}}</td>
<td>A</td>
<td>{{route.name}}</td>
<td>{{address.ip}}</td>
</tr>
</tbody>
</table>
<p class="comment">通过设置A记录可以将集群上的服务请求转发到不同线路的节点上。</p>
</td>
</tr>
@@ -125,17 +143,34 @@
</tr>
<tbody v-show="node.status.isActive">
<tr>
<td>CPU</td>
<td>CPU用量</td>
<td>{{node.status.cpuUsageText}}</td>
</tr>
<tr>
<td>内存</td>
<td>内存用量</td>
<td>{{node.status.memUsageText}}</td>
</tr>
<tr>
<td>连接数</td>
<td>{{node.status.connectionCount}}</td>
</tr>
<tr>
<td>版本</td>
<td>v{{node.status.buildVersion}}
&nbsp; <a :href="'/clusters/cluster/upgradeRemote?clusterId=' + clusterId" v-if="shouldUpgrade"><span class="red">发现新版本v{{newVersion}} &raquo;</span></a>
</td>
</tr>
<tr>
<td>CPU</td>
<td>
<span v-if="node.status.cpuPhysicalCount > 0">{{node.status.cpuPhysicalCount}}核心/{{node.status.cpuLogicalCount}}线程</span>
<span v-else class="disabled">-/-</span>
</td>
</tr>
<tr>
<td>负载</td>
<td>{{node.status.load1m}} &nbsp; {{node.status.load5m}} &nbsp; {{node.status.load15m}} &nbsp; <tip-icon content="三个数字分别代表1分钟、5分钟、15分钟平均负载"></tip-icon></td>
</tr>
</tbody>
</table>
<p class="comment" v-if="node.status.isActive">每隔30秒钟更新一次运行状态。</p>

View File

@@ -20,7 +20,7 @@
</thead>
<tr v-for="node in nodes">
<td>
<a :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + node.id">{{node.name}}</a>
<link-icon :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + node.id">{{node.name}}</link-icon>
</td>
<td>
<span v-for="addr in node.addresses" v-if="addr.canAccess" class="ui label tiny">{{addr.ip}}</span>