support

package
v12.120.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 13 Imported by: 28

Documentation

Overview

Package support provides methods for collecting and printing support information about system.

By default, it collects information about the application and environment:

  • Name
  • Version
  • Go version used
  • Binary SHA
  • Git commit SHA

There are also some sub-packages to collect/parse additional information:

  • apps: Package for extracting apps versions info
  • deps: Package for extracting dependency information from gomod data
  • pkgs: Package for collecting information about installed packages
  • services: Package for collecting information about services
  • fs: Package for collecting information about the file system
  • network: Package to collect information about the network

Example of collecting maximum information about the application and system:

support.Collect("TestApp", "12.3.4").
  WithRevision("fc8d81e").
  WithDeps(deps.Extract(gomodData)).
  WithApps(apps.Golang(), apps.GCC()).
  WithPackages(pkgs.Collect("rpm", "go,golang", "java,jre,jdk", "nano")).
  WithServices(services.Collect("firewalld", "nginx")).
  WithChecks(myAppAvailabilityCheck()).
  WithEnvVars("LANG", "PAGER", "SSH_CLIENT").
  WithNetwork(network.Collect("https://domain.com/ip-echo")).
  WithFS(fs.Collect()).
  Print()

Also, you can't encode data to JSON/GOB and send it to your server instead of printing it to the console.

info := support.Collect("TestApp", "12.3.4").
  WithRevision("fc8d81e").
  WithDeps(deps.Extract(gomodData)).
  WithApps(apps.Golang(), apps.GCC()).
  WithPackages(pkgs.Collect("rpm", "go,golang", "java,jre,jdk", "nano")).
  WithServices(services.Collect("firewalld", "nginx")).
  WithChecks(myAppAvailabilityCheck()).
  WithEnvVars("LANG", "PAGER", "SSH_CLIENT").
  WithNetwork(network.Collect("https://domain.com/ip-echo")).
  WithFS(fs.Collect())

b, _ := json.Marshal(info)

fmt.Println(string(b))

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

App contains basic information about app

type BuildInfo

type BuildInfo struct {
	GoVersion string `json:"go_version"`
	GoArch    string `json:"go_arch"`
	GoOS      string `json:"go_os"`

	GitSHA string `json:"git_sha,omitempty"`
	BinSHA string `json:"bin_sha,omitempty"`
}

BuildInfo contains information about binary

type Check added in v12.109.0

type Check struct {
	Status  CheckStatus `json:"status"`
	Title   string      `json:"title"`
	Message string      `json:"message,omitempty"`
}

Check contains info about custom check

type CheckStatus added in v12.109.0

type CheckStatus string
const (
	CHECK_OK    CheckStatus = "ok"
	CHECK_ERROR CheckStatus = "error"
	CHECK_WARN  CheckStatus = "warn"
	CHECK_SKIP  CheckStatus = "skip"
)

type Dep

type Dep struct {
	Path    string `json:"path"`
	Version string `json:"version"`
	Extra   string `json:"extra"`
}

Dep contains dependency information

type EnvVar

type EnvVar struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

EnvVar contains information about environment variable

type FSInfo

type FSInfo struct {
	Path   string `json:"path,omitempty"`
	Device string `json:"device,omitempty"`
	Type   string `json:"type,omitempty"`
	Used   uint64 `json:"used,omitempty"`
	Free   uint64 `json:"free,omitempty"`
}

FSInfo contains basic information about file system mount

type Info

type Info struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	Binary  string `json:"binary"`

	Build    *BuildInfo   `json:"build,omitempty"`
	OS       *OSInfo      `json:"os,omitempty"`
	System   *SystemInfo  `json:"system,omitempty"`
	Network  *NetworkInfo `json:"network,omitempty"`
	FS       []FSInfo     `json:"fs,omitempty"`
	Pkgs     []Pkg        `json:"pkgs,omitempty"`
	Services []Service    `json:"services,omitempty"`
	Deps     []Dep        `json:"deps,omitempty"`
	Apps     []App        `json:"apps,omitempty"`
	Checks   []Check      `json:"checks,omitempty"`
	Env      []EnvVar     `json:"env,omitempty"`
}

Info contains all support information (can be encoded in JSON/GOB)

func Collect

func Collect(app, ver string) *Info

Collect collects basic info about system

func (*Info) Print

func (i *Info) Print()

Print prints support info

func (*Info) WithApps

func (i *Info) WithApps(apps ...App) *Info

WithPackages adds information about system apps

func (*Info) WithChecks added in v12.109.0

func (i *Info) WithChecks(check ...Check) *Info

WithChecks adds information custom checks

func (*Info) WithDeps

func (i *Info) WithDeps(deps []Dep) *Info

WithDeps adds information about dependencies

func (*Info) WithEnvVars

func (i *Info) WithEnvVars(vars ...string) *Info

WithEnvVars adds information with environment variables

func (*Info) WithFS

func (i *Info) WithFS(info []FSInfo) *Info

WithFS adds file system information

func (*Info) WithNetwork

func (i *Info) WithNetwork(info *NetworkInfo) *Info

WithNetwork adds information about the network

func (*Info) WithPackages

func (i *Info) WithPackages(pkgs []Pkg) *Info

WithPackages adds information about packages

func (*Info) WithRevision

func (i *Info) WithRevision(rev string) *Info

WithRevision adds git revision

func (*Info) WithServices added in v12.119.0

func (i *Info) WithServices(services []Service) *Info

WithServices adds information about services

type NetworkInfo

type NetworkInfo struct {
	Hostname string   `json:"hostname"`
	PublicIP string   `json:"public_ip,omitempty"`
	IPv4     []string `json:"ipv4"`
	IPv6     []string `json:"ipv6,omitempty"`
}

NetworkInfo contains basic information about network

type OSInfo

type OSInfo struct {
	Name        string `json:"name,omitempty"`
	PrettyName  string `json:"pretty_name,omitempty"`
	Version     string `json:"version,omitempty"`
	Build       string `json:"build,omitempty"`
	ID          string `json:"id,omitempty"`
	IDLike      string `json:"id_like,omitempty"`
	VersionID   string `json:"version_id,omitempty"`
	VersionCode string `json:"version_code,omitempty"`
	PlatformID  string `json:"platform_id,omitempty"`
	CPE         string `json:"cpe,omitempty"`
	// contains filtered or unexported fields
}

OSInfo contains extended information about OS

type Pkg

type Pkg = App

Pkg contains basic information about package

type Service added in v12.119.0

type Service struct {
	Name      string        `json:"name"`
	Status    ServiceStatus `json:"status"`
	IsPresent bool          `json:"is_present"`
	IsEnabled bool          `json:"is_enabled"`
}

Service contains basic info about service

type ServiceStatus added in v12.119.0

type ServiceStatus string
const (
	STATUS_WORKS   ServiceStatus = "works"
	STATUS_STOPPED ServiceStatus = "stopped"
	STATUS_UNKNOWN ServiceStatus = "unknown"
)

type SystemInfo

type SystemInfo struct {
	Name            string `json:"name"`
	Arch            string `json:"arch"`
	Kernel          string `json:"kernel"`
	ContainerEngine string `json:"container_engine,omitempty"`
}

SystemInfo contains basic information about system

Directories

Path Synopsis
Package apps provides methods for obtaining version information about various tools
Package apps provides methods for obtaining version information about various tools
Package pkgs provides methods for collecting information about used dependencies
Package pkgs provides methods for collecting information about used dependencies
Package pkgs provides methods for collecting information about filesystem
Package pkgs provides methods for collecting information about filesystem
Package network provides methods for collecting information about machine network
Package network provides methods for collecting information about machine network
Package pkgs provides methods for collecting information about installed packages
Package pkgs provides methods for collecting information about installed packages
Package services provides methods for collecting information about system services
Package services provides methods for collecting information about system services

Jump to

Keyboard shortcuts

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