Documentation
¶
Overview ¶
Package config provides types and functions to collect, validate and apply user-provided settings.
Index ¶
Constants ¶
const ( HelpFlagLong string = "help" HelpFlagShort string = "h" VersionFlagLong string = "version" BrandingFlag string = "branding" TimeoutFlagLong string = "timeout" TimeoutFlagShort string = "t" LogLevelFlagLong string = "log-level" LogLevelFlagShort string = "ll" ShowAllProcessesFlagLong string = "show-all" )
Flag names for consistent references. Exported so that they're available from tests.
const ( // LogLevelDisabled maps to zerolog.Disabled logging level LogLevelDisabled string = "disabled" // LogLevelPanic maps to zerolog.PanicLevel logging level LogLevelPanic string = "panic" // LogLevelFatal maps to zerolog.FatalLevel logging level LogLevelFatal string = "fatal" // LogLevelError maps to zerolog.ErrorLevel logging level LogLevelError string = "error" // LogLevelWarn maps to zerolog.WarnLevel logging level LogLevelWarn string = "warn" // LogLevelInfo maps to zerolog.InfoLevel logging level LogLevelInfo string = "info" // LogLevelDebug maps to zerolog.DebugLevel logging level LogLevelDebug string = "debug" // LogLevelTrace maps to zerolog.TraceLevel logging level LogLevelTrace string = "trace" )
const ExitCodeCatchall int = 1
ExitCodeCatchall indicates a general or miscellaneous error has occurred. This exit code is not directly used by monitoring plugins in this project. See https://tldp.org/LDP/abs/html/exitcodes.html for additional details.
Variables ¶
var ( // ErrVersionRequested indicates that the user requested application version // information. ErrVersionRequested = errors.New("version information requested") // ErrHelpRequested indicates that the user requested application // help/usage information. ErrHelpRequested = errors.New("help/usage information requested") // ErrUnsupportedOption indicates that an unsupported option was specified. ErrUnsupportedOption = errors.New("unsupported option") // ErrConfigNotInitialized indicates that the configuration is not in a // usable state and application execution can not successfully proceed. ErrConfigNotInitialized = errors.New("configuration not initialized") )
Functions ¶
func Branding ¶
Branding accepts a message and returns a function that concatenates that message with version information. This function is intended to be called as a final step before application exit after any other output has already been emitted.
Types ¶
type AppType ¶
type AppType struct {
// Plugin represents an application used as a Nagios plugin.
Plugin bool
// Inspector represents an application used for one-off or isolated
// checks. Unlike a Nagios plugin which is focused on specific attributes
// resulting in a severity-based outcome, an Inspector application is
// intended for examining a small set of targets for
// informational/troubleshooting purposes.
Inspector bool
}
AppType represents the type of application that is being configured/initialized. Not all application types will use the same features and as a result will not accept the same flags. Unless noted otherwise, each of the application types are incompatible with each other, though some flags are common to all types.
type Config ¶
type Config struct {
// LoggingLevel is the supported logging level for this application.
LoggingLevel string
// Log is an embedded zerolog Logger initialized via config.New().
Log zerolog.Logger
// InspectorSettings is the collection of settings specific to the
// Inspector application type.
InspectorSettings InspectorSettings
// EmitBranding controls whether "generated by" text is included at the
// bottom of application output. This output is included in the Nagios
// dashboard and notifications. This output may not mix well with branding
// output from other tools such as atc0005/send2teams which also insert
// their own branding output.
EmitBranding bool
// ShowVersion is a flag indicating whether the user opted to display only
// the version string and then immediately exit the application.
ShowVersion bool
// ShowHelp indicates whether the user opted to display usage information
// and exit the application.
ShowHelp bool
// contains filtered or unexported fields
}
Config represents the application configuration as specified via command-line flags.
type InspectorSettings ¶
type InspectorSettings struct {
// ShowAll indicates whether the user opted to display information for ALL
// processes. This can produce a lot of output
ShowAll bool
}
InspectorSettings is the collection of settings specific to the Inspector application type.