Documentation ¶
Index ¶
- Constants
- func All(ss []string, f func(string) bool) bool
- func Any(ss []string, f func(string) bool) bool
- func AppendFile(path string) (*os.File, error)
- func AppendToPathEnv(pathEnv string, toAdd ...string) string
- func BoolAsInt(b bool) int
- func CheckDupeProcess() error
- func CmpTCPAddr(a, b *net.TCPAddr) bool
- func ConcatErrors(scanErrors []error, err error) error
- func CpDir(source string, dest string) error
- func CpFile(src, dst string) error
- func DedupeStringSlice(in []string) []string
- func DeleteKeyValue(keyPairs []string, name string) ([]string, error)
- func ExpBackoff(base time.Duration, cur, limit uint64) time.Duration
- func ExpBackoffWithJitter(base, jitter time.Duration, cur, limit uint64) time.Duration
- func Filter(ss []string, f func(string) bool) (nss []string)
- func FilterStringMatches(filterStr, actualStr string) bool
- func FindBinary(binName string) (string, error)
- func FindKeyValue(keyPairs []string, name string) (string, error)
- func FolderCompress(src string, buf io.Writer) error
- func FormatTime(t time.Time) string
- func GetAdjacentPath(inPath string) (string, error)
- func GetConsent(log logging.Logger) bool
- func GetExitStatus(err error) error
- func GetFilePaths(dir string, ext string) ([]string, error)
- func GetProcName(pid int) (string, error)
- func GetProcPids(procName string) ([]int, error)
- func GetWorkingPath(inPath string) (string, error)
- func HasPort(addr string) bool
- func HasPrefixPath(base, sub string) (bool, error)
- func Includes(ss []string, target string) bool
- func Index(ss []string, target string) int
- func InterfaceIsNil(i interface{}) bool
- func IsAlphabetic(s string) bool
- func IsHidden(filename string) bool
- func IsLocalAddr(testAddr *net.TCPAddr) bool
- func LocalhostCtrlAddr() *net.TCPAddr
- func Map(ss []string, f func(string) string) (nss []string)
- func MergeKeyValues(curVars []string, newVars []string) (merged []string)
- func NormalizePath(p string) (np string, err error)
- func ParseHostList(in []string, defaultPort int) (out []string, err error)
- func ParseNumberList(stringList string, output interface{}) error
- func ParseTime(ts string) (time.Time, error)
- func PercentageString(part, total uint64) string
- func Pluralise(s string, n int) string
- func PrintStructs(name string, i interface{})
- func ResolvePath(inPath string, defaultPath string) (outPath string, err error)
- func Run(cmd string) error
- func ScrubEnvironment(blocklist []string)
- func ScrubEnvironmentExcept(allowlist []string)
- func ScrubProxyVariables()
- func SplitPort(addrPattern string, defaultPort int) (string, string, error)
- func StringSliceHasDuplicates(slice []string) bool
- func StructsToString(i interface{}) (lines string, err error)
- func SyncDir(path string) (err error)
- func TokenizeCommaSeparatedString(str string) []string
- func TruncFile(path string) (*os.File, error)
- func UpdateKeyValue(keyPairs []string, name, newValue string) ([]string, error)
- func WriteFileAtomic(path string, data []byte, perm os.FileMode) error
- func WriteSlice(path string, slice []string) (err error)
- func WriteString(path string, s string) error
- type ControlLogLevel
- type ExitStatus
- type GetMemInfoFn
- type MemInfo
- type StringSet
- func (s StringSet) Add(values ...string)
- func (s StringSet) AddUnique(values ...string) error
- func (s StringSet) Has(val string) bool
- func (s StringSet) MarshalYAML() (interface{}, error)
- func (s StringSet) String() string
- func (s StringSet) ToSlice() []string
- func (s *StringSet) UnmarshalYAML(unmarshal func(interface{}) error) error
Constants ¶
const ( ControlLogLevelTrace = ControlLogLevel(logging.LogLevelTrace) ControlLogLevelDebug = ControlLogLevel(logging.LogLevelDebug) ControlLogLevelInfo = ControlLogLevel(logging.LogLevelInfo) ControlLogLevelNotice = ControlLogLevel(logging.LogLevelNotice) ControlLogLevelError = ControlLogLevel(logging.LogLevelError) DefaultControlLogLevel = ControlLogLevel(logging.DefaultLogLevel) )
TODO(mjmac): Evaluate whether or not this layer of indirection adds any value.
const DisableProxyScrubEnv = "DAOS_DISABLE_PROXY_SCRUB"
DisableProxyScrubEnv disabled removal of proxy variables from the process environment.
const UtilLogDepth = 4
UtilLogDepth signifies stack depth, set calldepth on calls to logger so log message context refers to caller not callee.
Variables ¶
This section is empty.
Functions ¶
func AppendFile ¶
AppendFile appends to existing or creates new file with default options
func AppendToPathEnv ¶
AppendToPathEnv appends entries to the supplied colon-separated string if non-existent.
func CheckDupeProcess ¶
func CheckDupeProcess() error
CheckDupeProcess checks to see if another process with the same name as ours is running.
func CmpTCPAddr ¶
CmpTCPAddr compares two *net.TCPAddr instances and returns true if they are equivalent, false otherwise.
func ConcatErrors ¶
ConcatErrors builds single error from error slice.
func DedupeStringSlice ¶
DedupeStringSlice is responsible for returning a slice based on the input with any duplicates removed.
func DeleteKeyValue ¶
DeleteKeyValue removes an existing key and returns new slice of key-value pairs.
func ExpBackoff ¶
ExpBackoff implements an exponential backoff algorithm, where the parameters are used to multiplicatively slow down the rate of retries of some operation, up to a maximum backoff limit.
func ExpBackoffWithJitter ¶
ExpBackoffWithJitter is like ExpBackoff but allows for a custom amount of jitter to be specified.
func FilterStringMatches ¶
FilterStringMatches checks whether a filter string matches the actual string in a case-insensitive way. If the filter string is empty, a match is assumed.
func FindBinary ¶
FindBinary attempts to locate the named binary by checking $PATH first. If the binary is not found in $PATH, look in the directory containing the running processes binary as well as the working directory.
func FindKeyValue ¶
FindKeyValue will return value from supplied name key if found in input slice of key-pairs (e.g. environment). ErrNotExist error returned if key cannot be found.
func FolderCompress ¶
Archive and create the *tar.gz of the given folder.
func FormatTime ¶
FormatTime returns ISO8601 formatted representation of timestamp with microsecond resolution.
func GetAdjacentPath ¶
GetAdjacentPath retrieves path relative to the binary used to launch the currently running process.
func GetExitStatus ¶
GetExitStatus ensures that a monitored process always returns an error of some sort when it exits so that we can respond appropriately.
func GetFilePaths ¶
GetFilePaths return full file paths in given directory with matching file extensions
func GetProcName ¶
GetProcName returns the name of the process with the given pid.
func GetProcPids ¶
GetProcPids returns a list of pids for the given process name.
func GetWorkingPath ¶
GetWorkingPath retrieves path relative to the current working directory when invoking the current process.
func HasPort ¶
HasPort checks if addr specifies a port. This only works with IPv4 addresses at the moment.
func HasPrefixPath ¶
HasPrefixPath reports whether sub parameter path is a prefix of the base parameter one.
func InterfaceIsNil ¶
func InterfaceIsNil(i interface{}) bool
InterfaceIsNil returns true if the interface itself or its underlying value is nil.
func IsAlphabetic ¶
IsAlphabetic checks of a string just contains alphabetic characters.
func IsLocalAddr ¶
IsLocalAddr returns true if the supplied net.TCPAddr matches one of the local IP addresses, false otherwise.
func LocalhostCtrlAddr ¶
LocalhostCtrlAddr returns a *net.TCPAddr representing the default control address on localhost.
func MergeKeyValues ¶
MergeKeyValues merges and deduplicates two slices of key-value pairs. Conflicts are resolved by taking the value from the second list.
func NormalizePath ¶
Normalize the input path with removing redundant separators, up-level reference, changing relative path to absolute one, etc.
func ParseHostList ¶
ParseHostList validates and deduplicates the given list of host strings. Any hosts missing a port will have one added according to the defaultPort parameter.
func ParseNumberList ¶
ParseNumberList converts a comma-separated string of numbers to a slice.
func PercentageString ¶
PercentageString returns string representation of percentage given nominator and denominator unsigned integers.
func PrintStructs ¶
func PrintStructs(name string, i interface{})
PrintStructs dumps friendly YAML representation of structs to stdout proceeded with "name" identifier.
func ResolvePath ¶
ResolvePath simply returns an absolute path, appends input path to current working directory if input path not empty otherwise appends default path to location of running binary (adjacent). Use case is specific to config files.
func ScrubEnvironment ¶
func ScrubEnvironment(blocklist []string)
ScrubEnvironment modifies the environment variables set for this process and any children which inherit its environment by unsetting any variables supplied in the blocklist.
func ScrubEnvironmentExcept ¶
func ScrubEnvironmentExcept(allowlist []string)
ScrubEnvironmentExcept modifies the environment variables set for this process and any children which inherit its environment by unsetting any variables that are not supplied in the allowlist.
func ScrubProxyVariables ¶
func ScrubProxyVariables()
ScrubProxyVariables removes proxy variables from the process environment.
func SplitPort ¶
SplitPort separates port from host in address and can apply default port if address doesn't contain one.
func StringSliceHasDuplicates ¶
StringSliceHasDuplicates checks whether there are duplicate strings in the slice. Comparisons are case insensitive. If duplicates found, return true.
func StructsToString ¶
StructsToString returns yaml representation (as a list of strings) of any interface but avoids fields/lines prefixed with xxx_ such as added by protobuf boilerplate.
func SyncDir ¶
SyncDir flushes all prior modifications to a directory. This is required if one modifies a directory (e.g., by creating a new file in it) and needs to wait for this modification to become persistent.
func TokenizeCommaSeparatedString ¶
TokenizeCommaSeparatedString splits the input string on comma boundaries, and discards any empty strings in the result.
func UpdateKeyValue ¶
UpdateKeyValue updates a value for existing key and returns new slice of key-value pairs.
func WriteFileAtomic ¶
WriteFileAtomic mimics ioutil.WriteFile, but it makes sure the file is either successfully written persistently or untouched.
func WriteSlice ¶
WriteSlice writes string slice to specified file, overwriting and creating if non-existent.
func WriteString ¶
WriteString writes string to specified file, wrapper around WriteSlice.
Types ¶
type ControlLogLevel ¶
ControlLogLevel is a type that specifies log levels
func (ControlLogLevel) MarshalYAML ¶
func (c ControlLogLevel) MarshalYAML() (interface{}, error)
func (ControlLogLevel) String ¶
func (c ControlLogLevel) String() string
func (*ControlLogLevel) UnmarshalYAML ¶
func (c *ControlLogLevel) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements yaml.Unmarshaler on ControlLogMask struct
type ExitStatus ¶
type ExitStatus string
ExitStatus implements the error interface and is used to indicate external process exit conditions.
const NormalExit ExitStatus = "process exited with 0"
NormalExit indicates that the process exited without error.
func (ExitStatus) Error ¶
func (es ExitStatus) Error() string
type GetMemInfoFn ¶
type MemInfo ¶
type MemInfo struct { HugepagesTotal int `json:"hugepages_total" hash:"ignore"` HugepagesFree int `json:"hugepages_free" hash:"ignore"` HugepagesRsvd int `json:"hugepages_reserved" hash:"ignore"` HugepagesSurp int `json:"hugepages_surplus" hash:"ignore"` HugepageSizeKiB int `json:"hugepage_size_kb"` MemTotalKiB int `json:"mem_total_kb"` MemFreeKiB int `json:"mem_free_kb" hash:"ignore"` MemAvailableKiB int `json:"mem_available_kb" hash:"ignore"` }
MemInfo contains information about system hugepages.
func GetMemInfo ¶
GetMemInfo reads /proc/meminfo and returns information about system hugepages and memory (RAM).
func (*MemInfo) HugepagesFreeMB ¶
func (*MemInfo) HugepagesTotalMB ¶
type StringSet ¶
type StringSet map[string]struct{}
StringSet is a non-duplicated set of strings.
func NewStringSet ¶
NewStringSet creates a StringSet and initializes it with zero or more strings.
func (StringSet) AddUnique ¶
AddUnique adds zero or more strings to the StringSet, and returns an error if any already exist.
func (StringSet) MarshalYAML ¶
MarshalYAML converts from the StringSet to a slice that can be marshaled into YAML.
func (*StringSet) UnmarshalYAML ¶
UnmarshalYAML converts from the YAML string slice to a StringSet.