Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateDefaultConfigFile(mvc *MinValuableConfig, configFilePath string) error
- func SaveConfigFile(cfg interface{}, configFilePath string) error
- func TryUpdateConfigFromFile(cfg *Config, configFilePath string) error
- func Uname() (string, error)
- type CPUUtilisationAnalyser
- type CPUUtilisationAnalysisConfig
- type CPUWatcher
- type Cagent
- func (ca *Cagent) CPUUtilisationAnalyser() *CPUUtilisationAnalyser
- func (ca *Cagent) CPUWatcher() *CPUWatcher
- func (ca *Cagent) CheckHubCredentials(ctx context.Context, fieldHubURL, fieldHubUser, fieldHubPassword string) error
- func (ca *Cagent) GetFileSystemWatcher() *fs.FileSystemWatcher
- func (ca *Cagent) GetNetworkWatcher() *networking.NetWatcher
- func (ca *Cagent) HostInfoResults() (common.MeasurementsMap, error)
- func (ca *Cagent) MemResults() (common.MeasurementsMap, *mem.VirtualMemoryStat, error)
- func (ca *Cagent) PortsResult(processList []*processes.ProcStat) (common.MeasurementsMap, error)
- func (ca *Cagent) PostResultToHub(ctx context.Context, result *Result) error
- func (ca *Cagent) Run(outputFile *os.File, interrupt chan struct{})
- func (ca *Cagent) RunHeartbeat(interrupt chan struct{})
- func (ca *Cagent) RunOnce(outputFile *os.File, fullMode bool) error
- func (ca *Cagent) SetLogLevel(lvl LogLevel)
- func (ca *Cagent) Shutdown()
- func (ca *Cagent) SwapResults() (common.MeasurementsMap, error)
- type Cleaner
- type Config
- type ConfigDeprecated
- type DockerMonitoringConfig
- type JobMonitoringConfig
- type LogLevel
- type LogsFilesConfig
- type MinValuableConfig
- type PortStat
- type Result
- type StorCLIConfig
- type TimeSeriesAverage
- type TimeValue
- type TimeoutError
- type UpdatesConfig
- type UpdatesMonitoringConfig
- type ValuesCount
- type ValuesMap
Constants ¶
const ( IOModeFile = "file" IOModeHTTP = "http" OperationModeFull = "full" OperationModeMinimal = "minimal" OperationModeHeartbeat = "heartbeat" )
Variables ¶
var ( Version string LicenseInfo = "released under MIT license. https://github.com/4S7xfPcbp1Hfayz/cagent/" SelfUpdatesFeedURL = "https://repo.cloudradar.io/windows/cagent/feed/rolling" )
variables set on build. Example: go build -o cagent -ldflags="-X github.com/4S7xfPcbp1Hfayz/cagent.Version=$(git --git-dir=src/github.com/4S7xfPcbp1Hfayz/cagent/.git describe --always --long --dirty --tag)" github.com/4S7xfPcbp1Hfayz/cagent/cmd/cagent
var ( // 429 error ErrHubTooManyRequests = errors.New("Hub replied with a 429 error code") // 5xx error code ErrHubServerError = errors.New("Hub replied with a 5xx error code") ErrHubUnauthorized = errors.New("Hub replied with a 401 error code") )
var DefaultCfgPath string
Functions ¶
func GenerateDefaultConfigFile ¶
func GenerateDefaultConfigFile(mvc *MinValuableConfig, configFilePath string) error
func SaveConfigFile ¶
func TryUpdateConfigFromFile ¶
TryUpdateConfigFromFile applies values from file in configFilePath to cfg if given file exists. it rewrites all cfg keys that present in the file
Types ¶
type CPUUtilisationAnalyser ¶
type CPUUtilisationAnalyser struct { NumberOfProcesses int // contains filtered or unexported fields }
func (*CPUUtilisationAnalyser) Results ¶
func (cuan *CPUUtilisationAnalyser) Results() (common.MeasurementsMap, bool, error)
type CPUUtilisationAnalysisConfig ¶
type CPUUtilisationAnalysisConfig struct { Threshold float64 `toml:"threshold" comment:"target value to start the analysis" json:"threshold"` Function string `toml:"function" comment:"threshold compare function, possible values: 'lt', 'lte', 'gt', 'gte'" json:"function"` Metric string `toml:"metric" commend:"possible values: 'user','system','idle','iowait'" json:"metric"` GatheringMode string `toml:"gathering_mode" comment:"should be one of values of cpu_utilisation_gathering_mode" json:"gathering_mode"` ReportProcesses int `toml:"report_processes" comment:"number of processes to return" json:"report_processes"` TrailingProcessAnalysisMinutes int `` /* 193-byte string literal not displayed */ }
type CPUWatcher ¶
type CPUWatcher struct { LoadAvg1 bool LoadAvg5 bool LoadAvg15 bool UtilAvg TimeSeriesAverage UtilTypes []string ThresholdNotifiers []thresholdNotifier }
func (*CPUWatcher) AddThresholdNotifier ¶
func (*CPUWatcher) Once ¶
func (cw *CPUWatcher) Once() error
func (*CPUWatcher) Results ¶
func (cw *CPUWatcher) Results() (common.MeasurementsMap, error)
func (*CPUWatcher) Run ¶
func (cw *CPUWatcher) Run()
type Cagent ¶
type Cagent struct { Config *Config ConfigLocation string // contains filtered or unexported fields }
func (*Cagent) CPUUtilisationAnalyser ¶
func (ca *Cagent) CPUUtilisationAnalyser() *CPUUtilisationAnalyser
func (*Cagent) CPUWatcher ¶
func (ca *Cagent) CPUWatcher() *CPUWatcher
func (*Cagent) CheckHubCredentials ¶
func (ca *Cagent) 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 (*Cagent) GetFileSystemWatcher ¶
func (ca *Cagent) GetFileSystemWatcher() *fs.FileSystemWatcher
func (*Cagent) GetNetworkWatcher ¶
func (ca *Cagent) GetNetworkWatcher() *networking.NetWatcher
func (*Cagent) HostInfoResults ¶
func (ca *Cagent) HostInfoResults() (common.MeasurementsMap, error)
func (*Cagent) MemResults ¶
func (ca *Cagent) MemResults() (common.MeasurementsMap, *mem.VirtualMemoryStat, error)
func (*Cagent) PortsResult ¶
PortsResult lists all active connections
func (*Cagent) PostResultToHub ¶
func (*Cagent) RunHeartbeat ¶
func (ca *Cagent) RunHeartbeat(interrupt chan struct{})
func (*Cagent) SetLogLevel ¶
Sets Log level and corresponding logrus level
func (*Cagent) SwapResults ¶
func (ca *Cagent) SwapResults() (common.MeasurementsMap, error)
type Config ¶
type Config struct { OperationMode string `` /* 405-byte string literal not displayed */ Interval float64 `toml:"interval" comment:"interval to push metrics to the HUB"` HeartbeatInterval float64 `toml:"heartbeat" comment:"send a heartbeat without metrics to the HUB every X seconds"` Sleep float64 `toml:"sleep" comment:"sleep duration after failed communication with the HUB"` PidFile string `toml:"pid" comment:"pid file location"` LogFile string `toml:"log,omitempty" required:"false" comment:"log file location"` LogSyslog string `toml:"log_syslog" comment:"\"local\" for local unix socket or URL e.g. \"udp://localhost:514\" for remote syslog server"` MinValuableConfig HubGzip bool `toml:"hub_gzip" comment:"enable gzip when sending results to the HUB"` HubRequestTimeout int `` /* 200-byte string literal not displayed */ HubProxy string `toml:"hub_proxy" commented:"true"` HubProxyUser string `toml:"hub_proxy_user" commented:"true"` HubProxyPassword string `toml:"hub_proxy_password" commented:"true"` CPULoadDataGather []string `toml:"cpu_load_data_gathering_mode" comment:"default ['avg1']"` CPUUtilDataGather []string `toml:"cpu_utilisation_gathering_mode" comment:"default ['avg1']"` CPUUtilTypes []string `toml:"cpu_utilisation_types" comment:"default ['user','system','idle','iowait']"` FSTypeInclude []string `toml:"fs_type_include" comment:"default ['ext3','ext4','xfs','jfs','ntfs','btrfs','hfs','apfs','fat32','smbfs','nfs']"` FSPathExclude []string `toml:"fs_path_exclude" comment:"Exclude file systems by name, disabled by default"` FSPathExcludeRecurse bool `` /* 268-byte string literal not displayed */ FSMetrics []string `` /* 166-byte string literal not displayed */ FSIdentifyMountpointsByDevice bool `` /* 303-byte string literal not displayed */ NetInterfaceExclude []string `toml:"net_interface_exclude" commented:"true"` NetInterfaceExcludeRegex []string `` /* 180-byte string literal not displayed */ NetInterfaceExcludeDisconnected bool `toml:"net_interface_exclude_disconnected" comment:"default true"` NetInterfaceExcludeLoopback bool `toml:"net_interface_exclude_loopback" comment:"default true"` NetMetrics []string `toml:"net_metrics" comment:"default ['in_B_per_s','out_B_per_s','total_out_B_per_s','total_in_B_per_s']"` NetInterfaceMaxSpeed string `` /* 535-byte string literal not displayed */ SystemFields []string `toml:"system_fields" comment:"default ['uname','os_kernel','os_family','os_arch','cpu_model','fqdn','memory_total_B']"` VirtualMachinesStat []string `toml:"virtual_machines_stat" comment:"default ['hyper-v'], available options 'hyper-v'"` HardwareInventory bool `toml:"hardware_inventory" comment:"default true"` DiscoverAutostartingServicesOnly bool `toml:"discover_autostarting_services_only" comment:"default true"` CPUUtilisationAnalysis CPUUtilisationAnalysisConfig `toml:"cpu_utilisation_analysis"` TemperatureMonitoring bool `toml:"temperature_monitoring" comment:"default true"` SoftwareRAIDMonitoring bool `` /* 149-byte string literal not displayed */ SMARTMonitoring bool `toml:"smart_monitoring" comment:"Enable S.M.A.R.T monitoring of hard disks\ndefault false"` SMARTCtl string `` /* 330-byte string literal not displayed */ Logs LogsFilesConfig `toml:"logs,omitempty"` StorCLI StorCLIConfig `` /* 358-byte string literal not displayed */ JobMonitoring JobMonitoringConfig `toml:"jobmon,omitempty" comment:"Settings for the jobmon wrapper for the job monitoring"` SystemUpdatesChecks UpdatesMonitoringConfig `` /* 318-byte string literal not displayed */ MysqlMonitoring mysql.Config `` /* 192-byte string literal not displayed */ ProcessMonitoring processes.Config `` /* 238-byte string literal not displayed */ Updates UpdatesConfig `toml:"self_update" comment:"Control how cagent installs self-updates. Windows-only"` DockerMonitoring DockerMonitoringConfig `` /* 172-byte string literal not displayed */ MemMonitoring bool `` /* 258-byte string literal not displayed */ CPUMonitoring bool `toml:"cpu_monitoring" comment:"Turn on/off any CPU related monitoring including the cpu_utilisation_analysis"` FSMonitoring bool `toml:"fs_monitoring" comment:"Turn on/off any disk- and filesystem-related monitoring like fill levels and iops"` NetMonitoring bool `toml:"net_monitoring" comment:"Turn on/off any network-related monitoring"` OnHTTP5xxRetries int `toml:"on_http_5xx_retries" comment:"Number of retries if server replies with a 5xx code"` OnHTTP5xxRetryInterval float64 `toml:"on_http_5xx_retry_interval" comment:"Interval in seconds between retries to contact server in case of a 5xx code"` }
func HandleAllConfigSetup ¶
HandleAllConfigSetup prepares Config for Cagent with parameters specified in file if Config file does not exist default one is created in form of MinValuableConfig
func (*Config) GetParsedNetInterfaceMaxSpeed ¶
type ConfigDeprecated ¶
type ConfigDeprecated struct {
WindowsUpdatesWatcherInterval int `toml:"windows_updates_watcher_interval" comment:""`
}
type DockerMonitoringConfig ¶
type DockerMonitoringConfig struct {
Enabled bool `toml:"enabled" comment:"Set 'false' to disable docker monitoring'"`
}
type JobMonitoringConfig ¶
type JobMonitoringConfig struct { SpoolDirPath string `toml:"spool_dir" comment:"Path to spool dir"` RecordStdErr bool `toml:"record_stderr" comment:"Record the last 4 KB of the error output. Default: true"` RecordStdOut bool `toml:"record_stdout" comment:"Record the last 4 KB of the standard output. Default: false"` Severity jobmon.Severity `toml:"severity" comment:"Failed jobs will be processed as alerts. Possible values alert, warning or none. Default: alert"` }
func (*JobMonitoringConfig) Validate ¶
func (j *JobMonitoringConfig) Validate() error
type LogsFilesConfig ¶
type LogsFilesConfig struct {
HubFile string `toml:"hub_file,omitempty" comment:"log hub objects send to the hub"`
}
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" commented:"true"` OutFile string `` /* 188-byte string literal not displayed */ HubURL string `toml:"hub_url" commented:"true"` HubUser string `toml:"hub_user" commented:"true"` HubPassword string `toml:"hub_password" commented:"true"` }
func NewMinimumConfig ¶
func NewMinimumConfig() *MinValuableConfig
type Result ¶
type Result struct { Timestamp int64 `json:"timestamp"` Measurements common.MeasurementsMap `json:"measurements"` Message interface{} `json:"message"` }
type StorCLIConfig ¶
type StorCLIConfig struct {
BinaryPath string `` /* 158-byte string literal not displayed */
}
type TimeSeriesAverage ¶
type TimeSeriesAverage struct { TimeSeries []TimeValue // contains filtered or unexported fields }
func (*TimeSeriesAverage) Average ¶
func (tsa *TimeSeriesAverage) Average() map[int]ValuesMap
func (*TimeSeriesAverage) Percentage ¶
func (tsa *TimeSeriesAverage) Percentage() (map[int]ValuesMap, error)
func (*TimeSeriesAverage) SetDurationsMinutes ¶
func (tsa *TimeSeriesAverage) SetDurationsMinutes(durations ...int)
type TimeoutError ¶
func (TimeoutError) Error ¶
func (err TimeoutError) Error() 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:"Cagent 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 UpdatesMonitoringConfig ¶
type UpdatesMonitoringConfig struct { Enabled bool `toml:"enabled" comment:"Set 'false' to disable checking available updates"` FetchTimeout uint32 `` /* 130-byte string literal not displayed */ CheckInterval uint32 `toml:"check_interval" comment:"Check for available updates every N seconds. Minimum is 300 seconds"` }
func (*UpdatesMonitoringConfig) Validate ¶
func (l *UpdatesMonitoringConfig) Validate() error