Documentation ¶
Index ¶
- func BytesToFile(data []byte, path string)
- func CommandColumnNoHeader(col int, cmd *exec.Cmd) []string
- func CommandOutput(cmd *exec.Cmd) string
- func FileToBytes(path string) []byte
- func FileToLines(path string) [][]byte
- func FileToString(path string) string
- func GetFilesWithExtension(path string, ext string) (paths []string)
- func Register(name string, check MakeCheckT)
- func SeparateByteUnits(str string) (int, string, error)
- func SubmatchMap(re *regexp.Regexp, str string) (dict map[string]string)
- func URLToBytes(urlstr string, secure bool) []byte
- type Check
- type MakeCheckT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToFile ¶
BytesToFile writes the given data to the file at the path, and handles errors
func CommandColumnNoHeader ¶
CommandColumnNoHeader returns a specified column of the output of a command, without that column's header. Useful for parsing the output of shell commands, which many of the Checks require.
func CommandOutput ¶
CommandOutput returns a string version of the ouput of a given command, and reports errors effectively.
func FileToBytes ¶
FileToBytes reads a file and handles the error
func FileToLines ¶
FileToLines reads in a file at a path, handles errors, splits it into lines, and returns those lines as byte slices
func FileToString ¶
FileToString reads in a file at a path, handles errors, and returns that file as a string
func GetFilesWithExtension ¶
GetFilesWithExtension returns the paths to all the files in the given dir that end with the given file extension (with or without dot)
func Register ¶ added in v0.3.0
func Register(name string, check MakeCheckT)
func SeparateByteUnits ¶
SeparateByteUnits: The integer part of a string representing a size unit, the unit: b | kb | mb | gb | tb, and an error if applicable. 90KB -> (90, kb, nil), 800ads -> (0, "", error) NOTE: this doesn't differentiate between kb and kib, and I don't know how `free` does.
func SubmatchMap ¶
SubmatchMap returns a map of submatch names to their captures, if any. If no matches are found, it returns an empty dict. Submatch names are specified using (?P<name>[matchme])
func URLToBytes ¶
URLToBytes gets the response from urlstr and returns it as a byte string TODO wait on a goroutine w/ timeout, instead of blocking main thread
Types ¶
type Check ¶
type Check interface { // New both validates the YAML-provided parameters (list of strings), // and parses and stores them in an internal, typed field for later access. New(parameters []string) (Check, error) // Status returns the status of the check at the instant it is called. // // msg is a descriptive, human-readable description of the status. // // code is exit code defining whether or not this check is passing. 0 is // considered passing, 1 is failing, with other values reserved for later // use. Status() (code int, msg string, err error) }
Check is a unified interface for health checks, it defines only the minimal necessary behaviors, while allowing each check to parse and store type-safe parameters.
func LookupCheck ¶ added in v0.3.0
type MakeCheckT ¶ added in v0.3.0
type MakeCheckT func() Check