Documentation ¶
Index ¶
- Constants
- Variables
- func LocalMd5Sum(localPath string) string
- func WaitSSHReady(ssh Interface, tryTimes int, hosts ...string) error
- type Client
- type Interface
- type SSH
- func (s *SSH) Cmd(host, cmd string) ([]byte, error)
- func (s *SSH) CmdAsync(host string, cmds ...string) error
- func (s *SSH) CmdToString(host, cmd, spilt string) (string, error)
- func (s *SSH) Connect(host string) (*ssh.Client, *ssh.Session, error)
- func (s *SSH) Copy(host, localPath, remotePath string) error
- func (s *SSH) Fetch(host, localFilePath, remoteFilePath string) error
- func (s *SSH) IsFileExist(host, remoteFilePath string) bool
- func (s *SSH) Ping(host string) error
- func (s *SSH) RemoteDirExist(host, remoteDirpath string) (bool, error)
- func (s *SSH) RemoteMd5Sum(host, remoteFilePath string) string
Constants ¶
View Source
const KByte = 1024
View Source
const MByte = 1024 * 1024
View Source
const (
Md5sumCmd = "md5sum %s | cut -d\" \" -f1"
)
Variables ¶
View Source
var DebugMode bool
Functions ¶
func LocalMd5Sum ¶ added in v0.1.5
Types ¶
type Interface ¶
type Interface interface { // copy local files to remote host // scp -r /tmp root@192.168.0.2:/root/tmp => Copy("192.168.0.2","tmp","/root/tmp") // need check md5sum Copy(host, srcFilePath, dstFilePath string) error // copy remote host files to localhost Fetch(host, srcFilePath, dstFilePath string) error // exec command on remote host, and asynchronous return logs CmdAsync(host string, cmd ...string) error // exec command on remote host, and return combined standard output and standard error Cmd(host, cmd string) ([]byte, error) // check remote file exist or not IsFileExist(host, remoteFilePath string) bool //Remote file existence returns true, nil RemoteDirExist(host, remoteDirpath string) (bool, error) // exec command on remote host, and return spilt standard output and standard error CmdToString(host, cmd, spilt string) (string, error) Ping(host string) error }
func GetHostSSHClient ¶ added in v0.6.0
func NewSSHByCluster ¶
func NewSSHClient ¶ added in v0.6.0
type SSH ¶
type SSH struct { User string Password string PkFile string PkPassword string Timeout *time.Duration LocalAddress *[]net.Addr }
func (*SSH) CmdToString ¶
CmdToString is in host exec cmd and replace to spilt str
func (*SSH) IsFileExist ¶
RemoteFileExist is
func (*SSH) RemoteDirExist ¶
if remote file not exist return false and nil
func (*SSH) RemoteMd5Sum ¶
Click to show internal directories.
Click to hide internal directories.