Documentation
¶
Index ¶
- Constants
- type AlertLevel
- type AlertTarget
- type App
- func (this *App) AddProcess(process ...*Process)
- func (this *App) CountAllConnections() int
- func (this *App) CountAllListens() int
- func (this *App) CountAllOpenFiles() int
- func (this *App) LoadFromInterface(a *apps.App)
- func (this *App) OnReload(f func())
- func (this *App) Reload()
- func (this *App) ResetProcesses()
- func (this *App) SumCPUUsage() *CPUUsage
- func (this *App) SumMemoryUsage() *MemoryUsage
- func (this *App) UniqueId() string
- type AppInterface
- type CPUUsage
- type Event
- type Listen
- type Log
- type LogFormat
- type LogType
- type MemoryUsage
- type Monitor
- type Operation
- type Process
- type Socket
- type Statistics
Constants ¶
View Source
const ( AlertLevelInfo = "info" AlertLevelDebug = "debug" AlertLevelWarning = "warning" AlertLevelError = "error" )
View Source
const ( LogTypeNormal = "normal" LogTypeAccess = "access" LogTypeError = "error" )
日志类型
View Source
const ( LogFormatPlain = "plain" LogFormatXML = "xml" // @TODO 暂不支持 LogFormatGzip = "gzip" // @TODO 暂不支持 LogFormatJSON = "json" // @TODO 暂不支持 LogFormatSQL = "sql" // @TODO 暂不支持 )
日志文件格式
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlertTarget ¶
type AlertTarget interface {
SetOptions(options map[string]interface{}) error // 设置选项
Send(message string) error // 发送消息
}
报警发送目标
type App ¶
type App struct {
Id string `json:"id"` // 唯一ID,通常系统会自动生成
Name string `json:"name"`
Developer string `json:"developer"`
Site string `json:"site"`
DocSite string `json:"docSite"`
Version string `json:"version"`
Icon []byte `json:"icon"`
Processes []*Process `json:"processes"`
Operations []*Operation `json:"operations"`
Monitors []*Monitor `json:"monitors"`
Statistics []*Statistics `json:"statistics"`
Logs []*Log `json:"logs"`
IsRunning bool `json:"isRunning"`
// contains filtered or unexported fields
}
App定义
func (*App) CountAllListens ¶
func (*App) LoadFromInterface ¶
type CPUUsage ¶
type CPUUsage struct {
Percent float64 `json:"percent"` // CPU占用比例,是一个小数,比如 0.215
}
CPU占用
type Log ¶
type Log struct {
Id string // 唯一ID,通常系统会自动生成
Name string // 日志名
Path string // 文件路径
Type LogType // 类型
Format LogFormat // 文件格式
}
日志定义
type MemoryUsage ¶
type MemoryUsage struct {
RSS uint64 `json:"rss"` // RSS
VMS uint64 `json:"vms"` // VMS
Percent float64 `json:"percent"` // 百分比
}
内存使用
type Monitor ¶
type Monitor struct {
ProcessPids []uint32 // 监控的进程PID
Files []string // 监控的文件
EventTypes []string // 监控的事件
Sockets []*Socket // 监控的Socket端口
URLs []string // 监控的URL
PingHosts []string // 通过ICMP监控
Scripts []string // 监控脚本
Timeout float64 // 超时时间,单位为秒
Interval float64 // 间隔时间
MaxFails uint32 // 最大失败次数,在达到此失败次数后才会报警
Level AlertLevel // 级别
Targets []*AlertTarget // 报警发送目标
}
监控设置
type Operation ¶
type Operation struct {
Id string // 唯一ID,通常系统会自动生成
Code string // 代号
Name string // 名称
IsEnabled bool // 是否启用
ShouldConfirm bool // 操作是否确认
ConfirmText string // 操作确认文字
// contains filtered or unexported fields
}
对App的操作定义
type Process ¶
type Process struct {
Name string `json:"name"`
Pid int32 `json:"pid"`
Ppid int32 `json:"ppid"`
Cwd string `json:"cwd"`
User string `json:"user"`
Uid int32 `json:"uid"`
Gid int32 `json:"gid"`
CreateTime int64 `json:"createTime"` // 时间戳
Cmdline string `json:"cmdline"` //命令行
File string `json:"file"` // 命令行文件路径
Dir string `json:"dir"` // 命令行文件所在目录
CPUUsage *CPUUsage `json:"cpuUsage"`
MemoryUsage *MemoryUsage `json:"memoryUsage"`
OpenFiles []string `json:"openFiles"`
Connections []string `json:"connections"`
Listens []*Listen `json:"listens"`
IsRunning bool `json:"isRunning"`
}
func NewProcess ¶
func NewProcess() *Process
Click to show internal directories.
Click to hide internal directories.