/
ip_all_period.go
57 lines (48 loc) · 1.06 KB
/
ip_all_period.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package teastats
import (
"github.com/TeaWeb/code/tealogs/accesslogs"
"github.com/iwind/TeaGo/logs"
"github.com/iwind/TeaGo/maps"
"strings"
)
// IP统计
type IPAllPeriodFilter struct {
CounterFilter
}
func (this *IPAllPeriodFilter) Name() string {
return "IP统计"
}
func (this *IPAllPeriodFilter) Codes() []string {
return []string{
"ip.all.second",
"ip.all.minute",
"ip.all.hour",
"ip.all.day",
"ip.all.week",
"ip.all.month",
"ip.all.year",
}
}
func (this *IPAllPeriodFilter) Indexes() []string {
return []string{}
}
func (this *IPAllPeriodFilter) Start(queue *Queue, code string) {
if queue == nil {
logs.Println("stat queue should be specified for '" + code + "'")
return
}
this.queue = queue
this.queue.Index(this.Indexes())
this.StartFilter(code, code[strings.LastIndex(code, ".")+1:])
}
func (this *IPAllPeriodFilter) Filter(accessLog *accesslogs.AccessLog) {
if !this.CheckNewIP(accessLog, "") {
return
}
this.ApplyFilter(accessLog, nil, maps.Map{
"count": 1,
})
}
func (this *IPAllPeriodFilter) Stop() {
this.StopFilter()
}