Documentation ¶
Overview ¶
获取系统运行状态信息
Index ¶
- Constants
- func SysInfo(runMode, cluster string) string
- type HostInfo
- type HostInfoTable
- func (self *HostInfoTable) CalcHostWeight(hostInfo *HostInfo)
- func (self *HostInfoTable) DumpInfo()
- func (self *HostInfoTable) DumpSortedByWeightInfo()
- func (self *HostInfoTable) GetHostInfo(ip string) *HostInfo
- func (self *HostInfoTable) HostInfoSortList(hostinfo HostInfo) (*list.Element, bool)
- func (self *HostInfoTable) InsertSortHostWeight(hostinfo HostInfo)
- func (self *HostInfoTable) UpdateHostStatus()
- func (self *HostInfoTable) UpdateHostTable(ip string, info *SystemInfo)
- type HostList
- type HttpProxyStatistics
- type StatisticsMap
- type SysHttpStatistics
- type SystemInfo
- type TCPNetInfo
Constants ¶
View Source
const ( ACTIVE = "active" UNACTIVE = "unactive" )
View Source
const (
UNACTIVE_TIMEOUT = 5 //unactive seconds
)
Variables ¶
This section is empty.
Functions ¶
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 (*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) 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 HttpProxyStatistics ¶
http 反向代理请求统计
type SysHttpStatistics ¶
type SysHttpStatistics struct {
// contains filtered or unexported fields
}
func (*SysHttpStatistics) GetStatisticsList ¶
func (self *SysHttpStatistics) GetStatisticsList() StatisticsMap
获取统计列表
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 }
系统信息定义
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网络状态
Click to show internal directories.
Click to hide internal directories.