system

package
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_USER_AGENT_PREFIX = "goss/"
View Source
const USER_AGENT_HEADER_PREFIX = "user-agent:"

Variables

View Source
var ErrNullPackage = errors.New("Could not detect Package type on this system, please use --package flag to explicity set it")

Functions

func DNSlookup added in v0.2.6

func DNSlookup(host string, server string, qtype string, timeout int) ([]string, error)

func DetectDistro added in v0.1.4

func DetectDistro() string

DetectDistro attempts to detect which Linux distribution this computer is using. One of "ubuntu", "redhat" (including Centos), "alpine", "arch", or "debian". If it can't decide, it returns an empty string.

func DetectPackageManager added in v0.1.4

func DetectPackageManager() string

DetectPackageManager attempts to detect whether or not the system is using "dpkg", "rpm", "apk", or "pacman" package managers. It first attempts to detect the distro. If that fails, it falls back to finding package manager executables. If that fails, it returns the empty string.

func DetectService added in v0.1.4

func DetectService() string

DetectService attempts to detect what kind of service management the system is using, "systemd", "upstart", "alpineinit", or "init". It looks for systemctl command to detect systemd, and falls back on DetectDistro otherwise. If it can't decide, it returns "init".

func GetPorts

func GetPorts(lookupPids bool) map[string][]GOnetstat.Process

FIXME: Is there a better way to do this rather than ignoring errors?

func GetProcs added in v0.0.4

func GetProcs() (map[string][]ps.Process, error)

func HasCommand added in v0.1.4

func HasCommand(cmd string) bool

HasCommand returns whether or not an executable by this name is on the PATH.

func HeaderToArray added in v0.3.21

func HeaderToArray(header http.Header) (res []string)

func IsSupportedPackageManager added in v0.3.21

func IsSupportedPackageManager(p string) bool

IsSupportedPackageManager determines if p is a supported package manager

func LookupA added in v0.2.6

func LookupA(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error)

A record lookup

func LookupAAAA added in v0.2.6

func LookupAAAA(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error)

AAAA (IPv6) record lookup

func LookupCAA added in v0.3.3

func LookupCAA(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error)

CAA record lookup

func LookupCNAME added in v0.2.6

func LookupCNAME(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error)

CNAME record lookup

func LookupHost added in v0.2.6

func LookupHost(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error)

A and AAAA record lookup - similar to net.LookupHost

func LookupMX added in v0.2.6

func LookupMX(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error)

MX record lookup

func LookupNS added in v0.2.6

func LookupNS(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error)

NS record lookup

func LookupPTR added in v0.2.6

func LookupPTR(addr string, server string, c *dns.Client, m *dns.Msg) (name []string, err error)

PTR record lookup

func LookupSRV added in v0.2.6

func LookupSRV(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error)

SRV record lookup

func LookupTXT added in v0.2.6

func LookupTXT(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error)

TXT record lookup

func SupportedPackageManagers added in v0.3.21

func SupportedPackageManagers() []string

SupportedPackageManagers is a list of package managers we support

Types

type Addr

type Addr interface {
	Address() string
	Exists() (bool, error)
	Reachable() (bool, error)
}

func NewDefAddr added in v0.0.4

func NewDefAddr(_ context.Context, address string, system *System, config util.Config) Addr

type AlpinePackage added in v0.0.20

type AlpinePackage struct {
	// contains filtered or unexported fields
}

func (*AlpinePackage) Exists added in v0.0.20

func (p *AlpinePackage) Exists() (bool, error)

func (*AlpinePackage) Installed added in v0.0.20

func (p *AlpinePackage) Installed() (bool, error)

func (*AlpinePackage) Name added in v0.0.20

func (p *AlpinePackage) Name() string

func (*AlpinePackage) Versions added in v0.0.20

func (p *AlpinePackage) Versions() ([]string, error)

type Command

type Command interface {
	Command() string
	Exists() (bool, error)
	ExitStatus() (int, error)
	Stdout() (io.Reader, error)
	Stderr() (io.Reader, error)
}

func NewDefCommand added in v0.0.4

func NewDefCommand(ctx context.Context, command string, system *System, config util.Config) Command

type DNS

type DNS interface {
	Host() string
	Addrs() ([]string, error)
	Resolvable() (bool, error)
	Exists() (bool, error)
	Server() string
	Qtype() string
}

func NewDefDNS added in v0.0.4

func NewDefDNS(_ context.Context, host string, system *System, config util.Config) DNS

type DebPackage added in v0.0.4

type DebPackage struct {
	// contains filtered or unexported fields
}

func (*DebPackage) Exists added in v0.0.4

func (p *DebPackage) Exists() (bool, error)

func (*DebPackage) Installed added in v0.0.4

func (p *DebPackage) Installed() (bool, error)

func (*DebPackage) Name added in v0.0.4

func (p *DebPackage) Name() string

func (*DebPackage) Versions added in v0.0.4

func (p *DebPackage) Versions() ([]string, error)

type DefAddr added in v0.0.4

type DefAddr struct {
	LocalAddress string
	Timeout      int
	// contains filtered or unexported fields
}

func (*DefAddr) Address added in v0.0.4

func (a *DefAddr) Address() string

func (*DefAddr) Exists added in v0.0.4

func (a *DefAddr) Exists() (bool, error)

func (*DefAddr) ID added in v0.0.4

func (a *DefAddr) ID() string

func (*DefAddr) Reachable added in v0.0.4

func (a *DefAddr) Reachable() (bool, error)

type DefCommand added in v0.0.4

type DefCommand struct {
	Ctx context.Context

	Timeout int
	// contains filtered or unexported fields
}

func (*DefCommand) Command added in v0.0.4

func (c *DefCommand) Command() string

func (*DefCommand) Exists added in v0.0.4

func (c *DefCommand) Exists() (bool, error)

Stub out

func (*DefCommand) ExitStatus added in v0.0.4

func (c *DefCommand) ExitStatus() (int, error)

func (*DefCommand) Stderr added in v0.0.4

func (c *DefCommand) Stderr() (io.Reader, error)

func (*DefCommand) Stdout added in v0.0.4

func (c *DefCommand) Stdout() (io.Reader, error)

type DefDNS added in v0.0.4

type DefDNS struct {
	Timeout int
	// contains filtered or unexported fields
}

func (*DefDNS) Addrs added in v0.0.4

func (d *DefDNS) Addrs() ([]string, error)

func (*DefDNS) Exists added in v0.0.4

func (d *DefDNS) Exists() (bool, error)

Stub out

func (*DefDNS) Host added in v0.0.4

func (d *DefDNS) Host() string

func (*DefDNS) Qtype added in v0.2.6

func (d *DefDNS) Qtype() string

func (*DefDNS) Resolvable added in v0.3.5

func (d *DefDNS) Resolvable() (bool, error)

func (*DefDNS) Server added in v0.2.6

func (d *DefDNS) Server() string

type DefFile added in v0.0.4

type DefFile struct {
	// contains filtered or unexported fields
}

func (*DefFile) Contents added in v0.4.0

func (f *DefFile) Contents() (io.Reader, error)

func (*DefFile) Exists added in v0.0.4

func (f *DefFile) Exists() (bool, error)

func (*DefFile) Filetype added in v0.0.4

func (f *DefFile) Filetype() (string, error)

func (*DefFile) Gid added in v0.4.5

func (f *DefFile) Gid() (int, error)

func (*DefFile) Group added in v0.0.4

func (f *DefFile) Group() (string, error)

func (*DefFile) LinkedTo added in v0.0.4

func (f *DefFile) LinkedTo() (string, error)

func (*DefFile) Md5 added in v0.2.6

func (f *DefFile) Md5() (string, error)

func (*DefFile) Mode added in v0.0.4

func (f *DefFile) Mode() (string, error)

func (*DefFile) Owner added in v0.0.4

func (f *DefFile) Owner() (string, error)

func (*DefFile) Path added in v0.0.4

func (f *DefFile) Path() string

func (*DefFile) Sha256 added in v0.3.3

func (f *DefFile) Sha256() (string, error)

func (*DefFile) Sha512 added in v0.3.21

func (f *DefFile) Sha512() (string, error)

func (*DefFile) Size added in v0.1.7

func (f *DefFile) Size() (int, error)

func (*DefFile) Uid added in v0.4.5

func (f *DefFile) Uid() (int, error)

type DefGossfile added in v0.0.4

type DefGossfile struct {
	// contains filtered or unexported fields
}

func (*DefGossfile) Exists added in v0.0.4

func (g *DefGossfile) Exists() (bool, error)

Stub out

func (*DefGossfile) Path added in v0.0.4

func (g *DefGossfile) Path() string

type DefGroup added in v0.0.4

type DefGroup struct {
	// contains filtered or unexported fields
}

func (*DefGroup) Exists added in v0.0.4

func (u *DefGroup) Exists() (bool, error)

func (*DefGroup) GID added in v0.1.0

func (u *DefGroup) GID() (int, error)

func (*DefGroup) Groupname added in v0.0.4

func (u *DefGroup) Groupname() string

type DefHTTP added in v0.1.10

type DefHTTP struct {
	RequestHeader http.Header
	RequestBody   string
	Timeout       int

	Username string
	Password string
	CAFile   string
	CertFile string
	KeyFile  string
	Method   string
	Proxy    string
	// contains filtered or unexported fields
}

func (*DefHTTP) Body added in v0.1.10

func (u *DefHTTP) Body() (io.Reader, error)

func (*DefHTTP) Exists added in v0.1.10

func (u *DefHTTP) Exists() (bool, error)

func (*DefHTTP) HTTP added in v0.1.10

func (u *DefHTTP) HTTP() string

func (*DefHTTP) Headers added in v0.3.21

func (u *DefHTTP) Headers() (io.Reader, error)

func (*DefHTTP) ID added in v0.1.10

func (u *DefHTTP) ID() string

func (*DefHTTP) SetAllowInsecure added in v0.1.10

func (u *DefHTTP) SetAllowInsecure(t bool)

func (*DefHTTP) SetNoFollowRedirects added in v0.2.5

func (u *DefHTTP) SetNoFollowRedirects(t bool)

func (*DefHTTP) Status added in v0.1.10

func (u *DefHTTP) Status() (int, error)

type DefInterface added in v0.1.8

type DefInterface struct {
	// contains filtered or unexported fields
}

func (*DefInterface) Addrs added in v0.1.8

func (i *DefInterface) Addrs() ([]string, error)

func (*DefInterface) Exists added in v0.1.8

func (i *DefInterface) Exists() (bool, error)

func (*DefInterface) ID added in v0.1.8

func (i *DefInterface) ID() string

func (*DefInterface) MTU added in v0.3.6

func (i *DefInterface) MTU() (int, error)

func (*DefInterface) Name added in v0.1.8

func (i *DefInterface) Name() string

type DefKernelParam added in v0.1.8

type DefKernelParam struct {
	// contains filtered or unexported fields
}

func (*DefKernelParam) Exists added in v0.1.8

func (k *DefKernelParam) Exists() (bool, error)

func (*DefKernelParam) ID added in v0.1.8

func (k *DefKernelParam) ID() string

func (*DefKernelParam) Key added in v0.1.8

func (k *DefKernelParam) Key() string

func (*DefKernelParam) Value added in v0.1.8

func (k *DefKernelParam) Value() (string, error)

type DefMount added in v0.1.8

type DefMount struct {
	Timeout int
	// contains filtered or unexported fields
}

func (*DefMount) Exists added in v0.1.8

func (m *DefMount) Exists() (bool, error)

func (*DefMount) Filesystem added in v0.1.8

func (m *DefMount) Filesystem() (string, error)

func (*DefMount) ID added in v0.1.8

func (m *DefMount) ID() string

func (*DefMount) MountPoint added in v0.1.8

func (m *DefMount) MountPoint() string

func (*DefMount) Opts added in v0.1.8

func (m *DefMount) Opts() ([]string, error)

func (*DefMount) Source added in v0.1.8

func (m *DefMount) Source() (string, error)

func (*DefMount) Usage added in v0.3.21

func (m *DefMount) Usage() (int, error)

func (*DefMount) VfsOpts added in v0.4.0

func (m *DefMount) VfsOpts() ([]string, error)

type DefPort added in v0.0.4

type DefPort struct {
	// contains filtered or unexported fields
}

func (*DefPort) Exists added in v0.0.4

func (p *DefPort) Exists() (bool, error)

func (*DefPort) IP added in v0.0.4

func (p *DefPort) IP() ([]string, error)

func (*DefPort) Listening added in v0.0.4

func (p *DefPort) Listening() (bool, error)

func (*DefPort) Port added in v0.0.4

func (p *DefPort) Port() string

type DefProcess added in v0.0.4

type DefProcess struct {
	// contains filtered or unexported fields
}

func (*DefProcess) Executable added in v0.0.4

func (p *DefProcess) Executable() string

func (*DefProcess) Exists added in v0.0.4

func (p *DefProcess) Exists() (bool, error)

func (*DefProcess) Pids added in v0.0.4

func (p *DefProcess) Pids() ([]int, error)

func (*DefProcess) Running added in v0.0.4

func (p *DefProcess) Running() (bool, error)

type DefUser added in v0.0.4

type DefUser struct {
	// contains filtered or unexported fields
}

func (*DefUser) Exists added in v0.0.4

func (u *DefUser) Exists() (bool, error)

func (*DefUser) GID added in v0.0.4

func (u *DefUser) GID() (int, error)

func (*DefUser) Groups added in v0.0.4

func (u *DefUser) Groups() ([]string, error)

func (*DefUser) Home added in v0.0.4

func (u *DefUser) Home() (string, error)

func (*DefUser) Shell added in v0.1.7

func (u *DefUser) Shell() (string, error)

func (*DefUser) UID added in v0.0.4

func (u *DefUser) UID() (int, error)

func (*DefUser) Username added in v0.0.4

func (u *DefUser) Username() string

type File

type File interface {
	Path() string
	Exists() (bool, error)
	Contents() (io.Reader, error)
	Mode() (string, error)
	Size() (int, error)
	Filetype() (string, error)
	Owner() (string, error)
	Uid() (int, error)
	Group() (string, error)
	Gid() (int, error)
	LinkedTo() (string, error)
	Md5() (string, error)
	Sha256() (string, error)
	Sha512() (string, error)
}

func NewDefFile added in v0.0.4

func NewDefFile(_ context.Context, path string, system *System, config util.Config) File

type Gossfile

type Gossfile interface {
	Path() string
	Exists() (bool, error)
}

func NewDefGossfile added in v0.0.4

func NewDefGossfile(_ context.Context, path string, system *System, config util.Config) Gossfile

type Group

type Group interface {
	Groupname() string
	Exists() (bool, error)
	GID() (int, error)
}

func NewDefGroup added in v0.0.4

func NewDefGroup(_ context.Context, groupname string, system *System, config util.Config) Group

type HTTP added in v0.1.10

type HTTP interface {
	HTTP() string
	Status() (int, error)
	Headers() (io.Reader, error)
	Body() (io.Reader, error)
	Exists() (bool, error)
	SetAllowInsecure(bool)
	SetNoFollowRedirects(bool)
}

func NewDefHTTP added in v0.1.10

func NewDefHTTP(_ context.Context, httpStr string, system *System, config util.Config) HTTP

type Interface added in v0.1.8

type Interface interface {
	Name() string
	Exists() (bool, error)
	Addrs() ([]string, error)
	MTU() (int, error)
}

func NewDefInterface added in v0.1.8

func NewDefInterface(_ context.Context, name string, systei *System, config util.Config) Interface

type KernelParam added in v0.1.8

type KernelParam interface {
	Key() string
	Exists() (bool, error)
	Value() (string, error)
}

func NewDefKernelParam added in v0.1.8

func NewDefKernelParam(_ context.Context, key string, system *System, config util.Config) KernelParam

type Mount added in v0.1.8

type Mount interface {
	MountPoint() string
	Exists() (bool, error)
	Opts() ([]string, error)
	VfsOpts() ([]string, error)
	Source() (string, error)
	Filesystem() (string, error)
	Usage() (int, error)
}

func NewDefMount added in v0.1.8

func NewDefMount(_ context.Context, mountPoint string, system *System, config util.Config) Mount

type NullPackage added in v0.0.4

type NullPackage struct {
	// contains filtered or unexported fields
}

func (*NullPackage) Exists added in v0.0.4

func (p *NullPackage) Exists() (bool, error)

func (*NullPackage) Installed added in v0.0.4

func (p *NullPackage) Installed() (bool, error)

func (*NullPackage) Name added in v0.0.4

func (p *NullPackage) Name() string

func (*NullPackage) Versions added in v0.0.4

func (p *NullPackage) Versions() ([]string, error)

type Package

type Package interface {
	Name() string
	Exists() (bool, error)
	Installed() (bool, error)
	Versions() ([]string, error)
}

func NewAlpinePackage added in v0.0.20

func NewAlpinePackage(_ context.Context, name string, system *System, config util.Config) Package

func NewDebPackage added in v0.0.4

func NewDebPackage(_ context.Context, name string, system *System, config util.Config) Package

func NewNullPackage added in v0.0.4

func NewNullPackage(_ context.Context, name string, system *System, config util.Config) Package

func NewPacmanPackage added in v0.1.4

func NewPacmanPackage(_ context.Context, name string, system *System, config util.Config) Package

func NewRpmPackage added in v0.0.4

func NewRpmPackage(_ context.Context, name string, system *System, config util.Config) Package

type PacmanPackage added in v0.1.4

type PacmanPackage struct {
	// contains filtered or unexported fields
}

func (*PacmanPackage) Exists added in v0.1.4

func (p *PacmanPackage) Exists() (bool, error)

func (*PacmanPackage) Installed added in v0.1.4

func (p *PacmanPackage) Installed() (bool, error)

func (*PacmanPackage) Name added in v0.1.4

func (p *PacmanPackage) Name() string

func (*PacmanPackage) Versions added in v0.1.4

func (p *PacmanPackage) Versions() ([]string, error)

type Port

type Port interface {
	Port() string
	Exists() (bool, error)
	Listening() (bool, error)
	IP() ([]string, error)
}

func NewDefPort added in v0.0.4

func NewDefPort(_ context.Context, port string, system *System, config util.Config) Port

type Process

type Process interface {
	Executable() string
	Exists() (bool, error)
	Running() (bool, error)
	Pids() ([]int, error)
}

func NewDefProcess added in v0.0.4

func NewDefProcess(_ context.Context, executable string, system *System, config util.Config) Process

type Resource

type Resource interface {
	Exists() (bool, error)
}

type RpmPackage added in v0.0.4

type RpmPackage struct {
	// contains filtered or unexported fields
}

func (*RpmPackage) Exists added in v0.0.4

func (p *RpmPackage) Exists() (bool, error)

func (*RpmPackage) Installed added in v0.0.4

func (p *RpmPackage) Installed() (bool, error)

func (*RpmPackage) Name added in v0.0.4

func (p *RpmPackage) Name() string

func (*RpmPackage) Versions added in v0.0.4

func (p *RpmPackage) Versions() ([]string, error)

type Service

type Service interface {
	Service() string
	Exists() (bool, error)
	Enabled() (bool, error)
	Running() (bool, error)
	RunLevels() ([]string, error)
}

func NewAlpineServiceInit added in v0.0.20

func NewAlpineServiceInit(_ context.Context, service string, system *System, config util.Config) Service

func NewServiceInit

func NewServiceInit(_ context.Context, service string, system *System, config util.Config) Service

func NewServiceSystemd added in v0.1.8

func NewServiceSystemd(_ context.Context, service string, system *System, config util.Config) Service

func NewServiceSystemdLegacy added in v0.3.21

func NewServiceSystemdLegacy(_ context.Context, service string, system *System, config util.Config) Service

func NewServiceUpstart added in v0.0.14

func NewServiceUpstart(_ context.Context, service string, system *System, config util.Config) Service

type ServiceInit

type ServiceInit struct {
	// contains filtered or unexported fields
}

func (*ServiceInit) Enabled

func (s *ServiceInit) Enabled() (bool, error)

func (*ServiceInit) Exists added in v0.0.2

func (s *ServiceInit) Exists() (bool, error)

func (*ServiceInit) RunLevels added in v0.4.0

func (s *ServiceInit) RunLevels() ([]string, error)

func (*ServiceInit) Running

func (s *ServiceInit) Running() (bool, error)

func (*ServiceInit) Service

func (s *ServiceInit) Service() string

type ServiceSystemd added in v0.1.8

type ServiceSystemd struct {
	// contains filtered or unexported fields
}

func (*ServiceSystemd) Enabled added in v0.1.8

func (s *ServiceSystemd) Enabled() (bool, error)

func (*ServiceSystemd) Exists added in v0.1.8

func (s *ServiceSystemd) Exists() (bool, error)

func (*ServiceSystemd) RunLevels added in v0.4.0

func (s *ServiceSystemd) RunLevels() ([]string, error)

func (*ServiceSystemd) Running added in v0.1.8

func (s *ServiceSystemd) Running() (bool, error)

func (*ServiceSystemd) Service added in v0.1.8

func (s *ServiceSystemd) Service() string

type ServiceUpstart added in v0.0.14

type ServiceUpstart struct {
	// contains filtered or unexported fields
}

func (*ServiceUpstart) Enabled added in v0.0.14

func (s *ServiceUpstart) Enabled() (bool, error)

func (*ServiceUpstart) Exists added in v0.0.14

func (s *ServiceUpstart) Exists() (bool, error)

func (*ServiceUpstart) RunLevels added in v0.4.0

func (s *ServiceUpstart) RunLevels() ([]string, error)

func (*ServiceUpstart) Running added in v0.0.14

func (s *ServiceUpstart) Running() (bool, error)

func (*ServiceUpstart) Service added in v0.0.14

func (s *ServiceUpstart) Service() string

type System

type System struct {
	NewPackage     func(context.Context, string, *System, util2.Config) Package
	NewFile        func(context.Context, string, *System, util2.Config) File
	NewAddr        func(context.Context, string, *System, util2.Config) Addr
	NewPort        func(context.Context, string, *System, util2.Config) Port
	NewService     func(context.Context, string, *System, util2.Config) Service
	NewUser        func(context.Context, string, *System, util2.Config) User
	NewGroup       func(context.Context, string, *System, util2.Config) Group
	NewCommand     func(context.Context, string, *System, util2.Config) Command
	NewDNS         func(context.Context, string, *System, util2.Config) DNS
	NewProcess     func(context.Context, string, *System, util2.Config) Process
	NewGossfile    func(context.Context, string, *System, util2.Config) Gossfile
	NewKernelParam func(context.Context, string, *System, util2.Config) KernelParam
	NewMount       func(context.Context, string, *System, util2.Config) Mount
	NewInterface   func(context.Context, string, *System, util2.Config) Interface
	NewHTTP        func(context.Context, string, *System, util2.Config) HTTP
	// contains filtered or unexported fields
}

func New

func New(packageManager string) *System

func (*System) Ports

func (s *System) Ports() map[string][]GOnetstat.Process

func (*System) ProcMap added in v0.0.4

func (s *System) ProcMap() (map[string][]ps.Process, error)

type User

type User interface {
	Username() string
	Exists() (bool, error)
	UID() (int, error)
	GID() (int, error)
	Groups() ([]string, error)
	Home() (string, error)
	Shell() (string, error)
}

func NewDefUser added in v0.0.4

func NewDefUser(_ context.Context, username string, system *System, config util.Config) User

Jump to

Keyboard shortcuts

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