sshlib

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

README

sshlib

  • This is a sshlib I use for more than 5 year, the main reason I made it is becuse some system not able to install custom opensource tool. Also some usage may not support for opensource ssh tool, like what I wrote sshtail, it can tail hundreds of servers at same time with colorful result.

How to

Use

  • echo "host1 127.0.0.1\nhost2 127.0.0.2\nhost3 127.0.0.3" > host
  • cat host|sshtail -c 'w'

demo

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Logger *logging.Logger
)
View Source
var (
	Manager = NewSshManager()
)
View Source
var Version string

Functions

func CleanResult

func CleanResult(in string) string

func NewLogger

func NewLogger(options *LogOptions) *logging.Logger

Types

type Bucket

type Bucket struct {
	Cmd string
	Res string
}

type Host

type Host struct {
	sync.Mutex
	Id       int
	Hostname string
	ManageIp string
	Mrtg     string
	Port     uint

	Err             chan error
	StdIn           chan string
	StdOut          chan string
	StdErr          chan string
	Running         chan bool
	Stopped         chan bool
	LastResult      string
	Buckets         []*Bucket
	Timeout         time.Duration
	DialTimeout     time.Duration
	FirstCmdTimeout time.Duration
	// contains filtered or unexported fields
}

type LogOptions

type LogOptions struct {
	Name      string
	ShowErr   bool
	ShowDebug bool
	ShowColor bool
}

type Provider

type Provider interface {
	Hosts() []*Host
}

type SshConfig

type SshConfig struct {
	User         string
	IdentityFile string
}

type SshManager

type SshManager struct {
	sync.Mutex
	User     string
	Key      string
	Sudo     bool
	Password []string

	Workers int
	InitCmd string

	HostMap map[string]*Host
	Sig     chan os.Signal
	Log     *log.Logger
	// contains filtered or unexported fields
}

func NewSshManager

func NewSshManager() *SshManager

func (*SshManager) Close

func (manager *SshManager) Close()

func (*SshManager) Listenning

func (manager *SshManager) Listenning()

func (*SshManager) ListenningSig

func (manager *SshManager) ListenningSig()

func (*SshManager) Prepare

func (manager *SshManager) Prepare()

func (*SshManager) Process

func (manager *SshManager) Process(host *Host) *Host

setup host

func (*SshManager) SetSudoPassword

func (m *SshManager) SetSudoPassword(p string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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