teaapps

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

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 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"`
	Statistics []*Statistics `json:"statistics"`
	Logs       []*Log        `json:"logs"`

	IsRunning bool `json:"isRunning"`
	// contains filtered or unexported fields
}

App定义

func NewApp

func NewApp() *App

取得新App

func (*App) AddProcess

func (this *App) AddProcess(process ...*Process)

添加进程,不包括子进程

func (*App) CountAllConnections

func (this *App) CountAllConnections() int

计算总连接数

func (*App) CountAllListens

func (this *App) CountAllListens() int

func (*App) CountAllOpenFiles

func (this *App) CountAllOpenFiles() int

计算总打开的文件数量

func (*App) LoadFromInterface

func (this *App) LoadFromInterface(a *apps.App)

func (*App) OnReload

func (this *App) OnReload(f func())

func (*App) Reload

func (this *App) Reload()

func (*App) ResetProcesses

func (this *App) ResetProcesses()

重置进程

func (*App) SumCPUUsage

func (this *App) SumCPUUsage() *CPUUsage

计算总体CPU占用量

func (*App) SumMemoryUsage

func (this *App) SumMemoryUsage() *MemoryUsage

计算总体内存占用量

func (*App) UniqueId

func (this *App) UniqueId() string

获取UniqueId

type AppInterface

type AppInterface interface {
	Start() error
	Stop() error
}

接口

type CPUUsage

type CPUUsage struct {
	Percent float64 `json:"percent"` // CPU占用比例,是一个小数,比如 0.215
}

CPU占用

type Event

type Event struct {
	Type string
}

事件

type Listen

type Listen struct {
	Network string `json:"network"`
	Addr    string `json:"addr"`
}

type Log

type Log struct {
	Id     string    // 唯一ID,通常系统会自动生成
	Name   string    // 日志名
	Path   string    // 文件路径
	Type   LogType   // 类型
	Format LogFormat // 文件格式
}

日志定义

type LogFormat

type LogFormat = string

type LogType

type LogType = string

type MemoryUsage

type MemoryUsage struct {
	RSS     uint64  `json:"rss"`     // RSS
	VMS     uint64  `json:"vms"`     // VMS
	Percent float64 `json:"percent"` // 百分比
}

内存使用

type Operation

type Operation struct {
	Id            string // 唯一ID,通常系统会自动生成
	Code          string // 代号
	Name          string // 名称
	IsEnabled     bool   // 是否启用
	ShouldConfirm bool   // 操作是否确认
	ConfirmText   string // 操作确认文字
	// contains filtered or unexported fields
}

对App的操作定义

func (*Operation) OnRun

func (this *Operation) OnRun(f func() error)

设置运行时回调函数

func (*Operation) Run

func (this *Operation) Run() error

运行此操作

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

type Socket

type Socket struct {
	Network string
	Address string
}

Socket定义

type Statistics

type Statistics struct {
}

统计 TODO

Jump to

Keyboard shortcuts

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