实现健康检查配置、立即执行健康检查

This commit is contained in:
GoEdgeLab
2020-10-17 21:15:22 +08:00
parent 282900d611
commit bbe6253346
28 changed files with 500 additions and 115 deletions

View File

@@ -1,7 +1,5 @@
{$layout}
{$template "/left_menu"}
<div class="right-box">
{$template "menu"}
<form class="ui form segment" action="/clusters/cluster">
@@ -61,7 +59,10 @@
<span v-if="node.ipAddresses.length == 0">-</span>
<div v-else class="address-box">
<div v-for="addr in node.ipAddresses" style="margin-bottom:0.3em">
<div class="ui label tiny">{{addr.ip}} <span class="small">{{addr.name}}</span></div>
<div class="ui label tiny">{{addr.ip}}
<span class="small" v-if="addr.name.length > 0">{{addr.name}}<span v-if="!addr.canAccess">,不可访问</span></span>
<span class="small" v-if="addr.name.length == 0 && !addr.canAccess">(不可访问)</span>
</div>
</div>
</div>
</td>
@@ -98,5 +99,4 @@
</table>
<div class="page" v-html="page"></div>
</div>
<div class="page" v-html="page"></div>

View File

@@ -1,7 +1,5 @@
{$layout}
{$template "/left_menu"}
<div class="right-box">
{$template "menu"}
<p>可以通过节点安装包中的<code-label>configs/cluster.yaml</code-label>直接自动注册节点。</p>
<table class="ui table definition selectable">
@@ -16,5 +14,4 @@ clusterId: "{{cluster.uniqueId}}"
secret: "{{cluster.secret}}"</pre>
</td>
</tr>
</table>
</div>
</table>

View File

@@ -1,4 +1,6 @@
<second-menu>
<menu-item :href="'/clusters/cluster?clusterId=' + clusterId">节点列表</menu-item>
<span class="item">|</span>
<menu-item :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + nodeId" code="node">节点详情</menu-item>
<menu-item :href="'/clusters/cluster/node/logs?clusterId=' + clusterId + '&nodeId=' + nodeId" code="log">运行日志</menu-item>
<menu-item :href="'/clusters/cluster/node/update?clusterId=' + clusterId + '&nodeId=' + nodeId" code="update">修改设置</menu-item>

View File

@@ -1,7 +1,5 @@
{$layout}
{$template "/left_menu"}
<div class="right-box">
{$template "/clusters/cluster/menu"}
<form class="ui form" data-tea-action="$" data-tea-success="success">
@@ -41,5 +39,4 @@
</tr>
</table>
<submit-btn></submit-btn>
</form>
</div>
</form>

View File

@@ -1,7 +1,5 @@
{$layout}
{$template "/left_menu"}
<div class="right-box">
{$template "node_menu"}
<!-- 已安装 -->
@@ -53,5 +51,4 @@ secret: "{{node.secret}}"</pre>
</table>
<a href="" @click.prevent="updateNodeIsInstalled(true)">[修改为已安装状态]</a>
</div>
</div>
</div>

View File

@@ -1,7 +1,5 @@
{$layout}
{$template "/left_menu"}
<div class="right-box">
{$template "node_menu"}
<p class="comment" v-if="logs.length == 0">暂时还没有日志。</p>
@@ -19,5 +17,4 @@
</tr>
</table>
<div class="page" v-html="page"></div>
</div>
<div class="page" v-html="page"></div>

View File

@@ -1,7 +1,5 @@
{$layout}
{$template "/left_menu"}
<div class="right-box">
{$template "node_menu"}
<h3>节点详情</h3>
@@ -19,8 +17,10 @@
<td>
<div v-if="node.ipAddresses.length > 0">
<div>
<div v-for="(address, index) in node.ipAddresses" class="ui label small">
{{address.ip}}<span class="small">{{address.name}}</span>
<div v-for="(address, index) in node.ipAddresses" class="ui label tiny">
{{address.ip}}
<span class="small" v-if="address.name.length > 0">{{address.name}}<span v-if="!address.canAccess">,不可访问</span></span>
<span class="small" v-if="address.name.length == 0 && !address.canAccess">(不可访问)</span>
</div>
</div>
</div>
@@ -97,5 +97,4 @@
<a v-else :href="'/clusters/cluster/installNode?clusterId=' + clusterId + '&nodeId=' + nodeId" class="underline" title="点击进入安装界面"><span class="red">未安装</span></a>
</td>
</tr>
</table>
</div>
</table>

View File

@@ -1,7 +1,5 @@
{$layout}
{$template "/left_menu"}
<div class="right-box">
{$template "node_menu"}
<h3>修改节点</h3>
@@ -76,5 +74,4 @@
</tbody>
</table>
<submit-btn></submit-btn>
</form>
</div>
</form>

View File

@@ -0,0 +1,10 @@
{$layout}
{$template "/left_menu"}
<div class="right-box">
<form class="ui form" data-tea-action="$" data-tea-success="success">
<input type="hidden" name="clusterId" :value="clusterId"/>
<health-check-config-box :v-health-check-config="healthCheckConfig"></health-check-config-box>
<submit-btn></submit-btn> &nbsp; <a href="" @click.prevent="run()">立即检查</a>
</form>
</div>

View File

@@ -0,0 +1,11 @@
Tea.context(function () {
this.success = NotifyReloadSuccess("保存成功")
this.run = function () {
teaweb.confirm("确定要对当前集群下的所有节点进行健康检查吗?", function () {
teaweb.popup("/clusters/cluster/settings/healthRun?clusterId=" + this.clusterId, {
})
})
}
})

View File

@@ -0,0 +1,27 @@
{$layout "layout_popup"}
<h3>健康检查</h3>
<span class="red" v-if="isRequesting">正在执行中,请等待执行完毕...</span>
<form class="ui form" v-if="!isRequesting">
<p>成功节点:<span class="green">{{countSuccess}}</span> &nbsp; 失败节点:<span class="red">{{countFail}}</span></p>
<table class="ui table selectable">
<thead>
<tr>
<th>节点</th>
<th>结果</th>
<th>耗时</th>
</tr>
</thead>
<tr v-for="result in results">
<td>{{result.node.name}}<span class="small" v-if="result.nodeAddr != null && result.nodeAddr.length > 0">{{result.nodeAddr}}</span></td>
<td>
<span v-if="!result.isOk" class="red">失败:{{result.error}}</span>
<span v-else class="green">成功</span>
</td>
<td>{{result.costMs}}ms</td>
</tr>
</table>
<button class="ui button primary" type="button" @click.prevent="success">完成</button>
</form>

View File

@@ -0,0 +1,39 @@
Tea.context(function () {
this.success = NotifyPopup
this.isRequesting = false
this.results = []
this.countSuccess = 0
this.countFail = 0
this.$delay(function () {
this.run()
})
this.run = function () {
this.isRequesting = true
this.$post("$")
.params({
clusterId: this.clusterId
})
.success(function (resp) {
this.results = resp.data.results
let that = this
this.results.forEach(function (v) {
v.costMs = Math.ceil(v.costMs)
if (isNaN(v.costMs)) {
v.costMs = 0
}
if (v.isOk) {
that.countSuccess++
} else {
that.countFail++
}
})
})
.done(function () {
this.isRequesting = false
})
}
})