Documentation ¶
Index ¶
- Constants
- Variables
- func AskForConfirmation(s string) bool
- func CheckIfRawICMPAvailable() bool
- func CheckIfRootlessICMPAvailable() bool
- func GenerateDefaultConfigFile(mvc *MinValuableConfig, configFilePath string) error
- func HandleFlagDaemonizeMode() int
- func HandleFlagInputOutput(inputFile string, outputFile string, oneRunOnlyMode bool) *os.File
- func HandleFlagSearchUpdates() int
- func HandleFlagUpdate(assumeYes *bool) int
- func SaveConfigFile(mvc *MinValuableConfig, configFilePath string) error
- func Uname() (string, error)
- type Check
- type Config
- type ErrorHubGeneral
- type ErrorHubResetContent
- type ErrorHubTooManyRequests
- type ErrorMissingHubOrInput
- type Frontman
- func (fm *Frontman) CheckHubCredentials(ctx context.Context, fieldHubURL, fieldHubUser, fieldHubPassword string) error
- func (fm *Frontman) HandleFlagLogLevel(logLevel string) error
- func (fm *Frontman) HandleFlagOneRunOnlyMode(inputFile string, output *os.File) int
- func (fm *Frontman) HandleFlagPrintConfig()
- func (fm *Frontman) HandleFlagPrintStats() int
- func (fm *Frontman) HandleFlagServiceInstall(systemManager service.System, username string, serviceInstallPtr *bool, ...) int
- func (fm *Frontman) HandleFlagServiceUninstall() int
- func (fm *Frontman) HandleFlagServiceUpgrade(cfgPath string, serviceUpgradeFlag *bool, serviceInstallUserPtr *string) int
- func (fm *Frontman) HandleFlagTest() int
- func (fm *Frontman) HandleServiceCommand(check, start, stop, restart bool) int
- func (fm *Frontman) HealthCheck() error
- func (fm *Frontman) HostInfoResults() (MeasurementsMap, error)
- func (fm *Frontman) RemovePidFileIfNeeded()
- func (fm *Frontman) Run(inputFilePath string, outputFile *os.File)
- func (fm *Frontman) RunOnce(inputFilePath string, outputFile *os.File) error
- func (fm *Frontman) RunUnderOsServiceManager() int
- func (fm *Frontman) ServeWeb() error
- func (fm *Frontman) SetLogLevel(lvl LogLevel)
- func (fm *Frontman) WritePidFileIfNeeded() error
- type HTTPListenerConfig
- type HealthCheckConfig
- type Input
- type Invoke
- type Invoker
- type LogLevel
- type LogrusErrorHook
- type MeasurementsMap
- type MinValuableConfig
- type MockHub
- type Node
- type NodeConfig
- type Result
- type Results
- type SNMPCheck
- type SNMPCheckData
- type ServiceCheck
- type ServiceCheckData
- type ServiceName
- type UpdatesConfig
- type WebCheck
- type WebCheckData
Constants ¶
const ( IOModeFile = "file" IOModeHTTP = "http" )
const ( ProtocolICMP = "icmp" ProtocolTCP = "tcp" ProtocolUDP = "udp" ProtocolSSL = "ssl" ServiceICMPPing = "ping" )
Variables ¶
var ( Version string SelfUpdatesFeedURL = "https://repo.cloudradar.io/windows/frontman/feed/rolling" )
variables set on build. Example: go build -o frontman -ldflags="-X main.Version=$(git --git-dir=src/github.com/cloudradar-monitoring/frontman/.git describe --always --long --dirty --tag)" github.com/cloudradar-monitoring/frontman/cmd/frontman
var DefaultCfgPath string
Functions ¶
func AskForConfirmation ¶
func CheckIfRawICMPAvailable ¶
func CheckIfRawICMPAvailable() bool
func CheckIfRootlessICMPAvailable ¶
func CheckIfRootlessICMPAvailable() bool
func GenerateDefaultConfigFile ¶
func GenerateDefaultConfigFile(mvc *MinValuableConfig, configFilePath string) error
GenerateDefaultConfigFile creates a default frontman.toml and writes to to disk
func HandleFlagInputOutput ¶
func SaveConfigFile ¶
func SaveConfigFile(mvc *MinValuableConfig, configFilePath string) error
SaveConfigFile saves config file as toml
Types ¶
type Config ¶
type Config struct { NodeName string `` /* 137-byte string literal not displayed */ Sleep float64 `` /* 297-byte string literal not displayed */ PidFile string `toml:"pid" comment:"path to pid file"` LogFile string `toml:"log,omitempty" comment:"path to log file"` LogSyslog string `toml:"log_syslog" comment:"\"local\" for local unix socket or URL e.g. \"udp://localhost:514\" for remote syslog server"` StatsFile string `toml:"stats_file" comment:"Path to the file where we write frontman statistics"` QueueStatsFile string `toml:"queue_stats_file" comment:"Path to the file where we write frontman queue statistics"` MinValuableConfig HubGzip bool `toml:"hub_gzip" comment:"enable gzip when sending results to the HUB"` HubRequestTimeout int `` /* 200-byte string literal not displayed */ HubMaxOfflineBufferBytes int `toml:"hub_max_offline_buffer_bytes" commented:"true"` ICMPTimeout float64 `toml:"icmp_timeout" comment:"ICMP ping timeout in seconds"` NetTCPTimeout float64 `toml:"net_tcp_timeout" comment:"TCP timeout in seconds"` NetUDPTimeout float64 `toml:"net_udp_timeout" comment:"UDP timeout in seconds"` HTTPCheckTimeout float64 `toml:"http_check_timeout" comment:"HTTP time in seconds"` HTTPCheckMaxRedirects int `toml:"max_redirects" comment:"Limit the number of HTTP redirects to follow"` IgnoreSSLErrors bool `toml:"ignore_ssl_errors"` SSLCertExpiryThreshold int `toml:"ssl_cert_expiry_threshold" comment:"Min days remain on the SSL cert to pass the check"` SenderBatchSize int `toml:"sender_batch_size" comment:"Do not send back more than N results per POST request"` SenderInterval float64 `toml:"sender_interval" comment:"Make a pause of N seconds between POST requests when processing the result queue"` SenderThreadConcurrency int `toml:"sender_thread_concurrency" comment:"The maximum number of concurrent http connections for sending\nresults to the hub."` DiscardOnHTTPResponseError bool `` /* 152-byte string literal not displayed */ DiscardOnHTTPConnectError bool `` /* 199-byte string literal not displayed */ CheckResultsTTL float64 `` /* 160-byte string literal not displayed */ SleepDurationAfterCheck float64 `toml:"sleep_duration_after_check" comment:"Time in seconds to sleep between each check being dispatched for execution"` SleepDurationEmptyQueue float64 `toml:"sleep_duration_empty_queue" comment:"Time in seconds to sleep when the check queue is empty"` HealthChecks HealthCheckConfig `` /* 534-byte string literal not displayed */ HTTPListener HTTPListenerConfig `toml:"http_listener" comment:"Perform checks requested via HTTP POST requests"` FailureConfirmation int `` /* 268-byte string literal not displayed */ FailureConfirmationDelay float64 `toml:"failure_confirmation_delay" comment:"Delay in seconds"` Node NodeConfig `toml:"node" comment:"Node configuration"` Nodes map[string]Node `` /* 527-byte string literal not displayed */ Updates UpdatesConfig `toml:"self_update" comment:"Control how frontman installs self-updates. Windows-only"` }
func HandleAllConfigSetup ¶
HandleAllConfigSetup prepares config for Frontman with parameters specified in file if config file not exists default one created in form of MinValuableConfig
func (*Config) TryUpdateConfigFromFile ¶
TryUpdateConfigFromFile applies values from file in configFilePath to cfg if given file exists. it rewrites all cfg keys that present in the file
type ErrorHubGeneral ¶
type ErrorHubGeneral struct {
// contains filtered or unexported fields
}
func (ErrorHubGeneral) Error ¶
func (e ErrorHubGeneral) Error() string
type ErrorHubResetContent ¶
type ErrorHubResetContent struct{}
func (ErrorHubResetContent) Error ¶
func (e ErrorHubResetContent) Error() string
type ErrorHubTooManyRequests ¶
type ErrorHubTooManyRequests struct{}
func (ErrorHubTooManyRequests) Error ¶
func (e ErrorHubTooManyRequests) Error() string
type ErrorMissingHubOrInput ¶
type ErrorMissingHubOrInput struct{}
func (ErrorMissingHubOrInput) Error ¶
func (e ErrorMissingHubOrInput) Error() string
type Frontman ¶
type Frontman struct { Config *Config ConfigLocation string HealthCheckPassedPreviously bool TerminateQueue sync.WaitGroup // interrupt handler, close it to shut down frontman InterruptChan chan struct{} // send true to signal completion DoneChan chan bool // contains filtered or unexported fields }
func (*Frontman) CheckHubCredentials ¶
func (fm *Frontman) CheckHubCredentials(ctx context.Context, fieldHubURL, fieldHubUser, fieldHubPassword string) error
CheckHubCredentials performs credentials check for a Hub config, returning errors that reference field names as in source config. Since config may be filled from file or UI, the field names can be different. Consider also localization of UI, we want to decouple credential checking logic from their actual view in UI.
Examples: * for TOML: CheckHubCredentials(ctx, "hub_url", "hub_user", "hub_password") * for WinUI: CheckHubCredentials(ctx, "URL", "User", "Password")
func (*Frontman) HandleFlagLogLevel ¶
func (*Frontman) HandleFlagOneRunOnlyMode ¶
returns error code
func (*Frontman) HandleFlagPrintConfig ¶
func (fm *Frontman) HandleFlagPrintConfig()
func (*Frontman) HandleFlagPrintStats ¶
returns exit code
func (*Frontman) HandleFlagServiceInstall ¶
func (fm *Frontman) HandleFlagServiceInstall(systemManager service.System, username string, serviceInstallPtr *bool, cfgPath string, assumeYesPtr *bool) int
returns exit code
func (*Frontman) HandleFlagServiceUninstall ¶
returns exit code
func (*Frontman) HandleFlagServiceUpgrade ¶
func (fm *Frontman) HandleFlagServiceUpgrade(cfgPath string, serviceUpgradeFlag *bool, serviceInstallUserPtr *string) int
returns exit code
func (*Frontman) HandleFlagTest ¶
HandleFlagTest handles -t flag for the frontman executable returns exit code
func (*Frontman) HandleServiceCommand ¶
returns exit code
func (*Frontman) HealthCheck ¶
HealthCheck runs before any other check to ensure that the host itself and its network are healthly. This is useful to confirm a stable internet connection to avoid false alerts due to network outages.
func (*Frontman) HostInfoResults ¶
func (fm *Frontman) HostInfoResults() (MeasurementsMap, error)
HostInfoResults fetches information about the host itself which can be send to the hub alongside measurements.
func (*Frontman) RemovePidFileIfNeeded ¶
func (fm *Frontman) RemovePidFileIfNeeded()
func (*Frontman) RunUnderOsServiceManager ¶
returns exit code
func (*Frontman) ServeWeb ¶
ServeWeb starts the webserver as configured under [http_listener] section of frontman.conf
func (*Frontman) SetLogLevel ¶
SetLogLevel sets Log level and corresponding logrus level
func (*Frontman) WritePidFileIfNeeded ¶
type HTTPListenerConfig ¶
type HTTPListenerConfig struct { HTTPListen string `` /* 419-byte string literal not displayed */ HTTPTLSKey string `toml:"http_tls_key" comment:"Private key for https connections"` HTTPTLSCert string `toml:"http_tls_cert" comment:"Certificate for https connections"` HTTPAuthUser string `toml:"http_auth_user" comment:"Username for the http basic authentication. If omitted authentication is disabled"` HTTPAuthPassword string `toml:"http_auth_password" comment:"Password for the http basic authentication."` HTTPAccessLog string `toml:"http_access_log" comment:"Log http requests. On windows slash must be escaped like \"C:\\\\access.log\""` }
type HealthCheckConfig ¶
type HealthCheckConfig struct { ReferencePingHosts []string `` /* 239-byte string literal not displayed */ ReferencePingTimeout float64 `toml:"reference_ping_timeout" comment:"Maximum time (seconds) to wait for the response"` ReferencePingCount int `toml:"reference_ping_count" comment:"Number of request packets to send to each host."` }
type Input ¶
type Input struct { ServiceChecks []ServiceCheck `json:"serviceChecks"` WebChecks []WebCheck `json:"webChecks"` SNMPChecks []SNMPCheck `json:"snmpChecks,omitempty"` }
func InputFromFile ¶
type LogrusErrorHook ¶
type LogrusErrorHook struct {
// contains filtered or unexported fields
}
func (*LogrusErrorHook) Levels ¶
func (h *LogrusErrorHook) Levels() []logrus.Level
type MeasurementsMap ¶
type MeasurementsMap map[string]interface{}
type MinValuableConfig ¶
type MinValuableConfig struct { LogLevel LogLevel `toml:"log_level" comment:"\"debug\", \"info\", \"error\" verbose level; can be overridden with -v flag"` IOMode string `toml:"io_mode" comment:"\"file\" or \"http\" – where frontman gets checks to perform and post results"` HubURL string `toml:"hub_url" commented:"true"` HubUser string `toml:"hub_user" commented:"true"` HubPassword string `toml:"hub_password" commented:"true"` HubProxy string `toml:"hub_proxy" commented:"true"` HubProxyUser string `toml:"hub_proxy_user" commented:"true"` HubProxyPassword string `toml:"hub_proxy_password" commented:"true"` // new configs should use host_info, keep system_fields to support older configs SystemFields []string `toml:"system_fields" commented:"true" comment:"DEPRECATED: use host_info instead"` HostInfo []string `toml:"host_info" commented:"true"` }
func NewMinimumConfig ¶
func NewMinimumConfig() *MinValuableConfig
type MockHub ¶
type MockHub struct { // if set, responds with this status code on all requests. useful for testing 401 and such ResponseStatusCode int // contains filtered or unexported fields }
func NewMockHub ¶
type NodeConfig ¶
type NodeConfig struct { NodeTimeout float64 `toml:"node_timeout" comment:"Set the maximum time in seconds frontman should spend trying to connect a node"` NodeCacheErrors float64 `` /* 181-byte string literal not displayed */ ForwardExcept []string `` /* 179-byte string literal not displayed */ ForwardLog string `` /* 164-byte string literal not displayed */ }
type Result ¶
type Result struct { CheckUUID string `json:"checkUuid"` Timestamp int64 `json:"timestamp"` CheckType string `json:"checkType"` Check interface{} `json:"check"` // *CheckData Measurements map[string]interface{} `json:"measurements"` Message interface{} `json:"message"` Node string `json:"node,omitempty"` // filled in when result is coming from a neighbor NodeMeasurements []map[string]interface{} `json:"nodeMeasurements,omitempty"` }
type SNMPCheck ¶
type SNMPCheck struct { UUID string `json:"checkUuid"` Check SNMPCheckData `json:"check"` }
type SNMPCheckData ¶
type SNMPCheckData struct { Connect string `json:"connect"` Port uint16 `json:"port"` Timeout float64 `json:"timeout"` Protocol string `json:"protocol"` Community string `json:"community,omitempty"` // v1, v2 Preset string `json:"preset"` Oids []string `json:"oids,omitempty"` SecurityLevel string `json:"security_level,omitempty"` // v3 Username string `json:"username,omitempty"` // v3 AuthenticationProtocol string `json:"authentication_protocol,omitempty"` // v3 AuthenticationPassword string `json:"authentication_password,omitempty"` // v3 PrivacyProtocol string `json:"privacy_protocol,omitempty"` // v3 PrivacyPassword string `json:"privacy_password,omitempty"` // v3 // values used by "oid" preset Oid string `json:"oid,omitempty"` Name string `json:"name,omitempty"` ValueType string `json:"value_type,omitempty"` /// auto (default), hex, delta, delta_per_sec Unit string `json:"unit,omitempty"` }
type ServiceCheck ¶
type ServiceCheck struct { UUID string `json:"checkUuid"` Check ServiceCheckData `json:"check"` }
type ServiceCheckData ¶
type ServiceName ¶
type ServiceName string
type UpdatesConfig ¶
type UpdatesConfig struct { Enabled bool `toml:"enabled" comment:"Set 'false' to disable self-updates"` URL string `toml:"url" comment:"URL for updates feed"` CheckInterval uint32 `toml:"check_interval" comment:"Frontman will check for new versions every N seconds"` }
func (*UpdatesConfig) GetCheckInterval ¶
func (u *UpdatesConfig) GetCheckInterval() time.Duration
func (*UpdatesConfig) Validate ¶
func (u *UpdatesConfig) Validate() error
type WebCheck ¶
type WebCheck struct { UUID string `json:"checkUuid"` Check WebCheckData `json:"check"` }
type WebCheckData ¶
type WebCheckData struct { Method string `json:"method"` URL string `json:"url"` PostData string `json:"postData,omitempty"` ExpectedHTTPStatus int `json:"expectedHttpStatus,omitempty"` SearchHTMLSource bool `json:"searchHtmlSource"` ExpectedPattern string `json:"expectedPattern,omitempty"` ExpectedPatternPresence string `json:"expectedPatternPresence,omitempty"` DontFollowRedirects bool `json:"dontFollowRedirects"` IgnoreSSLErrors *bool `json:"ignoreSSLErrors,omitempty"` Timeout float64 `json:"timeout,omitempty"` Headers map[string]string `json:"headers,omitempty"` }