sshutil

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewSSHClient

func NewSSHClient(host HostInfo) (client *Client, err error)

func (*Client) Close

func (c *Client) Close()

func (*Client) GetCpuInfo

func (c *Client) GetCpuInfo() (cpuInfo *CpuInfo, err error)

func (*Client) GetMemInfo

func (c *Client) GetMemInfo() (memInfo *MemInfo, err error)

func (*Client) GetNetInfo

func (c *Client) GetNetInfo() (netInfos []*NetInfo, err error)

func (*Client) GetPing

func (c *Client) GetPing() (rtt int64, err error)

func (*Client) GetSession

func (c *Client) GetSession() (*ssh.Session, error)

func (*Client) GetStats

func (c *Client) GetStats() (stats *Stats, err error)

func (*Client) GetUptime

func (c *Client) GetUptime() (uptime int64, err error)

func (*Client) Run

func (c *Client) Run(cmd string) (stdout string, err error)

func (*Client) RunCmd

func (c *Client) RunCmd(cmd string) (stdout string, err error)

type CpuInfo

type CpuInfo struct {
	Percent float64 `json:"percent"`
	User    float64 `json:"user"`
	Nice    float64 `json:"nice"`
	System  float64 `json:"system"`
	Idle    float64 `json:"idle"`
	IOWait  float64 `json:"iowait"`
	Irq     float64 `json:"irq"`
	SoftIrq float64 `json:"softIrq"`
	Steal   float64 `json:"steal"`
	Guest   float64 `json:"guest"`
	Cores   uint    `json:"cores"`
	// contains filtered or unexported fields
}

CpuInfo cpu信息

func (*CpuInfo) Default

func (i *CpuInfo) Default()

type HostInfo

type HostInfo struct {
	Host       string `json:"host"`
	Port       uint16 `json:"port"`
	Username   string `json:"username"`
	Password   string `json:"password"`
	PrivateKey string `json:"privateKey"`
	Passphrase string `json:"passphrase"`
}

func (*HostInfo) GetAuthMethods

func (h *HostInfo) GetAuthMethods() []ssh.AuthMethod

func (*HostInfo) Scan

func (h *HostInfo) Scan(val interface{}) error

func (HostInfo) Value

func (h HostInfo) Value() (driver.Value, error)

type MemInfo

type MemInfo struct {
	Percent   float64 `json:"percent"`
	Total     uint64  `json:"total"`
	Free      uint64  `json:"free"`
	Available uint64  `json:"available"`
	Buffers   uint64  `json:"buffers"`
	Cached    uint64  `json:"cached"`
	SwapTotal uint64  `json:"swapTotal"`
	SwapFree  uint64  `json:"swapFree"`
}

MemInfo 内存信息

func (*MemInfo) Default

func (i *MemInfo) Default()

type NetInfo

type NetInfo struct {
	Name      string `json:"name"`
	BytesRec  uint64 `json:"bytesRec"`
	BytesSent uint64 `json:"bytesSent"`
	SpeedRec  uint64 `json:"speedRec"`
	SpeedSent uint64 `json:"speedSent"`
}

NetInfo 网络信息

func (*NetInfo) Default

func (i *NetInfo) Default()

type Stats

type Stats struct {
	MemInfo *MemInfo   `json:"memInfo"`
	CpuInfo *CpuInfo   `json:"cpuInfo"`
	NetInfo []*NetInfo `json:"netInfo"`
	Uptime  int64      `json:"uptime"`
	Ping    int64      `json:"ping"`
}

Stats 基础信息

func (*Stats) Default

func (s *Stats) Default()

func (*Stats) ProcessNil

func (s *Stats) ProcessNil()

Jump to

Keyboard shortcuts

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