mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2026-01-03 04:26:35 +08:00
优化错误提示
This commit is contained in:
@@ -81,13 +81,21 @@ func (this *HTTPRequestStatManager) Start() {
|
||||
for range loopTicker.C {
|
||||
err := this.Loop()
|
||||
if err != nil {
|
||||
remotelogs.Error("HTTP_REQUEST_STAT_MANAGER", err.Error())
|
||||
if rpc.IsConnError(err) {
|
||||
remotelogs.Warn("HTTP_REQUEST_STAT_MANAGER", err.Error())
|
||||
} else {
|
||||
remotelogs.Error("HTTP_REQUEST_STAT_MANAGER", err.Error())
|
||||
}
|
||||
}
|
||||
select {
|
||||
case <-uploadTicker.C:
|
||||
err := this.Upload()
|
||||
if err != nil {
|
||||
remotelogs.Error("HTTP_REQUEST_STAT_MANAGER", "upload failed: "+err.Error())
|
||||
if !rpc.IsConnError(err) {
|
||||
remotelogs.Error("HTTP_REQUEST_STAT_MANAGER", "upload failed: "+err.Error())
|
||||
} else {
|
||||
remotelogs.Warn("HTTP_REQUEST_STAT_MANAGER", "upload failed: "+err.Error())
|
||||
}
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -166,10 +174,10 @@ Loop:
|
||||
if iplibrary.SharedLibrary != nil {
|
||||
result, err := iplibrary.SharedLibrary.Lookup(ip)
|
||||
if err == nil && result != nil {
|
||||
this.cityMap[serverId+"@"+result.Country+"@"+result.Province+"@"+result.City] ++
|
||||
this.cityMap[serverId+"@"+result.Country+"@"+result.Province+"@"+result.City]++
|
||||
|
||||
if len(result.ISP) > 0 {
|
||||
this.providerMap[serverId+"@"+result.ISP] ++
|
||||
this.providerMap[serverId+"@"+result.ISP]++
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,7 +205,7 @@ Loop:
|
||||
if dotIndex > -1 {
|
||||
browserVersion = browserVersion[:dotIndex]
|
||||
}
|
||||
this.browserMap[serverId+"@"+browser+"@"+browserVersion] ++
|
||||
this.browserMap[serverId+"@"+browser+"@"+browserVersion]++
|
||||
}
|
||||
case firewallRuleGroupString := <-this.firewallRuleGroupChan:
|
||||
this.dailyFirewallRuleGroupMap[firewallRuleGroupString]++
|
||||
|
||||
@@ -26,6 +26,7 @@ type TrafficItem struct {
|
||||
CountCachedRequests int64
|
||||
CountAttackRequests int64
|
||||
AttackBytes int64
|
||||
PlanId int64
|
||||
CheckingTrafficLimit bool
|
||||
}
|
||||
|
||||
@@ -81,13 +82,17 @@ func (this *TrafficStatManager) Start(configFunc func() *nodeconfigs.NodeConfig)
|
||||
for range ticker.C {
|
||||
err := this.Upload()
|
||||
if err != nil {
|
||||
remotelogs.Error("TRAFFIC_STAT_MANAGER", "upload stats failed: "+err.Error())
|
||||
if !rpc.IsConnError(err) {
|
||||
remotelogs.Error("TRAFFIC_STAT_MANAGER", "upload stats failed: "+err.Error())
|
||||
} else {
|
||||
remotelogs.Warn("TRAFFIC_STAT_MANAGER", "upload stats failed: "+err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add 添加流量
|
||||
func (this *TrafficStatManager) Add(serverId int64, domain string, bytes int64, cachedBytes int64, countRequests int64, countCachedRequests int64, countAttacks int64, attackBytes int64, checkingTrafficLimit bool) {
|
||||
func (this *TrafficStatManager) Add(serverId int64, domain string, bytes int64, cachedBytes int64, countRequests int64, countCachedRequests int64, countAttacks int64, attackBytes int64, checkingTrafficLimit bool, planId int64) {
|
||||
if bytes == 0 && countRequests == 0 {
|
||||
return
|
||||
}
|
||||
@@ -112,6 +117,7 @@ func (this *TrafficStatManager) Add(serverId int64, domain string, bytes int64,
|
||||
item.CountAttackRequests += countAttacks
|
||||
item.AttackBytes += attackBytes
|
||||
item.CheckingTrafficLimit = checkingTrafficLimit
|
||||
item.PlanId = planId
|
||||
|
||||
// 单个域名流量
|
||||
var domainKey = strconv.FormatInt(timestamp, 10) + "@" + strconv.FormatInt(serverId, 10) + "@" + domain
|
||||
@@ -171,6 +177,7 @@ func (this *TrafficStatManager) Upload() error {
|
||||
CountAttackRequests: item.CountAttackRequests,
|
||||
AttackBytes: item.AttackBytes,
|
||||
CheckTrafficLimiting: item.CheckingTrafficLimit,
|
||||
PlanId: item.PlanId,
|
||||
CreatedAt: timestamp,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user