mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-01-06 03:55:48 +08:00
实现WAF统计
This commit is contained in:
@@ -16,6 +16,7 @@ func init() {
|
||||
Get("", new(IndexAction)).
|
||||
Get("/providers", new(ProvidersAction)).
|
||||
Get("/clients", new(ClientsAction)).
|
||||
Get("/waf", new(WafAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
|
||||
78
internal/web/actions/default/servers/server/stat/waf.go
Normal file
78
internal/web/actions/default/servers/server/stat/waf.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package stat
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||
)
|
||||
|
||||
type WafAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *WafAction) Init() {
|
||||
this.Nav("", "stat", "")
|
||||
this.SecondMenu("waf")
|
||||
}
|
||||
|
||||
func (this *WafAction) RunGet(params struct {
|
||||
ServerId int64
|
||||
}) {
|
||||
// 统计数据
|
||||
resp, err := this.RPC().ServerHTTPFirewallDailyStatRPC().ComposeServerHTTPFirewallDashboard(this.AdminContext(), &pb.ComposeServerHTTPFirewallDashboardRequest{
|
||||
Day: timeutil.Format("Ymd"),
|
||||
ServerId: params.ServerId,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["countDailyLog"] = resp.CountDailyLog
|
||||
this.Data["countDailyBlock"] = resp.CountDailyBlock
|
||||
this.Data["countDailyCaptcha"] = resp.CountDailyCaptcha
|
||||
this.Data["countWeeklyBlock"] = resp.CountWeeklyBlock
|
||||
this.Data["countMonthlyBlock"] = resp.CountMonthlyBlock
|
||||
|
||||
// 分组
|
||||
groupStatMaps := []maps.Map{}
|
||||
for _, group := range resp.HttpFirewallRuleGroups {
|
||||
groupStatMaps = append(groupStatMaps, maps.Map{
|
||||
"group": maps.Map{
|
||||
"id": group.HttpFirewallRuleGroup.Id,
|
||||
"name": group.HttpFirewallRuleGroup.Name,
|
||||
},
|
||||
"count": group.Count,
|
||||
})
|
||||
}
|
||||
this.Data["groupStats"] = groupStatMaps
|
||||
|
||||
// 每日趋势
|
||||
logStatMaps := []maps.Map{}
|
||||
blockStatMaps := []maps.Map{}
|
||||
captchaStatMaps := []maps.Map{}
|
||||
for _, stat := range resp.LogDailyStats {
|
||||
logStatMaps = append(logStatMaps, maps.Map{
|
||||
"day": stat.Day,
|
||||
"count": stat.Count,
|
||||
})
|
||||
}
|
||||
for _, stat := range resp.BlockDailyStats {
|
||||
blockStatMaps = append(blockStatMaps, maps.Map{
|
||||
"day": stat.Day,
|
||||
"count": stat.Count,
|
||||
})
|
||||
}
|
||||
for _, stat := range resp.CaptchaDailyStats {
|
||||
captchaStatMaps = append(captchaStatMaps, maps.Map{
|
||||
"day": stat.Day,
|
||||
"count": stat.Count,
|
||||
})
|
||||
}
|
||||
this.Data["logDailyStats"] = logStatMaps
|
||||
this.Data["blockDailyStats"] = blockStatMaps
|
||||
this.Data["captchaDailyStats"] = captchaStatMaps
|
||||
|
||||
this.Show()
|
||||
}
|
||||
Reference in New Issue
Block a user