anet

package module
v0.0.0-...-88563be Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: AGPL-3.0 Imports: 9 Imported by: 1

README

SmartAgent Client/Server 通信协议


SmartAgent Client
https://github.com/jkstack/smartagent


SmartAgent Server
https://github.com/jkstack/smartagent-server



SmartAgent 开源站点

http://open.jkstack.com

SmartAgent 用户微信群

Documentation

Index

Constants

View Source
const (
	InstallActionDone = iota
	InstallActionDownload
	InstallActionInstall
	InstallActionFile
)
View Source
const (
	LoggingTypeK8s = iota
	LoggingTypeDocker
	LoggingTypeFile
)
View Source
const (
	LoggingAlreadyRunningMsg = "project is already running"
	LoggingNotRunningMsg     = "project is not running"
)
View Source
const (
	RPAPause = iota
	RPAStop
	RPAContinue
)

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(data []byte) ([]byte, error)

func Encrypt

func Encrypt(data []byte) ([]byte, error)

Types

type AgentInfo

type AgentInfo struct {
	Version          string             `json:"v"`   // 版本号
	GoVersion        string             `json:"gv"`  // go版本号
	CpuUsage         float32            `json:"cu"`  // cpu使用率(百分比)
	MemoryUsage      float32            `json:"mu"`  // 内存使用率(百分比)
	Threads          int                `json:"ts"`  // 线程数
	Routines         int                `json:"rs"`  // 协程数
	Startup          int64              `json:"st"`  // 启动时间戳
	HeapInuse        uint64             `json:"hi"`  // 堆内存用量
	GC               map[string]float64 `json:"gc"`  // gc信息
	InPackets        uint64             `json:"ip"`  // 接收数据包数量
	InBytes          uint64             `json:"ib"`  // 接收数据字节数
	OutPackets       uint64             `json:"op"`  // 发送数据包数量
	OutBytes         uint64             `json:"ob"`  // 发送数据字节数
	PluginExecd      uint64             `json:"pe"`  // 已运行插件数
	PluginRunning    uint64             `json:"pr"`  // 正在运行插件数量
	ReconnectCount   int                `json:"rcc"` // 重连次数
	PluginUseCount   map[string]uint64  `json:"puc"` // 每个插件使用次数
	PluginOutPackets map[string]uint64  `json:"pop"` // 每个插件发送数据包数量
	PluginOutBytes   map[string]uint64  `json:"pob"` // 每个插件发送字节数
	ReadChanSize     int                `json:"rcs"` // 接收队列长度
	WriteChanSize    int                `json:"wcs"` // 发送队列长度
}

type ComePayload

type ComePayload struct {
	ID              string `json:"id"` // agent-id
	Name            string `json:"name"`
	Version         string `json:"version"`          // 版本号
	IP              net.IP `json:"ip"`               // ip地址
	MAC             string `json:"mac"`              // mac地址
	HostName        string `json:"host_name"`        // 主机名
	OS              string `json:"os"`               // 操作系统名称,windows或linux
	Platform        string `json:"platform"`         // 操作系统名称,debian、centos等
	PlatformVersion string `json:"platform_version"` // 操作系统版本号,如7.7.1908
	KernelVersion   string `json:"kernel_version"`   // 内核版本号,如3.10.0-1062.el7.x86_64
	Arch            string `json:"arch"`             // 操作系统位数,amd64、i386等
	CPU             string `json:"cpu"`              // CPU型号,如AMD Ryzen 7 4800U with Radeon Graphics
	CPUCore         uint64 `json:"cpu_core"`         // CPU核心数
	Memory          uint64 `json:"memory"`           // 内存大小
}

ComePayload handshake request

type DownloadData

type DownloadData struct {
	Offset uint64 `json:"offset"` // 块偏移量
	Data   string `json:"data"`   // 块内容
}

DownloadData download data

type DownloadError

type DownloadError struct {
	Msg string `json:"msg"`
}

type DownloadRep

type DownloadRep struct {
	Dir       string         `json:"dir"`           // 文件路径
	OK        bool           `json:"ok"`            // 是否读取成功
	ErrMsg    string         `json:"msg,omitempty"` // 错误信息
	Size      uint64         `json:"size"`          // 文件大小
	BlockSize uint64         `json:"block_size"`    // 分块大小
	MD5       [md5.Size]byte `json:"md5"`           // 文件md5
}

DownloadRep download response

type DownloadReq

type DownloadReq struct {
	Dir string `json:"dir"` // 文件路径
}

DownloadReq download request

type ExecData

type ExecData struct {
	Data string `json:"data"`
}

ExecData exec data

type ExecDone

type ExecDone struct {
	Code int       `json:"code"` // 退出时的返回码
	Time time.Time `json:"t"`    // 结束时间
}

ExecDone exec done

type ExecKill

type ExecKill struct {
	Pid int `json:"pid"` // 进程ID
}

ExecKill exec kill

type ExecPayload

type ExecPayload struct {
	Cmd     string   `json:"cmd"`               // 命令路径
	Args    []string `json:"args,omitempty"`    // 命令参数
	Timeout int      `json:"timeout"`           // 超时时间,单位秒
	Auth    string   `json:"auth,omitempty"`    // 是否提权,su、sudo或空
	User    string   `json:"user,omitempty"`    // 提权用户
	Pass    string   `json:"pass,omitempty"`    // 提权密码
	WorkDir string   `json:"workdir,omitempty"` // 工作目录
	Env     []string `json:"env,omitempty"`     // 运行时的环境变量
	DeferRM string   `json:"drm,omitempty"`
}

ExecPayload exec payload

type ExecdPayload

type ExecdPayload struct {
	OK   bool      `json:"ok"`            // 是否启动成功
	Msg  string    `json:"msg,omitempty"` // 启动失败时的详情
	Pid  int       `json:"pid"`           // 进程id
	Time time.Time `json:"t"`             // 启动时间
}

ExecdPayload execd payload

type FileInfo

type FileInfo struct {
	Name    string      `json:"name"`     // 文件名称
	Mod     os.FileMode `json:"mod"`      // 文件权限
	User    string      `json:"user"`     // 所属用户
	Group   string      `json:"group"`    // 所属组
	Size    uint64      `json:"size"`     // 文件大小
	ModTime time.Time   `json:"mod_time"` // 文件修改时间
	IsLink  bool        `json:"is_link"`  // 是否是软链接
	LinkDir string      `json:"link_dir"` // 连接路径
}

FileInfo file info for ls

type HMAgentJob

type HMAgentJob struct {
	Name      string `json:"name"` // 任务名称
	Interval  uint64 `json:"i"`    // 间隔时间
	BytesSent uint64 `json:"bs"`   // 已发送字节数
	Count     uint64 `json:"ct"`   // 上报次数
}

type HMAgentStatus

type HMAgentStatus struct {
	Jobs     []HMAgentJob `json:"jobs,omitempty"` // 正在执行的自动采集任务列表
	Warnings uint64       `json:"warns"`          // 获取数据失败次数
}

type HMChangeReportStatus

type HMChangeReportStatus struct {
	Jobs []string `json:"jobs,omitempty"` // 允许执行的任务列表
}

type HMCore

type HMCore struct {
	Processor int32           `json:"processor,omitempty"` // 第几个核心
	Model     string          `json:"model,omitempty"`     // Intel(R) Xeon(R) CPU E5-2620 v2 @ 2.10GHz
	Core      int32           `json:"core,omitempty"`      // 所在物理核上的编号
	Cores     int32           `json:"cores,omitempty"`     // 某块CPU上的编号
	Physical  int32           `json:"physical,omitempty"`  // 物理CPU编号
	Mhz       utils.Float64P2 `json:"mhz,omitempty"`       // CPU频率
}

type HMDisk

type HMDisk struct {
	Model      string   `json:"model,omitempty"` // 品牌型号
	Total      uint64   `json:"total,omitempty"` // 容量
	Type       string   `json:"type,omitempty"`  // hdd,fdd,odd
	Partitions []string `json:"parts,omitempty"` // 逻辑分区
}

type HMDynamicConnection

type HMDynamicConnection struct {
	Fd     uint32 `json:"fd,omitempty"`     // 句柄号
	Pid    int32  `json:"pid,omitempty"`    // 所属进程ID
	Type   string `json:"type,omitempty"`   // 连接类型
	Local  string `json:"local,omitempty"`  // 本地地址
	Remote string `json:"remote,omitempty"` // 远程地址
	Status string `json:"status,omitempty"` // 连接状态
}

type HMDynamicInterface

type HMDynamicInterface struct {
	Name        string `json:"name,omitempty"`  // 网卡名称
	BytesSent   uint64 `json:"bsent,omitempty"` // 发送字节数
	BytesRecv   uint64 `json:"brecv,omitempty"` // 接收字节数
	PacketsSent uint64 `json:"psent,omitempty"` // 发送数据包数量
	PacketsRecv uint64 `json:"precv,omitempty"` // 接收数据包数量
}

type HMDynamicPartition

type HMDynamicPartition struct {
	Name           string          `json:"name,omitempty"`   // linux为挂载路径如/run,windows为盘符如C:
	Used           uint64          `json:"used,omitempty"`   // 已使用字节数
	Free           uint64          `json:"free,omitempty"`   // 剩余字节数
	Usage          utils.Float64P2 `json:"usage,omitempty"`  // 磁盘使用率
	InodeUsed      uint64          `json:"iused,omitempty"`  // inode使用数量
	InodeFree      uint64          `json:"ifree,omitempty"`  // inode剩余数量
	InodeUsage     utils.Float64P2 `json:"iusage,omitempty"` // inode使用率
	ReadPreSecond  utils.Float64P2 `json:"rps,omitempty"`    // 每秒读取字节数
	WritePreSecond utils.Float64P2 `json:"wps,omitempty"`    // 每秒写入字节数
	IopsInProgress uint64          `json:"iip,omitempty"`    // iops
}

type HMDynamicProcess

type HMDynamicProcess struct {
	ID            int32           `json:"id,omitempty"`     // 进程ID
	ParentID      int32           `json:"pid,omitempty"`    // 父进程ID
	User          string          `json:"user,omitempty"`   // 用户
	CpuUsage      utils.Float64P2 `json:"cpu,omitempty"`    // CPU使用率
	RssMemory     uint64          `json:"rss,omitempty"`    // 物理内存数
	VirtualMemory uint64          `json:"vms,omitempty"`    // 虚拟内存数
	SwapMemory    uint64          `json:"swap,omitempty"`   // swap内存数
	MemoryUsage   utils.Float64P2 `json:"mem,omitempty"`    // 内存使用率
	Cmd           []string        `json:"cmd,omitempty"`    // 命令行
	Listen        []uint32        `json:"listen,omitempty"` // 监听端口
	Connections   int             `json:"conns,omitempty"`  // 连接数
}

type HMDynamicRep

type HMDynamicRep struct {
	Begin               time.Time             `json:"begin"`             // 开始采集时间
	End                 time.Time             `json:"end"`               // 采集完成时间
	Usage               *HMDynamicUsage       `json:"usage,omitempty"`   // CPU
	Process             []HMDynamicProcess    `json:"process,omitempty"` // 进程
	Connections         []HMDynamicConnection `json:"conns,omitempty"`   // 连接
	SensorsTemperatures []HMSensorTemperature `json:"temps,omitempty"`   // 传感器温度
}

type HMDynamicReq

type HMDynamicReq struct {
	Req        []HMDynamicReqType `json:"req"`              // 请求内容
	Top        int                `json:"top,omitempty"`    // 返回进程列表数量限制
	AllowConns []string           `json:"aconns,omitempty"` // 允许返回的连接类型
}

type HMDynamicReqType

type HMDynamicReqType int
const (
	HMReqUsage HMDynamicReqType = iota
	HMReqProcess
	HMReqConnections
	HMReqSensorsTemperatures
)

type HMDynamicUsage

type HMDynamicUsage struct {
	Cpu struct {
		Usage  utils.Float64P2 `json:"usage,omitempty"`  // CPU使用率
		Load1  utils.Float64P2 `json:"load1,omitempty"`  // 1分钟负载
		Load5  utils.Float64P2 `json:"load5,omitempty"`  // 5分钟负载
		Load15 utils.Float64P2 `json:"load15,omitempty"` // 15分钟负载
	} `json:"cpu"`
	Memory struct {
		Used      uint64          `json:"used,omitempty"`      // 已使用字节数
		Free      uint64          `json:"free,omitempty"`      // 剩余字节数
		Available uint64          `json:"available,omitempty"` // 可用字节数
		Usage     utils.Float64P2 `json:"usage,omitempty"`     // 内存使用率
		SwapUsed  uint64          `json:"sused,omitempty"`     // swap已使用字节数
		SwapFree  uint64          `json:"sfree,omitempty"`     // swap剩余字节数
	} `json:"mem"`
	Partitions []HMDynamicPartition `json:"parts,omitempty"`      // 分区
	Interface  []HMDynamicInterface `json:"intferface,omitempty"` // 网卡
}

type HMInterface

type HMInterface struct {
	Index   int      `json:"index,omitempty"` // 网卡下标
	Name    string   `json:"name,omitempty"`  // 网卡名称
	Mtu     int      `json:"mtu,omitempty"`   // 网卡mtu
	Flags   []string `json:"flags,omitempty"` // 网卡附加参数
	Mac     string   `json:"mac,omitempty"`   // 网卡mac地址
	Address []string `json:"addrs,omitempty"` // 网卡上绑定的IP地址列表
}

type HMJob

type HMJob struct {
	Name     string        `json:"name,omitempty"`     // 任务名
	Interval time.Duration `json:"interval,omitempty"` // 间隔时间
}

type HMPartition

type HMPartition struct {
	Name   string   `json:"name,omitempty"`   // linux为挂载路径如/run,windows为盘符如C:
	FSType string   `json:"fstype,omitempty"` // NTFS
	Opts   []string `json:"opts,omitempty"`   // rw,nosuid,nodev
	Total  uint64   `json:"total,omitempty"`  // 总容量
	INodes uint64   `json:"inodes,omitempty"` // inode数量
}

type HMReportStatusPayload

type HMReportStatusPayload struct {
	Jobs       []HMJob  `json:"jobs,omitempty"`   // 当前正在执行的任务列表
	ConnsAllow []string `json:"aconns,omitempty"` // 允许采集的连接类型
}

type HMSensorTemperature

type HMSensorTemperature struct {
	Name        string          `json:"name,omitempty"` // 名称
	Temperature utils.Float64P2 `json:"temp,omitempty"` // 温度
}

type HMStaticPayload

type HMStaticPayload struct {
	Time time.Time `json:"time"` // 上报时间
	Host struct {
		Name   string        `json:"name,omitempty"`   // 主机名
		UpTime time.Duration `json:"uptime,omitempty"` // 主机启动时长
	} `json:"host,omitempty"`
	OS struct {
		Name            string    `json:"name,omitempty"`     // linux、windows
		PlatformName    string    `json:"pname,omitempty"`    // debian、centos
		PlatformVersion string    `json:"pversion,omitempty"` // 7.7.1908
		Install         time.Time `json:"install,omitempty"`  // 安装时间
		Startup         time.Time `json:"startup,omitempty"`  // 启动时间
	} `json:"os,omitempty"`
	Kernel struct {
		Version string `json:"version,omitempty"` // 3.10.0-1062.el7.x86_64
		Arch    string `json:"arch,omitempty"`    // amd64、i386
	} `json:"kernel,omitempty"`
	CPU struct {
		Physical int      `json:"physical,omitempty"` // 物理核心数
		Logical  int      `json:"logical,omitempty"`  // 逻辑核心数
		Cores    []HMCore `json:"cores,omitempty"`    // 每个核心的参数
	} `json:"cpu,omitempty"`
	Memory struct {
		Physical uint64 `json:"physical,omitempty"` // 物理内存大小
		Swap     uint64 `json:"swap,omitempty"`     // swap内存大小
	} `json:"memory,omitempty"`
	Disks       []HMDisk      `json:"disks,omitempty"`       // 物理磁盘列表
	Partitions  []HMPartition `json:"parts,omitempty"`       // 逻辑分区列表
	NameServers []string      `json:"nameservers,omitempty"` // DNS服务器列表
	GateWay     string        `json:"gateway,omitempty"`     // 网关地址
	Interface   []HMInterface `json:"interface,omitempty"`   // 网卡列表
	User        []HMUser      `json:"user,omitempty"`        // 用户列表
}

type HMUser

type HMUser struct {
	Name string `json:"name,omitempty"` // 用户名
	ID   string `json:"id,omitempty"`   // 用户ID
	GID  string `json:"gid,omitempty"`  // 用户组ID
}

type HandshakePayload

type HandshakePayload struct {
	OK       bool     `json:"ok"`                 // 握手是否成功
	ID       string   `json:"id"`                 // 被分配的agent id
	Msg      string   `json:"msg"`                // 错误信息
	Redirect []string `json:"redirect,omitempty"` // 重定向地址
}

HandshakePayload handshake response

type IPMICommonRequest

type IPMICommonRequest struct {
	Interface string `json:"interface"` // 连接方式:lan=v1.5, lanplus=v2.0, auto=lanplus first
	Addr      string `json:"addr"`      // IPMI地址
	Username  string `json:"username"`  // 用户名
	Password  string `json:"password"`  // 密码
}

type IPMIDeviceInfo

type IPMIDeviceInfo struct {
	OK              bool   `json:"ok"`               // 是否成功
	Msg             string `json:"msg,omitempty"`    // 错误信息
	OEM             string `json:"oem"`              // 生产厂商
	FirmwareVersion string `json:"firmware_version"` // 固件版本
	IPMIVersion     string `json:"ipmi_version"`     // IPMI版本
}

type IPMISensorCritical

type IPMISensorCritical struct {
	NonCritical    *utils.Float64P2 `json:"non_critical,omitempty"`    // 恢复数值
	Critical       *utils.Float64P2 `json:"critical,omitempty"`        // 告警数值
	NonRecoverable *utils.Float64P2 `json:"non_recoverable,omitempty"` // 严重告警数值
}

type IPMISensorInfo

type IPMISensorInfo struct {
	ID       uint16           `json:"id"`               // 传感器序号
	SensorID uint8            `json:"sensor_id"`        // 传感器ID
	EntityID string           `json:"entity_id"`        // 实体ID
	Name     string           `json:"name"`             // 传感器名称
	Type     string           `json:"type"`             // 传感器类型
	Discrete bool             `json:"discrete"`         // 是否是离散传感器
	Values   *IPMISensorValue `json:"values,omitempty"` // 传感器数值
}

type IPMISensorList

type IPMISensorList struct {
	OK   bool             `json:"ok"`            // 是否成功
	Msg  string           `json:"msg,omitempty"` // 错误信息
	List []IPMISensorInfo `json:"list"`          // 传感器列表
}

type IPMISensorValue

type IPMISensorValue struct {
	Unit    sensorUnitValue     `json:"unit"`            // 当前传感器的单位信息
	Current utils.Float64P2     `json:"current"`         // 当前数值
	Lower   *IPMISensorCritical `json:"lower,omitempty"` // 最低告警数值
	Upper   *IPMISensorCritical `json:"upper,omitempty"` // 最高告警数值
}

type InstallArgs

type InstallArgs struct {
	URI     string          `json:"uri"`
	URL     string          `json:"url"`
	Dir     string          `json:"dir"`
	Timeout int             `json:"timeout"`
	Auth    string          `json:"auth,omitempty"`
	User    string          `json:"user,omitempty"`
	Pass    string          `json:"pass,omitempty"`
	Configs []InstallConfig `json:"conf,omitempty"`
}

type InstallConfig

type InstallConfig struct {
	URI string `json:"uri"`
	URL string `json:"url"`
	Dir string `json:"dir"`
}

type InstallRep

type InstallRep struct {
	Time   int64  `json:"ts"`
	Action uint8  `json:"action"`
	Name   string `json:"name"`
	OK     bool   `json:"ok"`
	Msg    string `json:"msg"`
}

type LogDownloadData

type LogDownloadData struct {
	Offset uint64 `json:"offset"` // 块偏移量
	Data   string `json:"data"`   // 块内容
}

LogDownloadData download file data

type LogDownloadInfo

type LogDownloadInfo struct {
	OK        bool           `json:"ok"`                   // 是否成功
	ErrMsg    string         `json:"msg,omitempty"`        // 错误信息
	Size      uint64         `json:"size,omitempty"`       // 文件大小
	BlockSize uint64         `json:"block_size,omitempty"` // 分块大小
	MD5       [md5.Size]byte `json:"md5,omitempty"`        // 文件md5
}

LogDownloadInfo download file info

type LogDownloadReq

type LogDownloadReq struct {
	Files []string `json:"files"` // 请求文件列表
}

LogDownloadReq download log request

type LogFile

type LogFile struct {
	Name    string    `json:"name"` // 文件名
	Size    uint64    `json:"size"` // 文件大小
	ModTime time.Time `json:"mod"`  // 修改时间
}

LogFile log file info

type LoggingConfig

type LoggingConfig struct {
	Pid      int64                `json:"pid"`
	T        int                  `json:"t"`
	Exclude  string               `json:"ext,omitempty"`
	Batch    int                  `json:"b"`
	Buffer   int                  `json:"bf"`
	Interval int                  `json:"itv"`
	Report   string               `json:"rp"`
	K8s      *LoggingConfigK8s    `json:"k8s,omitempty"`
	Docker   *LoggingConfigDocker `json:"d,omitempty"`
	File     *LoggingConfigFile   `json:"f,omitempty"`
}

type LoggingConfigDocker

type LoggingConfigDocker struct {
	ContainerName string `json:"cn"`
	ContainerTag  string `json:"ct"`
	Dir           string `json:"d"`
}

type LoggingConfigFile

type LoggingConfigFile struct {
	Dir string `json:"d"`
}

type LoggingConfigK8s

type LoggingConfigK8s struct {
	Namespace string   `json:"ns"`
	Names     []string `json:"nms"`
	Dir       string   `json:"d"`
	Api       string   `json:"a"`
	Token     string   `json:"tk"`
}

type LoggingReport

type LoggingReport struct {
	CountK8s    uint64                  `json:"ct_k8s,omitempty"`
	CountDocker uint64                  `json:"ct_dr,omitempty"`
	CountFile   uint64                  `json:"ct_f,omitempty"`
	K8s         LoggingReportK8sData    `json:"k8s"`
	Docker      LoggingReportDockerData `json:"dr"`
	File        LoggingReportFileData   `json:"f"`
	Info        LoggingReportInfo       `json:"rp"`
	AgentInfo   LoggingReportAgentInfo  `json:"ag"`
}

type LoggingReportAgentInfo

type LoggingReportAgentInfo struct {
	GoVersion  string             `json:"gv"`
	Threads    int                `json:"ts"`
	Routines   int                `json:"rs"`
	Startup    int64              `json:"st"`
	HeapInuse  uint64             `json:"hi"`
	GC         map[string]float64 `json:"gc"`
	InPackets  uint64             `json:"ip"`
	InBytes    uint64             `json:"ib"`
	OutPackets uint64             `json:"op"`
	OutBytes   uint64             `json:"ob"`
}

type LoggingReportDockerData

type LoggingReportDockerData struct {
	Count int `json:"ct,omitempty"`
}

type LoggingReportFileData

type LoggingReportFileData struct {
	Count int `json:"ct,omitempty"`
}

type LoggingReportInfo

type LoggingReportInfo struct {
	QPS     float64 `json:"qps,omitempty"`
	AvgCost float64 `json:"avg,omitempty"`
	P0      int64   `json:"p0,omitempty"`
	P50     int64   `json:"p50,omitempty"`
	P90     int64   `json:"p90,omitempty"`
	P99     int64   `json:"p99,omitempty"`
	P100    int64   `json:"p100,omitempty"`
	Count   uint64  `json:"ct,omitempty"`
	Bytes   uint64  `json:"b,omitempty"`
	HttpErr uint64  `json:"he,omitempty"`
	SrvErr  uint64  `json:"se,omitempty"`
}

type LoggingReportK8sData

type LoggingReportK8sData struct {
	QPS            float64 `json:"qps,omitempty"`
	AvgCost        float64 `json:"avg,omitempty"`
	P0             int64   `json:"p0,omitempty"`
	P50            int64   `json:"p50,omitempty"`
	P90            int64   `json:"p90,omitempty"`
	P99            int64   `json:"p99,omitempty"`
	P100           int64   `json:"p100,omitempty"`
	CountService   int     `json:"ct_svr,omitempty"`
	CountPod       int     `json:"ct_pds,omitempty"`
	CountContainer int     `json:"ct_cts,omitempty"`
}

type LoggingReportTask

type LoggingReportTask struct {
	ID      int64 `json:"id"`
	Pods    int   `json:"pods"`
	Running bool  `json:"run"`
}

type LoggingStatusRep

type LoggingStatusRep struct {
	OK  bool   `json:"ok"`
	Msg string `json:"msg"`
}

type LoggingStatusReq

type LoggingStatusReq struct {
	ID      int64 `json:"id"`
	Running bool  `json:"run"`
}

type LsLogPayload

type LsLogPayload struct {
	Files []LogFile `json:"files"` // 文件列表
}

LsLogPayload ls log response

type LsRep

type LsRep struct {
	Dir    string     `json:"dir"`             // 路径
	OK     bool       `json:"ok"`              // 是否成功
	ErrMsg string     `json:"msg,omitempty"`   // 出错时的信息
	Files  []FileInfo `json:"files,omitempty"` // 文件列表
}

LsRep ls response

type LsReq

type LsReq struct {
	Dir string `json:"dir"` // ls目录地址
}

LsReq ls request

type Msg

type Msg struct {
	Type      TypeName    `json:"type"`             // 消息类型,详见消息类型章节
	Important bool        `json:"-"`                // 是否是关键消息
	TaskID    string      `json:"tid,omitempty"`    // 任务ID
	Plugin    *PluginInfo `json:"plugin,omitempty"` // 所需调用的插件信息
	ErrorMsg  string      `json:"errmsg,omitempty"` // 错误消息的详情
	// ctrl
	AgentInfo       *AgentInfo        `json:"ai,omitempty"`        // agent状态上报
	Come            *ComePayload      `json:"come,omitempty"`      // 握手请求
	Handshake       *HandshakePayload `json:"handshake,omitempty"` // 握手返回结果
	LsLog           *LsLogPayload     `json:"ls_log,omitempty"`    // 查询log文件结果
	LogDownload     *LogDownloadReq   `json:"log_dreq,omitempty"`  // 下载log文件
	LogDownloadInfo *LogDownloadInfo  `json:"log_dinfo,omitempty"` // 下载log文件信息
	LogDownloadData *LogDownloadData  `json:"log_ddata,omitempty"` // 下载log文件内容
	// exec plugin
	Exec     *ExecPayload  `json:"exec,omitempty"`      // 执行命令消息参数
	Execd    *ExecdPayload `json:"execd,omitempty"`     // 执行命令脚本或命令的启动结果,包括pid等
	ExecData *ExecData     `json:"exec_data,omitempty"` // 执行命令消息返回内容
	ExecDone *ExecDone     `json:"exec_done,omitempty"` // 执行命令返回结果,exit_code等
	ExecKill *ExecKill     `json:"exec_kill,omitempty"` // kill命令参数
	// file plugin
	LSReq         *LsReq         `json:"ls_req,omitempty"`         // ls请求参数
	LSRep         *LsRep         `json:"ls_rep,omitempty"`         // ls请求返回结果
	Upload        *Upload        `json:"upload,omitempty"`         // 文件上传时的文件基本信息,md5等
	UploadRep     *UploadRep     `json:"upload_rep,omitempty"`     // 文件创建结果
	DownloadReq   *DownloadReq   `json:"download_req,omitempty"`   // 文件下载请求,文件路径等
	DownloadRep   *DownloadRep   `json:"download_rep,omitempty"`   // 文件下载的基本信息,md5等
	DownloadData  *DownloadData  `json:"download_data,omitempty"`  // 文件内容
	DownloadError *DownloadError `json:"download_error,omitempty"` // 文件读取时的报错信息
	// host.monitor
	HMStatic        *HMStaticPayload       `json:"hm_static,omitempty"`        // 主机信息返回结果
	HMDynamicReq    *HMDynamicReq          `json:"hm_dynamic_req,omitempty"`   // 动态数据请求
	HMDynamicRep    *HMDynamicRep          `json:"hm_dynamic_rep,omitempty"`   // 动态数据响应
	HMCollectStatus *HMReportStatusPayload `json:"hm_status_rep,omitempty"`    // 自动采集状态返回
	HMChangeStatus  *HMChangeReportStatus  `json:"hm_change_status,omitempty"` // 修改自动采集状态
	HMAgentStatus   *HMAgentStatus         `json:"hm_agent_status,omitempty"`  // metrics-agent状态上报
	// install
	InstallArgs *InstallArgs `json:"inst_args,omitempty"` // 安装请求参数
	InstallRep  *InstallRep  `json:"inst_rep,omitempty"`  // 安装结果
	// logging
	LoggingConfig    *LoggingConfig    `json:"logging_config,omitempty"` // 创建任务
	LoggingStatusReq *LoggingStatusReq `json:"logging_req,omitempty"`    // 切换状态请求
	LoggingStatusRep *LoggingStatusRep `json:"logging_rep,omitempty"`    // 切换状态结果
	LoggingReport    *LoggingReport    `json:"logging_report,omitempty"` // 状态上报
	// rpa
	RPARun                 *RPARunArgs             `json:"rpa_run,omitempty"`                   // RPA运行参数
	RPALog                 *RPALogData             `json:"rpa_log,omitempty"`                   // RPA日志上报
	RPACtrlReq             *RPACtrlReq             `json:"rpa_ctrl_req,omitempty"`              // RPA控制请求
	RPACtrlRep             *RPACtrlRep             `json:"rpa_ctrl_rep,omitempty"`              // RPA控制结果
	RPAFinish              *RPAFinish              `json:"rpa_finish,omitempty"`                // RPA运行结束
	RPASelectorRep         *RPASelectorRep         `json:"rpa_selector_rep,omitempty"`          // RPA工具状态
	RPASelectorResult      *RPASelectorResult      `json:"rpa_selector_result,omitempty"`       // RPA工具结果
	RPASelectorValidateReq *RPASelectorValidateReq `json:"rpa_selector_validate_req,omitempty"` // RPA工具校验请求
	RPASelectorValidateRep *RPASelectorValidateRep `json:"rpa_selector_validate_rep,omitempty"` // RPA工具校验结果
	// ipmi
	IPMICommonReq  *IPMICommonRequest `json:"ipmi_common_req,omitempty"`  // IPMI通用请求
	IPMIDeviceInfo *IPMIDeviceInfo    `json:"ipmi_device_info,omitempty"` // IPMI设备信息
	IPMISensorList *IPMISensorList    `json:"ipmi_sensor_list,omitempty"` // IPMI传感器列表
	// snmp
	SNMPReq *SNMPReq `json:"snmp_req,omitempty"` // SNMP请求
	SNMPRep *SNMPRep `json:"snmp_rep,omitempty"` // SNMP响应
}

Msg message

type PluginInfo

type PluginInfo struct {
	Name    string         `json:"name"`    // 插件名称
	Version string         `json:"version"` // 插件版本号
	MD5     [md5.Size]byte `json:"md5"`     // 插件文件的md5
	URI     string         `json:"uri"`     // 插件下载的uri
}

PluginInfo plugin info

type RPACtrlRep

type RPACtrlRep struct {
	OK  bool   `json:"ok,omitempty"`  // 操作是否成功
	Msg string `json:"msg,omitempty"` // 失败原因
}

type RPACtrlReq

type RPACtrlReq struct {
	Status int `json:"status"` // 操作状态,0=pause, 1=stop, 2=continue
}

type RPAFinish

type RPAFinish struct {
	Code int    `json:"code,omitempty"` // 状态码
	Msg  string `json:"msg,omitempty"`  // 错误信息
	Data string `json:"data,omitempty"` // 返回内容
}

type RPALogData

type RPALogData string

type RPARunArgs

type RPARunArgs struct {
	URL     string `json:"url"`                // zip包下载地址
	IsDebug bool   `json:"is_debug,omitempty"` // 是否是调试模式运行
}

type RPASelectorRep

type RPASelectorRep struct {
	Code int    `json:"code,omitempty"` // 状态码
	Msg  string `json:"msg,omitempty"`  // 错误信息
}

type RPASelectorResult

type RPASelectorResult struct {
	Code    int    `json:"code,omitempty"`    // 状态码
	Msg     string `json:"msg,omitempty"`     // 错误信息
	Content string `json:"content,omitempty"` // xml内容
	Image   string `json:"image,omitempty"`   // 图片
}

type RPASelectorValidateRep

type RPASelectorValidateRep struct {
	OK  bool   `json:"ok"`  // 是否成功
	Msg string `json:"msg"` // 错误信息
}

type RPASelectorValidateReq

type RPASelectorValidateReq struct {
	Content string `json:"content"` // xml内容
}

type SNMPItem

type SNMPItem struct {
	OID   string `json:"oid"`   // snmp oid
	Type  string `json:"type"`  // snmp type
	Value string `json:"value"` // snmp value
}

type SNMPRep

type SNMPRep struct {
	OK    bool       `json:"ok"`              // 是否成功
	Msg   string     `json:"msg,omitempty"`   // 错误信息
	Items []SNMPItem `json:"items,omitempty"` // snmp items
}

type SNMPReq

type SNMPReq struct {
	Host      string `json:"host"`          // 服务地址
	Community string `json:"community"`     // snmp community
	OID       string `json:"oid,omitempty"` // snmp oid
}

type TypeName

type TypeName int
const (
	TypeError     TypeName = iota + 0 // 0:错误消息,可能是一个全局错误
	TypeCome                          // 1:握手消息,agent发起
	TypeHandshake                     // 2:握手消息,服务端返回
)

global

const (
	TypeFoo TypeName = iota + 8 // 8: foo消息
	TypeBar                     // 9: bar消息
)
const (
	TypeExec     TypeName = iota + 10 // 10:执行命令
	TypeExecd                         // 11:脚本或命令启动结果
	TypeExecData                      // 12:脚本返回内容
	TypeExecDone                      // 13:脚本执行结果
	TypeExecKill                      // 14:kill命令
)

exec

const (
	TypeLsReq         TypeName = iota + 20 // 20:ls命令请求参数
	TypeLsRep                              // 21:ls命令返回结果
	TypeUpload                             // 22:文件上传时的文件信息
	TypeUploadRep                          // 23:文件写入时的结果
	TypeDownloadReq                        // 24:文件下载请求参数
	TypeDownloadRep                        // 25:文件下载请求时的文件信息
	TypeDownloadData                       // 26:文件下载时的内容
	TypeDownloadError                      // 27:文件下载时的错误信息
)

file

const (
	TypeHMStaticReq           TypeName = iota + 30 // 30: 获取主机信息请求
	TypeHMStaticRep                                // 31: 主机信息返回内容
	TypeHMDynamicReq                               // 32: 获取动态数据
	TypeHMDynamicRep                               // 33: 返回动态数据
	TypeHMQueryCollect                             // 34: 获取自动采集状态(req)
	TypeHMCollectStatus                            // 35: 返回自动采集状态(rep)
	TypeHMChangeCollectStatus                      // 36: 切换自动采集状态
	TypeHMReportAgentStatus                        // 37: agent状态上报数据
)

host.monitor

const (
	TypeInstallArgs TypeName = iota + 40
	TypeInstallRep
)

install

const (
	TypeLoggingConfig TypeName = iota + 50
	TypeLoggingStatusReq
	TypeLoggingStatusRep
	TypeLoggingReport
)

logging

const (
	TypeRPARun TypeName = iota + 60
	TypeRPALog
	TypeRPAControlReq
	TypeRPAControlRep
	TypeRPAFinish
)

rpa

const (
	TypeRPASelectorReq TypeName = iota + 70
	TypeRPASelectorRep
	TypeRPASelectorResult
	TypeRPASelectorValidateReq
	TypeRPASelectorValidateRep
)

rpa-selector

const (
	TypeIPMIDeviceInfoReq TypeName = iota + 80
	TypeIPMIDeviceInfoRep
	TypeIPMISensorListReq
	TypeIPMISensorListRep
)

ipmi

const (
	TypeSNMPListReq TypeName = iota + 90
	TypeSNMPListRep
)

snmp

const (
	TypeLogLsReq        TypeName = iota + 10000 // 10000:查询log文件列表
	TypeLogLsRep                                // 10001: 返回log文件列表
	TypeLogDownloadReq                          // 10002:请求log文件
	TypeLogDownloadInfo                         // 10003:返回log文件详情
	TypeLogDownloadData                         // 10004: 返回log文件内容
)

agent log

const TypeAgentInfo TypeName = iota + 7 // 7: agent状态上报

func (TypeName) String

func (name TypeName) String() string

type Upload

type Upload struct {
	Dir      string         `json:"dir"`                 // 路径
	Name     string         `json:"name"`                // 文件名
	Auth     string         `json:"auth,omitempty"`      // 是否提权,su、sudo或空
	User     string         `json:"user,omitempty"`      // 提权用户
	Pass     string         `json:"pass,omitempty"`      // 提权密码
	Mod      os.FileMode    `json:"mod"`                 // 文件权限
	OwnUser  string         `json:"own_user,omitempty"`  // 上传文件所属用户
	OwnGroup string         `json:"own_group,omitempty"` // 上传文件所属分组
	Size     uint64         `json:"size,omitempty"`      // 上传文件大小
	MD5      [md5.Size]byte `json:"md5"`                 // 文件md5
	MD5Check bool           `json:"md5_check"`           // 是否校验文件md5
	Data     string         `json:"data,omitempty"`      // 如果文件内容小于1M则直接传输
	Token    string         `json:"token,omitempty"`     // 大于1M时下载的token信息
	URI      string         `json:"uri,omitempty"`       // 从server下载时的uri
}

Upload upload

type UploadRep

type UploadRep struct {
	Dir    string `json:"dir"`           // 路径
	OK     bool   `json:"ok"`            // 是否成功
	ErrMsg string `json:"msg,omitempty"` // 错误时的消息内容
}

UploadRep upload response

type WSWrap

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

WSWrap wrap for websocket

func NewWSWrap

func NewWSWrap(c *websocket.Conn) *WSWrap

NewWSWrap create wrap

func (*WSWrap) Read

func (w *WSWrap) Read(p []byte) (int, error)

func (*WSWrap) Write

func (w *WSWrap) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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