Documentation ¶
Index ¶
- Constants
- Variables
- func AuthWithAgent() (ssh.AuthMethod, error)
- func AuthWithPrivateKeyBytes(key []byte, password string) (ssh.AuthMethod, error)
- func Dial(network, addr string, config *ssh.ClientConfig) (net.Conn, *ssh.Client, error)
- func GetAllStats(client *Client, stats *Stats, wg *sync.WaitGroup) error
- func RegisterSessionGauge(g Gauge)
- type CPUInfo
- type Client
- func (c *Client) Chmod(path string) error
- func (c *Client) Close() error
- func (c *Client) CollectTargetMachineInfo() error
- func (c *Client) GetFile(path string) (*sftp.File, error)
- func (c *Client) GetPwd() (string, error)
- func (c *Client) GetRWFile(path string) (*sftp.File, error)
- func (c *Client) GetSSHClient() *ssh.Client
- func (c *Client) GetSftpClient() *sftp.Client
- func (c *Client) GetTargetMachineOs() string
- func (c *Client) IsDir(path string) bool
- func (c *Client) MkdirAll(dirPath string) error
- func (c *Client) NewPty() (*Session, error)
- func (c *Client) NewSession() (*Session, error)
- func (c *Client) NewSessionWithPty(cols, rows int) (*Session, error)
- func (c *Client) NewSftpClient() error
- func (c *Client) Notify(ch chan *Client)
- func (c *Client) PathExists(path string) bool
- func (c *Client) Ping() error
- func (c *Client) ReadDir(path string) ([]os.FileInfo, error)
- func (c *Client) ReadLink(path string) (string, error)
- func (c *Client) RealPath(path string) (string, error)
- func (c *Client) Remove(path string) error
- func (c *Client) RemoveDir(remoteDir string) error
- func (c *Client) SendRequest(name string, wantReply bool, payload []byte) (bool, []byte, error)
- func (c *Client) Stat(path string) (os.FileInfo, error)
- func (c *Client) UploadFile(local, fPath string, fName string) error
- func (c *Client) UploadFileRaw(context string, fPath string) error
- func (c *Client) UploadHttpFile(fileH *multipart.FileHeader, remote string) error
- type ClientConfig
- type FSInfo
- type Gauge
- type MachineInfo
- type NetIntfInfo
- type Session
- func (s *Session) Close() error
- func (s *Session) Kill() error
- func (s *Session) Output(cmd string) ([]byte, error)
- func (s *Session) OutputContext(ctx context.Context, cmd string) ([]byte, error)
- func (s *Session) Run(cmd string) error
- func (s *Session) RunScript(shell string, sudo bool, fPath string) ([]byte, error)
- func (s *Session) SetStderr(stderr io.Writer)
- func (s *Session) SetStdout(stdout io.Writer)
- func (s *Session) Shell() error
- func (s *Session) Start(cmd string) error
- func (s *Session) Sudo(cmd, passwd string) ([]byte, error)
- func (s *Session) SudoContext(ctx context.Context, cmd, passwd string) ([]byte, error)
- func (s *Session) Wait() error
- func (s *Session) WindowChange(h, w int) error
- func (s *Session) Write(b []byte) (int, error)
- type Stats
Constants ¶
View Source
const ( WindowsShellExt = ".bat" LinuxShellExt = ".sh" )
View Source
const ( KillSignal = "0x09" KeepAliveMessage = "keepalive@golang.org" GOOSLinux = "linux" GOOSFreeBSD = "freebsd" GOOSWindows = "windows" GOOSDarwin = "darwin" GOOSUnknown = "unknown" ArchAmd64 = "amd64" ArchI386 = "386" ArchArm = "arm" ArchUnknown = "unknown" DefaultPtyCols = 200 DefaultPtyRows = 40 )
View Source
const (
CmiTimeLayout = "20060102150405.999999"
)
Variables ¶
View Source
var ( DefaultTimeoutSec = utils.GetEnvInt("ENV_SSH_DIAL_TIMEOUT", defaultTimeout) DefaultRWTimeoutSec = utils.GetEnvInt("ENV_SSH_RW_TIMEOUT", defaultRWTimeout) SSHDialTimeout = time.Duration(DefaultTimeoutSec) * time.Second SSHRWTimeout = time.Duration(DefaultRWTimeoutSec) * time.Second )
Functions ¶
func AuthWithAgent ¶
func AuthWithAgent() (ssh.AuthMethod, error)
AuthWithAgent use already authed user
func AuthWithPrivateKeyBytes ¶
func AuthWithPrivateKeyBytes(key []byte, password string) (ssh.AuthMethod, error)
AuthWithPrivateKeyBytes 直接通过秘钥的bytes
func RegisterSessionGauge ¶
func RegisterSessionGauge(g Gauge)
RegisterSessionGauge call register a gauge listen session num
Types ¶
type CPUInfo ¶
type CPUInfo struct { Usage float32 `json:"usage"` User float32 `json:"user"` Nice float32 `json:"nice"` System float32 `json:"system"` Idle float32 `json:"idle"` Iowait float32 `json:"iowait"` Irq float32 `json:"irq"` SoftIrq float32 `json:"soft_irq"` Steal float32 `json:"steal"` Guest float32 `json:"guest"` }
type Client ¶
type Client struct { Info *MachineInfo Conf *ClientConfig // contains filtered or unexported fields }
func (*Client) CollectTargetMachineInfo ¶
func (*Client) GetSSHClient ¶
func (*Client) GetSftpClient ¶
func (*Client) GetTargetMachineOs ¶
func (*Client) NewSession ¶
func (*Client) NewSessionWithPty ¶
func (*Client) NewSftpClient ¶
func (*Client) PathExists ¶
func (*Client) SendRequest ¶
func (*Client) UploadHttpFile ¶
func (c *Client) UploadHttpFile(fileH *multipart.FileHeader, remote string) error
type ClientConfig ¶
type ClientConfig struct { ID int `json:"-"` Host string `json:"host"` User string `json:"user"` Password string `json:"password"` Passphrase string `json:"passphrase"` KeyBytes []byte `json:"key_bytes"` Port int `json:"port"` }
func (*ClientConfig) Serialize ¶
func (h *ClientConfig) Serialize() int64
type MachineInfo ¶
type NetIntfInfo ¶
type Session ¶
type Session struct { Client *Client // contains filtered or unexported fields }
func (*Session) OutputContext ¶
OutputContext run done and return output with context
func (*Session) SudoContext ¶
func (*Session) WindowChange ¶
type Stats ¶
type Stats struct { Uptime time.Duration `json:"uptime"` StartUpTime string `json:"start_up_time"` Hostname string `json:"hostname"` Load1 string `json:"load_1"` Load5 string `json:"load_5"` Load10 string `json:"load_10"` RunningProcs string `json:"running_procs"` TotalProcs string `json:"total_procs"` MemTotal uint64 `json:"mem_total"` MemFree uint64 `json:"mem_free"` MemUsage float32 `json:"mem_usage"` MemBuffers uint64 `json:"mem_buffers"` MemCached uint64 `json:"mem_cached"` SwapTotal uint64 `json:"swap_total"` SwapFree uint64 `json:"swap_free"` SwapUsage float32 `json:"swap_usage"` FSInfos []FSInfo `json:"fs_infos"` NetIntf map[string]NetIntfInfo `json:"-"` CPU CPUInfo `json:"cpu"` PreCPU *cpuRaw `json:"-"` }
Click to show internal directories.
Click to hide internal directories.