exec

package
v0.0.0-...-f9c4c5c Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NET_INTERFACE_ALL = "all"
	NET_INTERFACE_VPN = "tun0"
)

Variables

This section is empty.

Functions

func Start

func Start(cfg Config) (err error)

func Stop

func Stop()

Types

type CPUCollector

type CPUCollector struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewCPUCollector

func NewCPUCollector() *CPUCollector

func (*CPUCollector) Result

func (self *CPUCollector) Result() map[string]string

func (*CPUCollector) String

func (self *CPUCollector) String() string

func (*CPUCollector) Update

func (self *CPUCollector) Update()

type Cmd

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

func Command

func Command(name string, args ...string) *Cmd

func CommandWithCmd

func CommandWithCmd(cmd *exec.Cmd) *Cmd

func (*Cmd) Done

func (cmd *Cmd) Done() bool

判断程序结束

func (*Cmd) Kill

func (cmd *Cmd) Kill() error

func (*Cmd) Pid

func (cmd *Cmd) Pid() int

func (*Cmd) ProcessState

func (cmd *Cmd) ProcessState() *os.ProcessState

func (*Cmd) Run

func (cmd *Cmd) Run(timeout int, fn func(cmd *Cmd, err error)) error

异步执行

func (*Cmd) Signal

func (cmd *Cmd) Signal(sig syscall.Signal) error

func (*Cmd) String

func (cmd *Cmd) String() string

type Collector

type Collector interface {
	Update()
	Result() map[string]string
	String() string
}

type Config

type Config struct {
	Name     string `json:"name"`
	Inet     string `json:"inet"`
	Net      string `json:"net"`
	Center   string `json:"center"`
	Token    string `json:"token"`
	DataPath string `json:"data_path"`
}

type Daemon

type Daemon struct {
	// 这个选项是进程启动多少秒之后,此时状态如果是running,则我们认为启动成功了
	// 默认值为1 。。非必须设置
	StartSecs int
	// 当进程启动失败后,最大尝试启动的次数。。当超过预定次数后,将把此进程的状态置为Exited
	// 默认值为3 。。非必须设置。
	StartRetries int
	// 这个是当我们向子进程发送stop信号后,到系统返回信息所等待的最大时间。
	// 超过这个时间会向该子进程发送一个强制kill的信号。
	StopWaitSecs int
	// 运行状态
	State string
	// Cmd
	Cmd *exec.Cmd
}

type DiskCollector

type DiskCollector struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewDiskCollector

func NewDiskCollector() *DiskCollector

func (*DiskCollector) Result

func (self *DiskCollector) Result() map[string]string

func (*DiskCollector) String

func (self *DiskCollector) String() string

func (*DiskCollector) Update

func (self *DiskCollector) Update()

type Executor

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

func (*Executor) Go

func (er *Executor) Go(data proto.Message, callback func(interface{}, error)) error

func (*Executor) SendMessage

func (er *Executor) SendMessage(msg proto.Message) error

func (*Executor) SendRequest

func (er *Executor) SendRequest(req *drpc.Request) error

func (*Executor) SendResponse

func (er *Executor) SendResponse(resp *drpc.Response) error

func (*Executor) Submit

func (er *Executor) Submit(fn interface{}, args ...interface{}) error

type HostCollector

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

func NewHostCollector

func NewHostCollector() *HostCollector

func (*HostCollector) Result

func (self *HostCollector) Result() map[string]string

func (*HostCollector) String

func (self *HostCollector) String() string

func (*HostCollector) Update

func (self *HostCollector) Update()

type LineBuffer

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

func NewLineBuffer

func NewLineBuffer(line int) *LineBuffer

func (*LineBuffer) Bytes

func (this *LineBuffer) Bytes() []byte

func (*LineBuffer) Write

func (this *LineBuffer) Write(p []byte) (n int, err error)

type MemCollector

type MemCollector struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewMemCollector

func NewMemCollector() *MemCollector

func (*MemCollector) Result

func (self *MemCollector) Result() map[string]string

func (*MemCollector) String

func (self *MemCollector) String() string

func (*MemCollector) Update

func (self *MemCollector) Update()

type NetCollector

type NetCollector struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewNetCollector

func NewNetCollector() *NetCollector

func (*NetCollector) Result

func (self *NetCollector) Result() map[string]string

func (*NetCollector) String

func (self *NetCollector) String() string

func (*NetCollector) Update

func (self *NetCollector) Update()

type Process

type Process struct {
	Pid        int32  `json:"pid"`
	Stderr     string `json:"stderr"`
	ID         int32  `json:"id"`
	Name       string `json:"name"`
	State      string `json:"state"`
	CreateTime int64  `json:"create_time"`
	// contains filtered or unexported fields
}

func NewProcess

func NewProcess(pid int32) (*Process, error)

func (*Process) CPUPercent

func (this *Process) CPUPercent() float64

func (*Process) GetState

func (this *Process) GetState() string

func (*Process) MemoryPercent

func (this *Process) MemoryPercent() float32

Jump to

Keyboard shortcuts

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