stats

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RtspConns = NewConns() // RTSP连接统计
	FlvConns  = NewConns() // flv连接统计
)

全局变量

View Source
var (
	StartingTime = time.Now()
)

创建时间

Functions

This section is empty.

Types

type Conns

type Conns interface {
	Add() int64
	Release() int64
	GetSample() ConnsSample
}

Conns 连接统计

func NewConns

func NewConns() Conns

NewConns 新建连接计数

type ConnsSample

type ConnsSample struct {
	Total  int64 `json:"total"`
	Active int64 `json:"active"`
}

ConnsSample 连接计数采样

type Flow

type Flow interface {
	AddIn(size int64)      // 增加输入
	AddOut(size int64)     // 增加输出
	GetSample() FlowSample // 获取当前时点采样
}

Flow 流统计接口

func NewChildFlow

func NewChildFlow(parent Flow) Flow

NewChildFlow 创建子流量计数,它会把自己的计数Add到parent上

func NewFlow

func NewFlow() Flow

NewFlow 创建流量统计

type FlowSample

type FlowSample struct {
	InBytes  int64 `json:"inbytes"`
	OutBytes int64 `json:"outbytes"`
}

FlowSample 流统计采样

func (*FlowSample) Add

func (fs *FlowSample) Add(f FlowSample)

Add 采样累加

type GC

type GC struct {
	CPU float64 `json:"cpu"` // cpu使用情况
	Sys int32   `json:"sys"` // KB MemStats.GCSys
}

GC 垃圾回收信息

type Go

type Go struct {
	Count int32 `json:"count"` // runtime.NumGoroutine()
	Procs int32 `json:"procs"` //runtime.NumCPU()
	Sys   int32 `json:"sys"`   // KB MemStats.Sys
	Alloc int32 `json:"alloc"` // KB MemStats.TotalAlloc
}

Go Go运行时 goroutines 、threads 和 total memory

type Heap

type Heap struct {
	Inuse    int32 `json:"inuse"`    // KB MemStats.HeapInuse
	Sys      int32 `json:"sys"`      // KB MemStats.HeapSys
	Alloc    int32 `json:"alloc"`    // KB MemStats.HeapAlloc
	Idle     int32 `json:"idle"`     // KB MemStats.HeapIdle
	Released int32 `json:"released"` // KB MemStats.HeapReleased
	Objects  int32 `json:"objects"`  // = MemStats.HeapObjects
}

Heap 运行是堆信息

type Memory

type Memory struct {
	Inuse int32 `json:"inuse"` // KB
	Sys   int32 `json:"sys"`   // KB
}

Memory 通用内存信息

type Proc

type Proc struct {
	CPU    float64 `json:"cpu"`    // cpu使用情况
	Priv   int32   `json:"priv"`   // 私有内存 KB
	Virt   int32   `json:"virt"`   // 虚拟内存 KB
	Uptime int32   `json:"uptime"` // 运行时间 S
}

Proc 进程信息统计

func MeasureRuntime

func MeasureRuntime() Proc

MeasureRuntime 获取运行时信息。

type Runtime

type Runtime struct {
	Heap   Heap   `json:"heap"`
	MCache Memory `json:"mcache"` // MemStats.MCacheInuse/MCacheSys
	MSpan  Memory `json:"mspan"`  // MemStats.MSpanInuse/MSpanSys
	Stack  Memory `json:"stack"`  // MemStats.StackInuse/StackSys
	GC     GC     `json:"gc"`
	Go     Go     `json:"go"`
}

Runtime 运行时统计

func MeasureFullRuntime

func MeasureFullRuntime() *Runtime

MeasureFullRuntime 获取运行时信息。

Jump to

Keyboard shortcuts

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