stats

package
v1.3.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2024 License: BSD-3-Clause Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SharedBandwidthStatManager = NewBandwidthStatManager()
View Source
var SharedDAUManager = NewDAUManager()
View Source
var SharedHTTPRequestStatManager = NewHTTPRequestStatManager()
View Source
var SharedTrafficStatManager = NewTrafficStatManager()
View Source
var SharedUserAgentParser = NewUserAgentParser()

Functions

This section is empty.

Types

type BandwidthStat added in v0.4.9

type BandwidthStat struct {
	Day      string `json:"day"`
	TimeAt   string `json:"timeAt"`
	UserId   int64  `json:"userId"`
	ServerId int64  `json:"serverId"`

	CurrentBytes     int64 `json:"currentBytes"`
	CurrentTimestamp int64 `json:"currentTimestamp"`
	MaxBytes         int64 `json:"maxBytes"`
	TotalBytes       int64 `json:"totalBytes"`

	CachedBytes               int64 `json:"cachedBytes"`
	AttackBytes               int64 `json:"attackBytes"`
	CountRequests             int64 `json:"countRequests"`
	CountCachedRequests       int64 `json:"countCachedRequests"`
	CountAttackRequests       int64 `json:"countAttackRequests"`
	CountWebsocketConnections int64 `json:"countWebsocketConnections"`
	UserPlanId                int64 `json:"userPlanId"`
}

type BandwidthStatManager added in v0.4.9

type BandwidthStatManager struct {
	// contains filtered or unexported fields
}

BandwidthStatManager 服务带宽统计

func NewBandwidthStatManager added in v0.4.9

func NewBandwidthStatManager() *BandwidthStatManager

func (*BandwidthStatManager) AddBandwidth added in v1.0.0

func (this *BandwidthStatManager) AddBandwidth(userId int64, userPlanId int64, serverId int64, peekBytes int64, totalBytes int64)

AddBandwidth 添加带宽数据

func (*BandwidthStatManager) AddTraffic added in v1.0.0

func (this *BandwidthStatManager) AddTraffic(serverId int64, cachedBytes int64, countRequests int64, countCachedRequests int64, countAttacks int64, attackBytes int64, countWebsocketConnections int64)

AddTraffic 添加请求数据

func (*BandwidthStatManager) Cancel added in v1.0.0

func (this *BandwidthStatManager) Cancel()

Cancel 取消上传

func (*BandwidthStatManager) Inspect added in v0.4.9

func (this *BandwidthStatManager) Inspect()

func (*BandwidthStatManager) Loop added in v0.4.9

func (this *BandwidthStatManager) Loop() error

func (*BandwidthStatManager) Map added in v0.5.2

func (this *BandwidthStatManager) Map() map[int64]int64

func (*BandwidthStatManager) Save added in v1.0.0

func (this *BandwidthStatManager) Save() error

Save 保存到本地磁盘

func (*BandwidthStatManager) Start added in v0.4.9

func (this *BandwidthStatManager) Start()

type DAUManager added in v1.3.5

type DAUManager struct {
	// contains filtered or unexported fields
}

func NewDAUManager added in v1.3.5

func NewDAUManager() *DAUManager

NewDAUManager DAU计算器

func (*DAUManager) AddIP added in v1.3.5

func (this *DAUManager) AddIP(serverId int64, ip string)

func (*DAUManager) CleanStats added in v1.3.5

func (this *DAUManager) CleanStats() error

func (*DAUManager) Close added in v1.3.5

func (this *DAUManager) Close() error

func (*DAUManager) Flush added in v1.3.5

func (this *DAUManager) Flush() error

func (*DAUManager) Init added in v1.3.5

func (this *DAUManager) Init() error

func (*DAUManager) ReadStatMap added in v1.3.5

func (this *DAUManager) ReadStatMap() map[string]int64

func (*DAUManager) TestInspect added in v1.3.5

func (this *DAUManager) TestInspect(t *testing.T)

func (*DAUManager) Truncate added in v1.3.5

func (this *DAUManager) Truncate() error

type HTTPRequestStatManager

type HTTPRequestStatManager struct {
	// contains filtered or unexported fields
}

HTTPRequestStatManager HTTP请求相关的统计 这里的统计是一个辅助统计,注意不要因为统计而影响服务工作性能

func NewHTTPRequestStatManager

func NewHTTPRequestStatManager() *HTTPRequestStatManager

NewHTTPRequestStatManager 获取新对象

func (*HTTPRequestStatManager) AddFirewallRuleGroupId

func (this *HTTPRequestStatManager) AddFirewallRuleGroupId(serverId int64, firewallRuleGroupId int64, actions []*waf.ActionConfig)

AddFirewallRuleGroupId 添加防火墙拦截动作

func (*HTTPRequestStatManager) AddRemoteAddr

func (this *HTTPRequestStatManager) AddRemoteAddr(serverId int64, remoteAddr string, bytes int64, isAttack bool)

AddRemoteAddr 添加客户端地址

func (*HTTPRequestStatManager) AddUserAgent

func (this *HTTPRequestStatManager) AddUserAgent(serverId int64, userAgent string, ip string)

AddUserAgent 添加UserAgent

func (*HTTPRequestStatManager) Loop

func (this *HTTPRequestStatManager) Loop() error

Loop 单个循环

func (*HTTPRequestStatManager) Start

func (this *HTTPRequestStatManager) Start()

Start 启动

func (*HTTPRequestStatManager) Upload

func (this *HTTPRequestStatManager) Upload() error

Upload 上传数据

type IPInfo added in v1.3.5

type IPInfo struct {
	IP       string
	ServerId int64
}

type StatItem

type StatItem struct {
	Bytes               int64
	CountRequests       int64
	CountAttackRequests int64
	AttackBytes         int64
}

type TrafficItem

type TrafficItem struct {
	UserId               int64
	Bytes                int64
	CachedBytes          int64
	CountRequests        int64
	CountCachedRequests  int64
	CountAttackRequests  int64
	AttackBytes          int64
	PlanId               int64
	CheckingTrafficLimit bool
}

func (*TrafficItem) Add added in v0.5.6

func (this *TrafficItem) Add(anotherItem *TrafficItem)

type TrafficStatManager

type TrafficStatManager struct {
	// contains filtered or unexported fields
}

TrafficStatManager 区域流量统计

func NewTrafficStatManager

func NewTrafficStatManager() *TrafficStatManager

NewTrafficStatManager 获取新对象

func (*TrafficStatManager) Add

func (this *TrafficStatManager) Add(userId int64, serverId int64, domain string, bytes int64, cachedBytes int64, countRequests int64, countCachedRequests int64, countAttacks int64, attackBytes int64, countWebsocketConnections int64, checkingTrafficLimit bool, planId int64)

Add 添加流量

func (*TrafficStatManager) Start

func (this *TrafficStatManager) Start()

Start 启动自动任务

func (*TrafficStatManager) Upload

func (this *TrafficStatManager) Upload() error

Upload 上传流量

type UserAgentParser

type UserAgentParser struct {
	// contains filtered or unexported fields
}

UserAgentParser UserAgent解析器

func NewUserAgentParser

func NewUserAgentParser() *UserAgentParser

NewUserAgentParser 获取新解析器

func (*UserAgentParser) GC added in v1.3.3

func (this *UserAgentParser) GC()

GC 回收多余的缓存

func (*UserAgentParser) Len added in v1.3.3

func (this *UserAgentParser) Len() int

Len 读取当前缓存数量

func (*UserAgentParser) MaxCacheItems added in v1.3.3

func (this *UserAgentParser) MaxCacheItems() int

MaxCacheItems 读取能容纳的缓存最大数量

func (*UserAgentParser) Parse

func (this *UserAgentParser) Parse(userAgent string) (result UserAgentParserResult)

Parse 解析UserAgent

type UserAgentParserResult

type UserAgentParserResult struct {
	OS             useragent.OSInfo
	BrowserName    string
	BrowserVersion string
	IsMobile       bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL