Beispiel #1
0
Datei: main.go Projekt: e11it/ddq
func (p *Pool) Connect() error {
	for _, h := range p.Hosts {
		if cl, err := ssh.ConnectWithPassword(h, p.AUser, "inferion"); err == nil {
			p.cl = append(p.cl, cl)
		}
	}

	return nil
}
Beispiel #2
0
Datei: main.go Projekt: e11it/ddq
func main() {
	fmt.Println("test")

	p1 := pool.New("test_pool", "im")
	p1.AddHost("192.168.56.1")
	p1.AddHost("192.168.56.1")
	p1.AddHost("192.168.56.1")
	p1.AddHost("192.168.56.1")
	p1.AddHost("192.168.56.1")
	p1.Connect()
	fmt.Println(p1.Name)
	p1.Exec("date")

	if client, err := ssh.ConnectWithPassword("192.168.56.1", "im", "inferion"); err != nil {
		fmt.Println("Error:", err.Error())
	} else {
		fmt.Println("---------------")
		if out, err := client.Exec("uptime"); err == nil {
			fmt.Printf("Exec: %s\n", out)
		} else {
			fmt.Println("Err:", err.Error())
		}

		fmt.Println("---------------")
		if out, err := client.Exec("df -m|grep '^/dev/'"); err == nil {
			fmt.Printf("Exec: %s\n", out)
		} else {
			fmt.Println("Err:", err.Error())
		}
		fmt.Println("---------------")
		if out, err := client.Exec("uname -r"); err == nil {
			fmt.Printf("Exec: %s\n", out)
		} else {
			fmt.Println("Err:", err.Error())
		}
		client.Close()
	}

}