stat

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

README

// common key const ( STAT_IN = "MsgIn" STAT_OUT = "MsgOut" INDEGREE_Recive = "InDegree_Recive(MB)" INDEGREE_Send = "InDegree_Send(MB)" OUTDEGREE_Recive = "OutDegree_Recive(MB)" OUTDEGREE_Send = "OutDegree_Send(MB)"

)

// application key const ( StatRedisGet = "StatRedisGet" )

// base initialize logconfig := make(stat.LoggerParm) logconfig.level = "info" logconfig.path = "./stat" logconfig.namePrefix = "test" logconfig.filename = "stat.log" logconfig.maxfilesize = 10000 logconfig.maxdays = 7 logconfig.maxlines = 10000 logconfig.chanlen = 10000 stat.Init(logconfig, 60) stat.StatProc()

// application initialize stat.SetDelayUp(20,50,100)

// using method add stat data stat.Push(elem)

// exit must call stat.Exit()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exit

func Exit()

Exit 推出统计

func GetTopn

func GetTopn(rawdata map[int]uint, topn int) (arraykeys []int)

func Init

func Init(appName, fileName string)

Init 初始化调用,线程不安全

func PushStat

func PushStat(itemName string, procTime int, requestIP net.IP, payload int, retcode int)

PushStat 把函数统计输入统计

func SetDelayUp

func SetDelayUp(delayUp uint, delayUp2 uint, delayUp3 uint)

SetDelayUp 设置分段统计延时 初始化调用,线程不安全

func StatProc

func StatProc()

Proc 统计统一处理函数

Types

type Inter

type Inter interface {
	AddReportHeadItem(itemName string)
	AddReportBodyRowItem(itemName string)
	AddReportBodyColItem(itemName string)
	AddReportTailItem(itemName string)
	AddReportErrorItem(itemName string)
	AddReportIPError()

	IncStat(itemName string, val uint)
	IncKey(itemName string)
	IncStatByTab(rowName string, colName string, val uint)
	IncErrnoStat(errno int, val uint)
	IncErrnoStatByItem(itemName string, errno int, val uint)
	IncErrnoIP(ip uint, errno int, val uint)

	SetStat(itemName string, val uint)
	GetStat(itemName string) int
	GetStatValueByTab(itemName string, colName string)
	TimeStatGet(rowName string) (count uint, avgDelay float32, maxDelay float32, upDelay uint, upDelay2 uint, upDelay3 uint)

	NoCheckAndPrint()
	Print()
	PrintHeader()
	PrintBody()
	PrintTail()
	PrintRowError()
	PrintIPError()

	ClearAll()

	Reset()
}

Inter 统计接口

type Item

type Item struct {
	Name      string // 统计的接口名
	Delay     uint   // 接口执行的延时,单位ms
	Errcode   int    // 当次接口请求的错误码,0--成功`
	Ipsrc     net.IP // 请求的来源ip
	Payload   uint   // 请求的载荷
	Direction int    // 上行or下行    1 ---- 上行   0 ----下行
	InOrOut   int    // 入度还是出度   1 ---- in  0 ----out
}

Item 统一单元元素

type Mystat

type Mystat struct {
	IsClearFlag bool // 清除标记
	// contains filtered or unexported fields
}

Mystat 监控统计对象

var GStat *Mystat

GStat 全局唯一统计对象

func (*Mystat) AddReportBodyColItem

func (stat *Mystat) AddReportBodyColItem(itemName string)

AddReportBodyColItem 添加监控报告主体列元素

func (*Mystat) AddReportBodyRowItem

func (stat *Mystat) AddReportBodyRowItem(itemName string)

AddReportBodyRowItem 添加监控报告主体行元素

func (*Mystat) AddReportErrorItem

func (stat *Mystat) AddReportErrorItem(itemName string)

AddReportErrorItem 添加监控报告错误元素

func (*Mystat) AddReportHeadItem

func (stat *Mystat) AddReportHeadItem(itemName string)

AddReportHeadItem 添加监控报告头部元素

func (*Mystat) AddReportIPError

func (stat *Mystat) AddReportIPError()

AddReportIPError 添加监控报告IP地址错误

func (*Mystat) AddReportTailItem

func (stat *Mystat) AddReportTailItem(itemName string)

AddReportTailItem 添加监控报告尾部元素

func (*Mystat) ClearAll

func (stat *Mystat) ClearAll()

ClearAll 清空计数

func (*Mystat) GetStat

func (stat *Mystat) GetStat(itemName string) uint

GetStat 获取单位元素计数

func (*Mystat) GetStatValueByTab

func (stat *Mystat) GetStatValueByTab(itemName string, colName string) uint

GetStatValueByTab 获取列元素的值

func (*Mystat) GetTimeout

func (stat *Mystat) GetTimeout(itemName string) uint

GetTimeout 获取单位元素超时计数

func (*Mystat) IncErrnoIP

func (stat *Mystat) IncErrnoIP(ip net.IP, errno int, val uint)

IncErrnoIP 增加错误IP计数

func (*Mystat) IncErrnoStat

func (stat *Mystat) IncErrnoStat(errno int, val uint)

IncErrnoStat 增加错误计数

func (*Mystat) IncErrnoStatByItem

func (stat *Mystat) IncErrnoStatByItem(itemName string, errno int, val uint)

IncErrnoStatByItem 增加单位元素错误计数

func (*Mystat) IncKey

func (stat *Mystat) IncKey(itemName string)

IncKey 增加主体数据单位元素统计

func (*Mystat) IncStat

func (stat *Mystat) IncStat(itemName string, val uint)

IncStat 增加主体数据单位元素列统计

func (*Mystat) IncStatByTab

func (stat *Mystat) IncStatByTab(rowName string, colName string, val uint)

IncStatByTab 增加主体数据单位元素列统计

func (*Mystat) IncTimeout

func (stat *Mystat) IncTimeout(itemName string)

IncTimeout 增加单位元素超时计数

func (*Mystat) NoCheckAndPrint

func (stat *Mystat) NoCheckAndPrint()

NoCheckAndPrint 清空缓存并打印

func (*Mystat) Print

func (stat *Mystat) Print()

Print 打印

func (*Mystat) PrintBody

func (stat *Mystat) PrintBody()

PrintBody 打印主体数据

func (*Mystat) PrintHeader

func (stat *Mystat) PrintHeader()

PrintHeader 打印头部

func (*Mystat) PrintIPError

func (stat *Mystat) PrintIPError()

PrintIPError 打印IP错误

func (*Mystat) PrintRowError

func (stat *Mystat) PrintRowError()

PrintRowError 打印行错误

func (*Mystat) PrintTail

func (stat *Mystat) PrintTail()

PrintTail 打印尾部

func (*Mystat) Reset

func (stat *Mystat) Reset()

Reset 重置计数

func (*Mystat) SetStat

func (stat *Mystat) SetStat(itemName string, val uint)

SetStat 设置主体数据单位元素列统计值

func (*Mystat) SetTimeOut

func (stat *Mystat) SetTimeOut(timeout uint)

SetTimeOut 设置客户端请求超时时间 初始化调用,线程不安全 和delayup参数意义相同, 起一个分段作用,只不过是最大分段

func (*Mystat) TimeStatGet

func (stat *Mystat) TimeStatGet(rowName string) (count uint, avgDelay, maxDelay float32, upDelay, upDelay2, upDelay3, upDelay4 uint)

TimeStatGet 单位时间内的计数获取

Jump to

Keyboard shortcuts

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