IP阈值增加节点分组和集群相关统计项目

This commit is contained in:
GoEdgeLab
2021-09-14 11:36:08 +08:00
parent b7a694e99d
commit e454bdd982
11 changed files with 70 additions and 110 deletions

View File

@@ -3,6 +3,7 @@ package node
import ( import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs" "github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"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/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/maps"
@@ -25,16 +26,11 @@ func (this *InstallAction) RunGet(params struct {
this.Data["nodeId"] = params.NodeId this.Data["nodeId"] = params.NodeId
// 节点 // 节点
nodeResp, err := this.RPC().NodeRPC().FindEnabledNode(this.AdminContext(), &pb.FindEnabledNodeRequest{NodeId: params.NodeId}) node, err := nodeutils.InitNodeInfo(this.Parent(), params.NodeId)
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
node := nodeResp.Node
if node == nil {
this.WriteString("找不到要操作的节点")
return
}
// 安装信息 // 安装信息
if node.InstallStatus != nil { if node.InstallStatus != nil {
@@ -84,15 +80,12 @@ func (this *InstallAction) RunGet(params struct {
} }
this.Data["apiEndpoints"] = "\"" + strings.Join(apiEndpoints, "\", \"") + "\"" this.Data["apiEndpoints"] = "\"" + strings.Join(apiEndpoints, "\", \"") + "\""
this.Data["node"] = maps.Map{ var nodeMap = this.Data["node"].(maps.Map)
"id": node.Id, nodeMap["installDir"] = node.InstallDir
"name": node.Name, nodeMap["isInstalled"] = node.IsInstalled
"installDir": node.InstallDir, nodeMap["uniqueId"] = node.UniqueId
"isInstalled": node.IsInstalled, nodeMap["secret"] = node.Secret
"uniqueId": node.UniqueId, nodeMap["cluster"] = clusterMap
"secret": node.Secret,
"cluster": clusterMap,
}
this.Show() this.Show()
} }

View File

@@ -22,11 +22,21 @@ func InitNodeInfo(parentAction *actionutils.ParentAction, nodeId int64) (*pb.Nod
return nil, errors.New("node '" + strconv.FormatInt(nodeId, 10) + "' not found") return nil, errors.New("node '" + strconv.FormatInt(nodeId, 10) + "' not found")
} }
var node = nodeResp.Node var node = nodeResp.Node
var groupMap maps.Map
if node.NodeGroup != nil {
groupMap = maps.Map{
"id": node.NodeGroup.Id,
"name": node.NodeGroup.Name,
}
}
parentAction.Data["node"] = maps.Map{ parentAction.Data["node"] = maps.Map{
"id": node.Id, "id": node.Id,
"name": node.Name, "name": node.Name,
"isOn": node.IsOn, "isOn": node.IsOn,
"isUp": node.IsUp, "isUp": node.IsUp,
"group": groupMap,
} }
var clusterId int64 = 0 var clusterId int64 = 0
if node.NodeCluster != nil { if node.NodeCluster != nil {

View File

@@ -45,6 +45,7 @@ func (this *ClusterHelper) BeforeAction(actionPtr actions.ActionWrapper) (goNext
action.WriteString("can not find cluster") action.WriteString("can not find cluster")
return return
} }
action.Data["currentClusterName"] = cluster.Name
clusterInfo, err := dao.SharedNodeClusterDAO.FindEnabledNodeClusterConfigInfo(ctx, clusterId) clusterInfo, err := dao.SharedNodeClusterDAO.FindEnabledNodeClusterConfigInfo(ctx, clusterId)
if err != nil { if err != nil {

View File

@@ -6,6 +6,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/conds/condutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/conds/condutils"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
"github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/Tea"
@@ -102,6 +103,16 @@ func (this *ComponentsAction) RunGet(params struct{}) {
buffer.Write([]byte{'\n', '\n'}) buffer.Write([]byte{'\n', '\n'})
} }
// IP地址阈值
ipAddrThresholdItemsJSON, err := json.Marshal(nodeconfigs.FindAllIPAddressThresholdItems())
if err != nil {
logs.Println("ComponentsAction marshal ip addr threshold items failed: " + err.Error())
} else {
buffer.WriteString("window.IP_ADDR_THRESHOLD_ITEMS = ")
buffer.Write(ipAddrThresholdItemsJSON)
buffer.Write([]byte{'\n', '\n'})
}
componentsData = buffer.Bytes() componentsData = buffer.Bytes()
// ETag // ETag

View File

@@ -66,7 +66,7 @@ Vue.component("network-addresses-box", {
updateAddr: function (index, addr) { updateAddr: function (index, addr) {
let that = this let that = this
window.UPDATING_ADDR = addr window.UPDATING_ADDR = addr
teaweb.popup("/servers/addPortPopup?serverType=" + this.vServerType + "&protocol=" + this.protocol, { teaweb.popup("/servers/addPortPopup?serverType=" + this.vServerType + "&protocol=" + this.protocol + "&from=" + this.from, {
height: "16em", height: "16em",
callback: function (resp) { callback: function (resp) {
var addr = resp.data.address var addr = resp.data.address

View File

@@ -27,37 +27,12 @@ Vue.component("node-ip-address-thresholds-box", {
isAddingItem: false, isAddingItem: false,
isAddingAction: false, isAddingAction: false,
itemCode: "avgRequests", itemCode: "nodeAvgRequests",
itemReportGroups: [], itemReportGroups: [],
itemOperator: "lte", itemOperator: "lte",
itemValue: "", itemValue: "",
itemDuration: 5, itemDuration: "5",
allItems: [ allItems: window.IP_ADDR_THRESHOLD_ITEMS,
{
"name": "平均请求数",
"code": "avgRequests",
"description": "在单位时间内接收到的平均请求数。",
"unit": "个"
},
{
"name": "平均下行流量",
"code": "avgTrafficOut",
"description": "在单位时间内发送的下行流量。",
"unit": "M"
},
{
"name": "平均上行流量",
"code": "avgTrafficIn",
"description": "在单位时间内接收的上行流量。",
"unit": "M"
},
{
"name": "连通性",
"code": "connectivity",
"description": "通过区域监控得到的连通性数值取值在0和100之间。",
"unit": "%"
},
],
allOperators: [ allOperators: [
{ {
"name": "小于等于", "name": "小于等于",
@@ -165,10 +140,10 @@ Vue.component("node-ip-address-thresholds-box", {
cancelItem: function () { cancelItem: function () {
this.isAddingItem = false this.isAddingItem = false
this.itemCode = "avgRequests" this.itemCode = "nodeAvgRequests"
this.itmeOperator = "lte" this.itmeOperator = "lte"
this.itemValue = "" this.itemValue = ""
this.itemDuration = "1" this.itemDuration = "5"
this.itemReportGroups = [] this.itemReportGroups = []
}, },
confirmItem: function () { confirmItem: function () {
@@ -393,7 +368,7 @@ Vue.component("node-ip-address-thresholds-box", {
<td style="background: white"> <td style="background: white">
<!-- 已经添加的项目 --> <!-- 已经添加的项目 -->
<div> <div>
<div v-for="(item, index) in addingThreshold.items" class="ui label basic small" style="margin-bottom: 0.5em; font-weight: normal"> <div v-for="(item, index) in addingThreshold.items" class="ui label basic small" style="margin-bottom: 0.5em;">
[{{item.duration}}{{itemDurationUnitName(item.durationUnit)}}] {{itemName(item.item)}} [{{item.duration}}{{itemDurationUnitName(item.durationUnit)}}] {{itemName(item.item)}}
<!-- 连通性 --> <!-- 连通性 -->
<span v-if="item.item == 'connectivity' && item.options != null && item.options.groups != null && item.options.groups.length > 0">[<span v-for="(group, groupIndex) in item.options.groups">{{group.name}} <span v-if="groupIndex != item.options.groups.length - 1">&nbsp; </span></span>]</span> <span v-if="item.item == 'connectivity' && item.options != null && item.options.groups != null && item.options.groups.length > 0">[<span v-for="(group, groupIndex) in item.options.groups">{{group.name}} <span v-if="groupIndex != item.options.groups.length - 1">&nbsp; </span></span>]</span>

View File

@@ -18,32 +18,7 @@ Vue.component("node-ip-address-thresholds-view", {
return { return {
thresholds: thresholds, thresholds: thresholds,
allItems: [ allItems: window.IP_ADDR_THRESHOLD_ITEMS,
{
"name": "平均请求数",
"code": "avgRequests",
"description": "在单位时间内接收到的平均请求数。",
"unit": "个"
},
{
"name": "平均下行流量",
"code": "avgTrafficOut",
"description": "在单位时间内发送的下行流量。",
"unit": "M"
},
{
"name": "平均上行流量",
"code": "avgTrafficIn",
"description": "在单位时间内接收的上行流量。",
"unit": "M"
},
{
"name": "连通性",
"code": "connectivity",
"description": "通过区域监控得到的连通性数值取值在0和100之间。",
"unit": "%"
},
],
allOperators: [ allOperators: [
{ {
"name": "小于等于", "name": "小于等于",

View File

@@ -22,7 +22,7 @@
<td style="text-align: center;"><i class="icon bars handle grey"></i> </td> <td style="text-align: center;"><i class="icon bars handle grey"></i> </td>
<td>{{group.name}}</td> <td>{{group.name}}</td>
<td class="center"> <td class="center">
<span v-if="group.countNodes > 0">{{group.countNodes}}</span> <a :href="'/clusters/cluster/nodes?clusterId=' + clusterId + '&groupId=' + group.id" v-if="group.countNodes > 0">{{group.countNodes}}</a>
<span v-else class="disabled">0</span> <span v-else class="disabled">0</span>
</td> </td>
<td> <td>

View File

@@ -1,10 +1,10 @@
<second-menu> <second-menu>
<menu-item :href="'/clusters/cluster/nodes?clusterId=' + clusterId">节点列表</menu-item> <a :href="'/clusters/cluster/nodes?clusterId=' + clusterId" class="item" style="padding-right: 0">{{currentClusterName}} &raquo;</a>
<span class="item disabled">|</span> <a :href="'/clusters/cluster/nodes?clusterId=' + clusterId + '&groupId=' + node.group.id" v-if="node.group != null" class="item" style="padding-left: 0"> &nbsp; {{node.group.name}} &raquo;</a>
<menu-item :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + node.id" code="node" <menu-item :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + node.id" code="node"
v-if="!teaIsPlus">"{{node.name}}"节点详情</menu-item> v-if="!teaIsPlus" style="padding-left: 0">"{{node.name}}"节点详情</menu-item>
<menu-item :href="'/clusters/cluster/node/boards?clusterId=' + clusterId + '&nodeId=' + node.id" code="board" v-if="teaIsPlus">"{{node.name}}" 节点看板</menu-item> <menu-item :href="'/clusters/cluster/node/boards?clusterId=' + clusterId + '&nodeId=' + node.id" code="board" v-if="teaIsPlus" style="padding-left: 0">"{{node.name}}" 节点看板</menu-item>
<menu-item :href="'/clusters/cluster/node/detail?clusterId=' + clusterId + '&nodeId=' + node.id" code="node" v-if="teaIsPlus">节点详情</menu-item> <menu-item :href="'/clusters/cluster/node/detail?clusterId=' + clusterId + '&nodeId=' + node.id" code="node" v-if="teaIsPlus" style="padding-left: 0">节点详情</menu-item>
<menu-item :href="'/clusters/cluster/node/logs?clusterId=' + clusterId + '&nodeId=' + node.id" code="log">运行日志</menu-item> <menu-item :href="'/clusters/cluster/node/logs?clusterId=' + clusterId + '&nodeId=' + node.id" code="log">运行日志</menu-item>
<menu-item :href="'/clusters/cluster/node/install?clusterId=' + clusterId + '&nodeId=' + node.id" code="install">安装节点</menu-item> <menu-item :href="'/clusters/cluster/node/install?clusterId=' + clusterId + '&nodeId=' + node.id" code="install">安装节点</menu-item>
<menu-item :href="'/clusters/cluster/node/update?clusterId=' + clusterId + '&nodeId=' + node.id" code="update">修改设置</menu-item> <menu-item :href="'/clusters/cluster/node/update?clusterId=' + clusterId + '&nodeId=' + node.id" code="update">修改设置</menu-item>

View File

@@ -68,10 +68,10 @@
<tr v-for="node in nodes"> <tr v-for="node in nodes">
<td><a :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + node.id">{{node.name}}</a> <td><a :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + node.id">{{node.name}}</a>
<div style="margin-top: 0.5em" v-if="node.region != null"> <div style="margin-top: 0.5em" v-if="node.region != null">
<tiny-basic-label class="olive">区域:{{node.region.name}}</tiny-basic-label> <span class="ui label tiny grey basic">区域:{{node.region.name}}</span>
</div> </div>
<div style="margin-top: 0.5em" v-if="node.group != null"> <div style="margin-top: 0.5em" v-if="node.group != null">
<tiny-basic-label class="olive">分组:{{node.group.name}}</tiny-basic-label> <span class="ui label tiny grey basic">分组:{{node.group.name}}</span>
</div> </div>
<div style="margin-top: 0.5em"> <div style="margin-top: 0.5em">
<node-clusters-labels :v-primary-cluster="node.cluster" :v-secondary-clusters="node.secondaryClusters" size="tiny"></node-clusters-labels> <node-clusters-labels :v-primary-cluster="node.cluster" :v-secondary-clusters="node.secondaryClusters" size="tiny"></node-clusters-labels>

View File

@@ -22,32 +22,27 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"><more-options-indicator></more-options-indicator></td> <td>是否启用</td>
<td>
<div class="ui checkbox">
<input type="checkbox" name="isOn" value="1" v-model="addr.isOn"/>
<label></label>
</div>
<p class="comment">选中表示当前IP有效。</p>
</td>
</tr>
<tr>
<td class="title">名称</td>
<td>
<input type="text" name="name" maxlength="50" v-model="addr.name"/>
</td>
</tr>
<tr v-if="teaIsPlus && supportThresholds">
<td>上线阈值</td>
<td>
<node-ip-address-thresholds-box :v-thresholds="addr.thresholds"></node-ip-address-thresholds-box>
</td>
</tr> </tr>
<tbody v-show="moreOptionsVisible">
<tr>
<td>是否启用</td>
<td>
<div class="ui checkbox">
<input type="checkbox" name="isOn" value="1" v-model="addr.isOn"/>
<label></label>
</div>
<p class="comment">选中表示当前IP有效。</p>
</td>
</tr>
<tr>
<td class="title">名称</td>
<td>
<input type="text" name="name" maxlength="50" v-model="addr.name"/>
</td>
</tr>
<tr v-if="teaIsPlus && supportThresholds">
<td>上线阈值</td>
<td>
<node-ip-address-thresholds-box :v-thresholds="addr.thresholds"></node-ip-address-thresholds-box>
</td>
</tr>
</tbody>
</table> </table>
<submit-btn></submit-btn> <submit-btn></submit-btn>
</form> </form>