chkutil

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2016 License: Apache-2.0 Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToFile

func BytesToFile(data []byte, path string)

BytesToFile writes the given data to the file at the path, and handles errors

func CommandColumnNoHeader

func CommandColumnNoHeader(col int, cmd *exec.Cmd) []string

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

func CommandOutput(cmd *exec.Cmd) string

CommandOutput returns a string version of the ouput of a given command, and reports errors effectively.

func FileToBytes

func FileToBytes(path string) []byte

FileToBytes reads a file and handles the error

func FileToLines

func FileToLines(path string) [][]byte

FileToLines reads in a file at a path, handles errors, splits it into lines, and returns those lines as byte slices

func FileToString

func FileToString(path string) string

FileToString reads in a file at a path, handles errors, and returns that file as a string

func GetFilesWithExtension

func GetFilesWithExtension(path string, ext string) (paths []string)

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

func SeparateByteUnits(str string) (int, string, error)

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

func SubmatchMap(re *regexp.Regexp, str string) (dict map[string]string)

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

func URLToBytes(urlstr string, secure bool) []byte

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

func LookupCheck(name string) Check

type MakeCheckT added in v0.3.0

type MakeCheckT func() Check

Jump to

Keyboard shortcuts

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