ssh

package
v0.0.0-...-c3423aa Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package ssh is the ssh probe package

Index

Constants

View Source
const Kind string = "ssh"

Kind is the type of probe

Variables

This section is empty.

Functions

This section is empty.

Types

type BastionMapType

type BastionMapType map[string]Endpoint

BastionMapType is the type of bastion

var BastionMap BastionMapType

BastionMap is a map of bastion

func (*BastionMapType) ParseAllBastionHost

func (bm *BastionMapType) ParseAllBastionHost()

ParseAllBastionHost parse all bastion host

type Endpoint

type Endpoint struct {
	PrivateKey string `yaml:"key" json:"key,omitempty" jsonschema:"title=Private Key,description=the private key file path for ssh login"`
	Passphrase string `yaml:"passphrase" json:"passphrase,omitempty" jsonschema:"title=Passphrase,description=the passphrase for ssh private key"`
	Host       string `yaml:"host" json:"host" jsonschema:"required,format=hostname,title=Host,description=the host for ssh probe"`
	User       string `yaml:"username" json:"username,omitempty" jsonschema:"title=User,description=the username for ssh probe"`
	Password   string `yaml:"password" json:"password,omitempty" jsonschema:"title=Password,description=the password for ssh probe"`
	// contains filtered or unexported fields
}

Endpoint is SSH Endpoint

func (*Endpoint) ParseHost

func (e *Endpoint) ParseHost() error

ParseHost check the host is configured the port or not

func (*Endpoint) SSHConfig

func (e *Endpoint) SSHConfig(kind, name string, timeout time.Duration) (*ssh.ClientConfig, error)

SSHConfig returns the ssh.ClientConfig

type SSH

type SSH struct {
	Bastion *BastionMapType `yaml:"bastion" json:"bastion,omitempty" jsonschema:"title=Bastion Servers,description=the bastion hosts configuration"`
	Servers []Server        `yaml:"servers" json:"servers" jsonschema:"required,title=SSH Servers,description=SSH servers to probe"`
}

SSH is the SSH probe Configuration

type Server

type Server struct {
	base.DefaultProbe `yaml:",inline"`
	Endpoint          `yaml:",inline"`
	Command           string   `yaml:"cmd" json:"cmd,omitempty" jsonschema:"title=Shell Command,description=command to run"`
	Args              []string `yaml:"args,omitempty" json:"args,omitempty" jsonschema:"title=Shell Command Arguments,description=arguments for the command"`
	Env               []string `` /* 132-byte string literal not displayed */

	// Output Text Checker
	probe.TextChecker `yaml:",inline"`

	BastionID string `yaml:"bastion" json:"bastion,omitempty" jsonschema:"title=Bastion Server,description=the bastion host id"`
	// contains filtered or unexported fields
}

Server implements a config for ssh command

func (*Server) Config

func (s *Server) Config(gConf global.ProbeSettings) error

Config SSH Config Object

func (*Server) Configure

func (s *Server) Configure(gConf global.ProbeSettings,
	kind, tag, name, endpoint string,
	bastionMap *BastionMapType, fn base.ProbeFuncType) error

Configure configure the SSH probe

func (*Server) DoProbe

func (s *Server) DoProbe() (bool, string)

DoProbe return the checking result

func (*Server) ExportMetrics

func (s *Server) ExportMetrics()

ExportMetrics export shell metrics

func (*Server) GetSSHClient

func (s *Server) GetSSHClient() error

GetSSHClient returns a ssh.Client

func (*Server) GetSSHClientFromBastion

func (s *Server) GetSSHClientFromBastion() error

GetSSHClientFromBastion returns a ssh.Client via bastion server

func (*Server) RunSSHCmd

func (s *Server) RunSSHCmd() (string, error)

RunSSHCmd run ssh command

func (*Server) SetBastion

func (s *Server) SetBastion(b *Endpoint)

SetBastion set the bastion

Jump to

Keyboard shortcuts

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