common

package
v0.0.0-...-c8d1825 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommondResult

func CommondResult(commond string) (result string, err error)

func CommondShell

func CommondShell(commond string, argv []string) (err error)

func CompressFile

func CompressFile(absolutePath string) (data []byte, err error)

压缩文件

func FileText

func FileText(file string, beginLine, endLine int64) (begin, end int64, info []string, err error)

获取文本文件的内容(根据开始行数和结束行数)

func GetPartitionInfo

func GetPartitionInfo(path string) (total, used, free uint64, err error)

func IsDirectory

func IsDirectory(path string) (result bool)

是否为文件夹

func IsExist

func IsExist(path string) (result bool)

文件/路径是否存在

func IsFile

func IsFile(path string) (result bool)

是否为文件

func MaxInt32

func MaxInt32(a, b int32) int32

获取最大值

func MaxInt64

func MaxInt64(a, b int64) int64

func MinInt32

func MinInt32(a, b int32) int32

获取最小值

func MinInt64

func MinInt64(a, b int64) int64

func NetworkInterfaceBandwidth

func NetworkInterfaceBandwidth(network string) (bandwidth uint64, err error)

获取网络接口的网络带宽

func Pow

func Pow(x uint64, y int) (result uint64)

func ReabableSize

func ReabableSize(size uint64) (result string)

把byte转换为K,M,G,T等易读的字符串,小数点后保留一位有效数组

Types

type ByDiskName

type ByDiskName []DiskStatisticInfo

func (ByDiskName) Len

func (a ByDiskName) Len() int

func (ByDiskName) Less

func (a ByDiskName) Less(i, j int) bool

func (ByDiskName) Swap

func (a ByDiskName) Swap(i, j int)

type CapacityInfo

type CapacityInfo struct {
	TotalCapacity             uint64 `json:"total_capacity"`              // 总容量
	TotalCapacityReadable     string `json:"total_capacity_readable"`     // 总容量(阅读友好的)
	UsedCapacity              uint64 `json:"used_capacity"`               // 已经使用的容量
	UsedCapacityReadable      string `json:"used_capacity_readable"`      // 已经使用的容量(阅读友好的)
	AvailableCapacity         uint64 `json:"available_capacity"`          // 空闲的容量
	AvailableCapacityReadable string `json:"available_capacity_readable"` // 空闲的容量(阅读友好的)
}

容量信息

func (*CapacityInfo) String

func (c *CapacityInfo) String() string

type DebugInfo

type DebugInfo struct {
	Log LogInfo `json:"log"` // 日志信息
}

调试信息

func (*DebugInfo) String

func (d *DebugInfo) String() string

type DiskStatisticInfo

type DiskStatisticInfo struct {
	Rrqm              uint64 `json:"rrqm/s"`
	Wrqm              uint64 `json:"wrqm/s"`
	Read              uint64 `json:"r/s"`
	Write             uint64 `json:"w/s"`
	ReadByte          uint64 `json:"rkB/s"`
	ReadByteReadable  string `json:"read_byte_readable"`
	WriteByte         uint64 `json:"wkB/s"`
	WriteByteReadable string `json:"write_byte_readable"`
	Avgrq             uint64 `json:"avgrq-sz"`
	Avgqu             uint64 `json:"avgqu-sz"`
	Await             uint64 `json:"await"`
	Rawait            uint64 `json:"r_await"`
	Wawait            uint64 `json:"w_await"`
	Name              string `json:"name"`
	SerialNumber      string `json:"serialNumber"`
	Svctm             uint64 `json:"svctm"`
	Util              uint64 `json:"util"`
}

磁盘统计

func (*DiskStatisticInfo) String

func (d *DiskStatisticInfo) String() string

type GgfServiceInfo

type GgfServiceInfo struct {
	ServiceInfo
}

主机服务

func (*GgfServiceInfo) String

func (o *GgfServiceInfo) String() string

type GitInfo

type GitInfo struct {
	Branch  string `json:"branch"`  // 分支
	Commit  string `json:"commit"`  // id
	Version string `json:"version"` // 版本信息
}

git信息

type IOInfo

type IOInfo struct {
	ReadCount         uint64 `json:"read_count"`
	WriteCount        uint64 `json:"write_count"`
	ReadByte          uint64 `json:"read_byte"`
	ReadByteReadable  string `json:"read_byte_readable"`
	WriteByte         uint64 `json:"write_byte"`
	WriteByteReadable string `json:"write_byte_readable"`
}

io信息

func (*IOInfo) String

func (i *IOInfo) String() string

type LogInfo

type LogInfo struct {
	LogLevel string `json:"level"` // 日志级别
}

日志信息

func (*LogInfo) String

func (l *LogInfo) String() string

type MemoryStatisticInfo

type MemoryStatisticInfo struct {
	TotalCapacity         uint64 `json:"total_capacity"`          // 总容量
	TotalCapacityReadable string `json:"total_capacity_readable"` // 总容量(阅读友好的)
	UsedSize              uint64 `json:"used_size"`               // 已经使用的容量
	UsedSizeReadable      string `json:"used_size_readable"`      // 已经使用的容量(阅读友好的)
	AvailableSize         uint64 `json:"available_size"`          // 可用的
	AvailableSizeReadable string `json:"available_size_readable"` // 可读性好的可用的内存
	BufferSize            uint64 `json:"buffer_size"`             // buffer的size
	BufferSizeReadable    string `json:"buffer_size_readable"`    // 可读性好的buffer size
	CacheSize             uint64 `json:"cache_size"`              // cache的size
	CacheSizeReadable     string `json:"cache_size_readable"`     // 可读性好的cache的size
}

内存使用情况的统计

func (*MemoryStatisticInfo) String

func (m *MemoryStatisticInfo) String() string

type MemoryUseInfo

type MemoryUseInfo struct {
	UsedPrecent  float64 `json:"used_precent"` // 内存占用的百分比
	RSS          uint64  `json:"rss"`          // 提交到物理内存中的内存使用
	RSSReadable  string  `json:"rss_readable"` // 提交到物理内存中的内存使用
	VMS          uint64  `json:"vms"`          // 虚拟内存
	VMSReadable  string  `json:"vms_readable"` // 可读性好的虚拟内存
	Data         uint64  `json:"data"`         // 数据段占用的内存,
	DataReadable string  `json:"data_readable"`
}

内存使用情况

func (*MemoryUseInfo) String

func (m *MemoryUseInfo) String() string

type NTPInfo

type NTPInfo struct {
	IP                string `json:"ip"`                 // ntp服务器IP
	Port              int32  `json:"port"`               // ntp端口
	ProofreadInterval int64  `json:"proofread_interval"` // 校对间隔
	Enable            bool   `json:"enable"`             // 是否启用ntp校时
}

NTP信息

func (*NTPInfo) String

func (n *NTPInfo) String() string

type NetworkStatisticInfo

type NetworkStatisticInfo struct {
	Name                 string `json:"name"`                   //网口的名称
	ReceiveByte          uint64 `json:"receive_byte"`           //  接收的数据
	ReceiveByteReadable  string `json:"receive_byte_readable"`  // 接收的数据(易于读的)
	SendByte             uint64 `json:"send_byte"`              // 发送的数据
	SendByteReadable     string `json:"send_byte_readable"`     // 接收的数据(易于读的)
	CapacityByte         uint64 `json:"capacity_byte"`          // 网口的总容量
	CapacityByteReadable string `json:"capacity_byte_readable"` // 接收的数据(易于读的)
	ReceivePacket        uint64 `json:"receive_packet"`         // 接收的数据包
	SendPacket           uint64 `json:"send_packet"`            // 发送的数据包
	ReceiveError         uint64 `json:"receive_error"`          // 接收到的错误的包
	SendError            uint64 `json:"send_error"`             // 发送的错误的包
	ReceiveDrop          uint64 `json:"receive_drop"`           // 丢弃的接收的包
	SendDrop             uint64 `json:"send_drop"`              // 丢弃的发送的包
}

网络统计信息

func (*NetworkStatisticInfo) String

func (n *NetworkStatisticInfo) String() string

type NtpControlType

type NtpControlType string

ntp 操作类型

const (
	Ntp_Control_Test NtpControlType = "test"
	Ntp_Control_Set  NtpControlType = "set"
)

type Priority

type Priority int32

定义优先级

const (
	Priority_First  Priority = iota // 第一优先级(最高优先级)
	Priority_Second                 // 第二优先级
	Priority_Third                  // 第三优先级
	Priority_Fourth                 // 第四优先级
	Priority_Fifth                  // 第五优先级(最低优先级)
	Priority_Count                  // 消息种类个数
)

func (Priority) String

func (priority Priority) String() string

Priority转换为字符串

type ProcessInfo

type ProcessInfo struct {
	Name        string               `json:"service"`      // 服务名称
	Pid         int32                `json:"pid"`          // 进程名称
	ThreadCount int32                `json:"thread_count"` // 线程个数
	CPU         float64              `json:"cpu"`          // cpu的使用率
	Startup     string               `json:"startup"`      // 程序启动时间
	Command     string               `json:"command"`      // 启动参数
	Memory      MemoryUseInfo        `json:"memory"`       // 内存使用情况
	Disk        IOInfo               `json:"disk"`         // io使用
	Network     NetworkStatisticInfo `json:"network"`
}

进程的信息

func (*ProcessInfo) String

func (p *ProcessInfo) String() string

type ServiceInfo

type ServiceInfo struct {
	Ip       string // 服务器的ip
	Port     int32  // 服务器的普通端口
	HttpPort int32  // 服务器的http端口
}

服务组件信息

func (*ServiceInfo) String

func (s *ServiceInfo) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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