Skip to content

Commit

Permalink
fix : waf多层级不展示数据
Browse files Browse the repository at this point in the history
fix : 移除节点层级waf统计数据
feat: 事务日程调整
  • Loading branch information
iamtsm committed Aug 2, 2022
1 parent e7650a3 commit c326a6d
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 41 deletions.
11 changes: 1 addition & 10 deletions api/router/tl_ops_api_get_state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ local Router = function()
health_uncheck = health_uncheck_cache,
limit_state = limit_state_cache,
limit_version = limit_version_cache,
waf_success = waf_success_cache_service
waf_success = cjson.decode(waf_success_cache_service)
}
cache_state.service[service_name].nodes = { }

Expand Down Expand Up @@ -163,13 +163,6 @@ local Router = function()
balance_success_cache = "{}"
end

local waf_count_name_node = "tl-ops-waf-count-" .. tl_ops_constant_waf.count.interval;
local waf_cache_count_node = require("cache.tl_ops_cache_core"):new(waf_count_name_node);
local waf_success_cache_node = waf_cache_count_node:get001(tl_ops_utils_func:gen_node_key(tl_ops_constant_waf.cache_key.waf_interval_success, node.service, node_id))
if not waf_success_cache_node then
waf_success_cache_node = "{}"
end

cache_state.service[service_name].nodes[node.name] = {
health_state = health_node_state_cache,
health_failed = health_node_failed_cache,
Expand All @@ -183,12 +176,10 @@ local Router = function()
limit_pre_time = limit_pre_time,
limit_bucket = limit_bucket,
balance_success = cjson.decode(balance_success_cache),
waf_success = cjson.decode(waf_success_cache_node),
}
end
end


-- 健康检查相关状态
local health_options_str, _ = cache_health:get(tl_ops_constant_health.cache_key.options_list);
if not health_options_str or health_options_str == nil then
Expand Down
7 changes: 3 additions & 4 deletions web/console/tl_ops_web_console.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@
<div class="layui-col-sm6">
<div class="layui-card" style="border-radius: 24px;">
<div class="layui-card-header">
{{# if(service.type !== 'waf') { }}
<span class="layui-badge layui-bg-blue">{{service.id}}服务</span>

{{# } }}

{{# if(service.type === 'balance') { }}
<div style="float: right;" class="layui-form">
<span class="layui-badge layui-bg-blue " style="padding: 4px 14px 4px 14px;cursor: pointer;">当天</span>
Expand All @@ -166,7 +168,6 @@
</div>
{{# } }}


{{# if(service.type === 'health') { }}
<div style="float: right;" class="layui-form">
{{# if(service.uncheck === false) { }}
Expand All @@ -181,7 +182,6 @@
</div>
{{# } }}


{{# if(service.type === 'waf') { }}
<div style="float: right;" class="layui-form">
<span class="layui-badge layui-bg-blue " style="padding: 4px 14px 4px 14px;cursor: pointer;">当天</span>
Expand All @@ -192,7 +192,6 @@
</div>
{{# } }}


</div>
<div class="layui-card-body">
<div style="height:300px;" id="{{service.id}}"> </div>
Expand Down
91 changes: 64 additions & 27 deletions web/console/tl_ops_web_console.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,43 +503,75 @@ const tl_ops_web_console_waf_time_list_caculate_days = function (data) {
for (let key in data) {
let waf_count = 0; //服务总量统计
let seriesWafList = [];
let nodes = data[key].nodes;
for (let skey in nodes) {
let wafSuccessList = nodes[skey].waf_success;

for (let time in wafSuccessList) {
let count = wafSuccessList[time];
waf_count += count;
}
let wafSuccessList = data[key].waf_success;

let dayTimeCountList = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] //节点总量统计
for (let timeItem in wafSuccessList) {
let count = wafSuccessList[timeItem];
let day = timeItem.toString().split(" ")[0]
let time = timeItem.toString().split(" ")[1]
let hours = parseInt(time.split(":")[0])
let cur_day = getDateStr(0);
for (let time in wafSuccessList) {
let count = wafSuccessList[time];
waf_count += count;
}

//当天内
if (day.includes(cur_day)) {
let dayTimeCountIndex = parseInt((hours % 2) === 0 ? (hours / 2) : (hours / 2) + 1) - 1;
dayTimeCountList[dayTimeCountIndex] += count
}
let dayTimeCountList = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] //总量统计
for (let timeItem in wafSuccessList) {
let count = wafSuccessList[timeItem];
let day = timeItem.toString().split(" ")[0]
let time = timeItem.toString().split(" ")[1]
let hours = parseInt(time.split(":")[0])
let cur_day = getDateStr(0);

//当天内
if (day.includes(cur_day)) {
let dayTimeCountIndex = parseInt((hours % 2) === 0 ? (hours / 2) : (hours / 2) + 1) - 1;
dayTimeCountList[dayTimeCountIndex] += count
}
seriesWafList.push({
name: skey,
type: 'line',
yAxisIndex: 0,
data: dayTimeCountList,
})
}
seriesWafList.push({
name: key+"-服务层级",
type: 'line',
yAxisIndex: 0,
data: dayTimeCountList,
})
config.push({
id: key,
waf_count: waf_count,
seriesWafList: seriesWafList,
timeList: ['1点', '3点', '5点', '7点', '9点', '11点', '13点', '15点', '17点', '19点', '21点', '23点']
})
}

//全局统计
let waf_count = 0;
let wafSuccessList = res_data.waf.waf_success;
for (let time in wafSuccessList) {
let count = wafSuccessList[time];
waf_count += count;
}
let dayTimeCountList = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] //总量统计
for (let timeItem in wafSuccessList) {
let count = wafSuccessList[timeItem];
let day = timeItem.toString().split(" ")[0]
let time = timeItem.toString().split(" ")[1]
let hours = parseInt(time.split(":")[0])
let cur_day = getDateStr(0);

//当天内
if (day.includes(cur_day)) {
let dayTimeCountIndex = parseInt((hours % 2) === 0 ? (hours / 2) : (hours / 2) + 1) - 1;
dayTimeCountList[dayTimeCountIndex] += count
}
}
let seriesWafList = [{
name: "全局层级",
type: 'line',
yAxisIndex: 0,
data: dayTimeCountList,
}]
config.push({
id: "全局层级",
waf_count: waf_count,
seriesWafList: seriesWafList,
timeList: ['1点', '3点', '5点', '7点', '9点', '11点', '13点', '15点', '17点', '19点', '21点', '23点']
})

return config
}

Expand Down Expand Up @@ -568,6 +600,11 @@ const tl_ops_web_console_echarts_waf_render = function (data) {
}
serviceList = serviceList.sort(function(a, b){return a.id.localeCompare(b.id,'zh-CN')})

serviceList.unshift({
id : "全局层级",
type : 'waf',
})

laytpl(document.getElementById(_console_echarts_tlp_id_name).innerHTML).render((() => {
return serviceList
})(), (html) => {
Expand Down Expand Up @@ -1143,5 +1180,5 @@ function getDateStr(day) {
let y = cur.getFullYear();
let m = cur.getMonth() + 1;
let d = cur.getDate();
return y + '-' + (m < 10 ? '0' + m : m) + '-' + d;
return y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d);
}

0 comments on commit c326a6d

Please sign in to comment.