util

package
v0.0.0-...-c8bb7d6 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatKeyValue

func FormatKeyValue(key string, value string, separator string, keyPrefix string, maxKeyLength int) string

Format the key value into one string such that the key string should be of length 6 (since memory is the longest word) with 2 spaces in between the key and value.

func GenerateContent

func GenerateContent(details map[string]GetterFunc, separator string, keyPrefix string, fieldsToExclude []string) []string

Generate an array of strings to print line by line when fetch is called.

func GetDiskUsage

func GetDiskUsage() string

Get disk usage for root

func GetDistroName

func GetDistroName() string

Get the Distro name Try to extract it from the lsb_release file If it's not there, try the os-release file Use the GOOS var as a fallback

func GetHostname

func GetHostname() string

Get the hostname by reading it from the /etc/hostname file If the file is not accessible try using Go's os to get the hostname as a fallback.

func GetKernelVersion

func GetKernelVersion() string

Extract the kernel version by reading the /proc/version file

func GetMemory

func GetMemory() string

Extract the memory details of the system. The memory will be returned in the format <percent used>% of <total in GB>

func GetShell

func GetShell() string

Get the shell by reading the $SHELL variable

func GetUptime

func GetUptime() string

Get the uptime of the system based on the /proc/uptime file

func GetUser

func GetUser() string

Get the name of the user by reading the $USER variable

func ParseExcludeFields

func ParseExcludeFields(excludeFields string) []string

Parse the exclude fields string to an array of string

Types

type DefaultValues

type DefaultValues struct {
	Align   []string
	Version string
}

Store default values for the commandline args

func ArgsDefaultValues

func ArgsDefaultValues() DefaultValues

type GetterFunc

type GetterFunc func() string

GetterFunc will get the attribute and return it in a string

Jump to

Keyboard shortcuts

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