system

package
v1.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: May 23, 2017 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

获取系统运行状态信息

Index

Constants

View Source
const (
	ACTIVE   = "active"
	UNACTIVE = "unactive"
)
View Source
const (
	UNACTIVE_TIMEOUT = 5 //unactive seconds
)

Variables

This section is empty.

Functions

func SysInfo

func SysInfo(runMode, cluster string) string

获取系统信息 返回json

Types

type HostInfo

type HostInfo struct {
	Info       *SystemInfo // info
	Status     string      //active noactive
	LastActive int64
}

服务器信息

type HostInfoTable

type HostInfoTable struct {
	HostsInfo cache.Cacher
	//active router
	ActiveHostList *HostList
	//active host weight list,sorted by weight
	ActiveHostWeightList *list.List
}

host info list

func NewHostInfoTable

func NewHostInfoTable() *HostInfoTable

新创建主机信息存储

func (*HostInfoTable) CalcHostWeight

func (self *HostInfoTable) CalcHostWeight(hostInfo *HostInfo)

calc host weight 根据服务器负载状态 计算 权重 cpu 0 1 2 3 load 0 1 2 3 mem 0 1 2 3

func (*HostInfoTable) DumpInfo

func (self *HostInfoTable) DumpInfo()

dump挂载的服务器列表

func (*HostInfoTable) DumpSortedByWeightInfo

func (self *HostInfoTable) DumpSortedByWeightInfo()

打印根据权重排序后的服务器信息

func (*HostInfoTable) GetHostInfo

func (self *HostInfoTable) GetHostInfo(ip string) *HostInfo

获取服务器信息 如果服务器存在的话 初始化服务器信息是null 初始化服务器是status 是 noactive 活跃是 active

func (*HostInfoTable) HostInfoSortList

func (self *HostInfoTable) HostInfoSortList(hostinfo HostInfo) (*list.Element, bool)

主机是否在排序列表中 根据ip对比

func (*HostInfoTable) InsertSortHostWeight

func (self *HostInfoTable) InsertSortHostWeight(hostinfo HostInfo)

根据权重对主机进行排序 只有权重改变的主机才进行排序

func (*HostInfoTable) UpdateHostStatus

func (self *HostInfoTable) UpdateHostStatus()

update host table status

func (*HostInfoTable) UpdateHostTable

func (self *HostInfoTable) UpdateHostTable(ip string, info *SystemInfo)

更新服务器状态 不存在插入 存在更新

type HostList

type HostList struct {
	ActiveHostInfo cache.Cacher
	// contains filtered or unexported fields
}

active ROUTER LIST

func NewHostList

func NewHostList() *HostList

新创建主机信息存储

func (*HostList) DumpInfo

func (self *HostList) DumpInfo()

dump

func (*HostList) UpdateHostList

func (self *HostList) UpdateHostList(pHostInfo *HostInfo)

更新host状态 移除unactive主机

type HttpProxyStatistics

type HttpProxyStatistics struct {
	Timestamp    int64 //时间戳
	RequestCount int64 //all请求次数
}

http 反向代理请求统计

type StatisticsMap

type StatisticsMap map[string][]*HttpProxyStatistics

http请求分析

type SysHttpStatistics

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

func NewSysHttpStatistics

func NewSysHttpStatistics() *SysHttpStatistics

CREATE SYSHTTPSTATISTICS

func (*SysHttpStatistics) GetStatisticsList

func (self *SysHttpStatistics) GetStatisticsList() StatisticsMap

获取统计列表

func (*SysHttpStatistics) ResetData

func (self *SysHttpStatistics) ResetData()

清空当天的请求统计日志 并且清空内存

func (*SysHttpStatistics) SaveDataLog

func (self *SysHttpStatistics) SaveDataLog()

存储当天的统计数据到json日志 或者数据库中

func (*SysHttpStatistics) UpdateClusterStatistics

func (self *SysHttpStatistics) UpdateClusterStatistics(cluster string, updateType int)

更新集群请求统计 cluster 集群名称 updateType 0 分别代表请求更新,只增加请求次数 1 时间段更新,添加新的时间段统计。

type SystemInfo

type SystemInfo struct {
	VM      *mem.VirtualMemoryStat `json:"VM"`      //虚拟内存
	LD      *load.LoadAvgStat      `json:"LD"`      //load average
	DISK    *disk.DiskUsageStat    `json:"DISK"`    //dis
	HOST    *host.HostInfoStat     `json:"HOST"`    //host
	Cluster string                 `json:"Cluster"` //集群分组
	RunMode string                 `json:"RunMode"` //runmode
	Domain  string                 `json:"Domain"`  //domain
	IP      string                 `json:"IP"`
	CpuNums int                    `json:"CpuNums"` //cpu number
	Weight  int                    ///host weight
	//CPUS     []cpu.CPUInfoStat      `json:"CPUS"`     //cpu
	//CPUTIMES []cpu.CPUTimesStat     `json:"CPUTIMES"` //cpu times
	//SM *mem.SwapMemoryStat    `json:"SM"` //交换内存
	NC         *TCPNetInfo `json:"NC"`          //网络
	CpuPercent []float64   `json:"CPUPERCENTS"` //cpu percent
}

系统信息定义

func DecodeSysinfo

func DecodeSysinfo(info string) (*SystemInfo, error)

转换成本地结构体

type TCPNetInfo

type TCPNetInfo struct {
	ClosedWaitCount int `json:"CLOSED_WAIT"`
	//ClosedCount      int `json:"CLOSED"`
	ListenCount      int `json:"LISTEN"`
	EstablishedCount int `json:"ESTABLISH"`
	FinWait2Count    int `json:"FIN_WAIT_2"`
	FinWait1Count    int `json:"FIN_WAIT_1"`
	//ClosingCount     int `json:"CLOSING"`
	SynSentCount     int `json:"SYN_SENT"`
	SynReceivedCount int `json:"SYN_RECV"`
	TimeWaitCount    int `json:"TIME_WAIT"`
	//	LastAckCount     int `json:"LAST_ACK"`
	AllConnectCount int `json:"ALLCOUNT"`
}

网络信息 各种tcp网络状态

Jump to

Keyboard shortcuts

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