Documentation
¶
Overview ¶
Package hostdiag answers a fixed set of read-only host questions for the web CLI console, in process. It never executes anything and takes no input beyond a subcommand name chosen from a closed list.
Index ¶
- Constants
- Variables
- func Check(argv []string) (string, error)
- func Enabled() bool
- func FormatDF(rows []DiskUsage) string
- func FormatFree(m Meminfo) string
- func FormatLoad(l Loadavg, cpus int) string
- func FormatService(s ServiceInfo) string
- func HumanDuration(d time.Duration) string
- func ParseOSRelease(text string) string
- func ParseUptime(text string) (time.Duration, error)
- func ParseVMRSS(text string) (uint64, error)
- func Run(sub string, info Info) (string, error)
- func Sanitize(s string) string
- func Subcommands() []string
- type DiskUsage
- type Info
- type Loadavg
- type Meminfo
- type ServiceInfo
- type UsageError
Constants ¶
const Command = "host"
Command is the console word that routes a line here.
const EnvSwitch = "APP_CLI_CONSOLE_HOST"
EnvSwitch turns host diagnostics off without turning off the console.
Variables ¶
var ErrUnsupported = errors.New("not supported on this platform")
ErrUnsupported means the current OS has no implementation.
Functions ¶
func Enabled ¶
func Enabled() bool
Enabled reports whether host diagnostics are allowed by the environment.
func FormatFree ¶
FormatFree renders a Meminfo as the free report.
func FormatService ¶
func FormatService(s ServiceInfo) string
FormatService renders the service report.
func HumanDuration ¶
HumanDuration renders d as "3d 4h 5m", or seconds when under a minute.
func ParseOSRelease ¶
ParseOSRelease returns PRETTY_NAME, falling back to NAME VERSION.
func ParseUptime ¶
ParseUptime reads the first field of /proc/uptime as seconds since boot.
func ParseVMRSS ¶
ParseVMRSS reads VmRSS from /proc/self/status, in bytes.
func Subcommands ¶
func Subcommands() []string
Subcommands returns the closed list of host subcommands.
Types ¶
type Loadavg ¶
Loadavg is the parsed /proc/loadavg.
func ParseLoadavg ¶
ParseLoadavg reads "0.10 0.20 0.30 1/234 5678"; the last pid field is ignored.
type Meminfo ¶
type Meminfo struct {
Total, Available, SwapTotal, SwapFree uint64
}
Meminfo holds the /proc/meminfo fields the free report uses, in bytes.
func ParseMeminfo ¶
ParseMeminfo reads /proc/meminfo text; values there are in kB.
type ServiceInfo ¶
type ServiceInfo struct {
Version string
GoVersion string
Started time.Time
Now time.Time
Goroutines int
RSS uint64
RSSKnown bool
Supervised bool
}
ServiceInfo describes this control plane process.
type UsageError ¶
type UsageError struct{ Reason string }
UsageError is a refusal whose message is safe to show the operator.
func (*UsageError) Error ¶
func (e *UsageError) Error() string