Documentation
¶
Overview ¶
Package support provides methods for collecting and printing support information about system.
By default, it collects information about the application and environment:
- App name
- App version
- Go version used for build
- Binary SHA checksum
- Git commit SHA checksum
There are also some sub-packages to collect/parse additional information:
- apps: Extracting apps versions info
- deps: Extracting dependency information from gomod data
- pkgs: Collecting information about installed packages
- services: Collecting information about services
- fs: Collecting information about the file system
- network: Collecting information about the network
- resources: Collecting information about CPU and memory
- kernel: Collecting information from OS kernel
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://cloudflare.com/cdn-cgi/trace")).
WithFS(fs.Collect()).
WithResources(resources.Collect()).
WithKernel(kernel.Collect("vm.nr_hugepages*", "vm.swappiness")).
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://cloudflare.com/cdn-cgi/trace")).
WithFS(fs.Collect()).
WithResources(resources.Collect()).
WithKernel(kernel.Collect("vm.nr_hugepages*", "vm.swappiness"))
b, _ := json.Marshal(info)
fmt.Println(string(b))
Index ¶
- type App
- type BuildInfo
- type CPUInfo
- type Check
- type CheckStatus
- type Dep
- type EnvVar
- type FSInfo
- type Info
- func (i *Info) Print()
- func (i *Info) WithApps(apps ...App) *Info
- func (i *Info) WithChecks(check ...Check) *Info
- func (i *Info) WithDeps(deps []Dep) *Info
- func (i *Info) WithEnvVars(vars ...string) *Info
- func (i *Info) WithFS(info []FSInfo) *Info
- func (i *Info) WithKernel(info []KernelParam) *Info
- func (i *Info) WithNetwork(info *NetworkInfo) *Info
- func (i *Info) WithPackages(pkgs []Pkg) *Info
- func (i *Info) WithResources(info *ResourcesInfo) *Info
- func (i *Info) WithRevision(rev string) *Info
- func (i *Info) WithServices(services []Service) *Info
- type KernelParam
- type NetworkInfo
- type OSInfo
- type Pkg
- type ResourcesInfo
- type Service
- type ServiceStatus
- type SystemInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildInfo ¶
type BuildInfo struct {
GoVersion string `json:"go_version"`
GoArch string `json:"go_arch"`
GoOS string `json:"go_os"`
CGO bool `json:"cgo"`
GitSHA string `json:"git_sha,omitempty"`
BinSHA string `json:"bin_sha,omitempty"`
}
BuildInfo contains information about binary
type CPUInfo ¶ added in v13.5.0
type CPUInfo struct {
Model string `json:"model"`
Threads int `json:"threads"`
Cores int `json:"cores"`
}
CPUInfo contains info about CPU
type Check ¶
type Check struct {
Status CheckStatus `json:"status"`
Title string `json:"title"`
Message string `json:"message,omitempty"`
}
Check contains info about custom check
type CheckStatus ¶
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 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"`
Resources *ResourcesInfo `json:"resources,omitempty"`
Kernel []KernelParam `json:"kernel,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 (*Info) WithChecks ¶
WithChecks adds information custom checks
func (*Info) WithEnvVars ¶
WithEnvVars adds information with environment variables
func (*Info) WithKernel ¶ added in v13.5.0
func (i *Info) WithKernel(info []KernelParam) *Info
WithKernel adds kernel parameters info
func (*Info) WithNetwork ¶
func (i *Info) WithNetwork(info *NetworkInfo) *Info
WithNetwork adds information about the network
func (*Info) WithPackages ¶
WithPackages adds information about packages
func (*Info) WithResources ¶ added in v13.5.0
func (i *Info) WithResources(info *ResourcesInfo) *Info
WithResources adds system resources information
func (*Info) WithRevision ¶
WithRevision adds git revision
func (*Info) WithServices ¶
WithServices adds information about services
type KernelParam ¶ added in v13.5.0
type KernelParam = EnvVar
KernelParam contains info about kernel parameter
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 ResourcesInfo ¶ added in v13.5.0
type ResourcesInfo struct {
CPU []CPUInfo `json:"cpu"`
MemTotal uint64 `json:"mem_total,omitempty"`
MemFree uint64 `json:"mem_free,omitempty"`
MemUsed uint64 `json:"mem_used,omitempty"`
SwapTotal uint64 `json:"swap_total,omitempty"`
SwapFree uint64 `json:"swap_free,omitempty"`
SwapUsed uint64 `json:"swap_used,omitempty"`
}
ResourcesInfo contains information about system resources
type Service ¶
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 ¶
type ServiceStatus string
const ( STATUS_WORKS ServiceStatus = "works" STATUS_STOPPED ServiceStatus = "stopped" STATUS_UNKNOWN ServiceStatus = "unknown" )
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 kernel provides methods for collecting information from OS kernel
|
Package kernel provides methods for collecting information from OS kernel |
|
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 resources provides methods for collecting information about system resources (cpu/memory)
|
Package resources provides methods for collecting information about system resources (cpu/memory) |
|
Package services provides methods for collecting information about system services
|
Package services provides methods for collecting information about system services |