Skip to content

Commit

Permalink
Allow to switch software RAID monitoring using config option 'softwar…
Browse files Browse the repository at this point in the history
…e_raid_monitoring'
  • Loading branch information
nikita-vanyasin committed Jan 10, 2020
1 parent a7c09ab commit 3bec3ef
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
7 changes: 5 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ type Config struct {

TemperatureMonitoring bool `toml:"temperature_monitoring" comment:"default true"`

SoftwareRAIDMonitoring bool `toml:"software_raid_monitoring" comment:"Software raid monitoring\nAuto-detect software raids by reading /proc/mdstat and monitor them\ndefault true"`

SMARTMonitoring bool `toml:"smart_monitoring" comment:"Enable S.M.A.R.T monitoring of hard disks\ndefault false"`
SMARTCtl string `toml:"smartctl" comment:"Path to a smartctl binary (smartctl.exe on windows, path must be escaped) version >= 7\nSee https://docs.cloudradar.io/configuring-hosts/installing-agents/troubleshoot-s.m.a.r.t-monitoring\nsmartctl = \"C:\\\\Program Files\\\\smartmontools\\\\bin\\\\smartctl.exe\"\nsmartctl = \"/usr/local/bin/smartctl\""`
Logs LogsFilesConfig `toml:"logs,omitempty"`
Expand Down Expand Up @@ -203,8 +205,9 @@ func NewConfig() *Config {
ReportProcesses: 5,
TrailingProcessAnalysisMinutes: 5,
},
SMARTMonitoring: false,
TemperatureMonitoring: true,
SMARTMonitoring: false,
TemperatureMonitoring: true,
SoftwareRAIDMonitoring: true,
Logs: LogsFilesConfig{
HubFile: "",
},
Expand Down
5 changes: 5 additions & 0 deletions example.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ hardware_inventory = true
discover_autostarting_services_only = true
temperature_monitoring = true # default true

# Software raid monitoring
# Auto-detect software raids by reading /proc/mdstat and monitor them
# default true
software_raid_monitoring = true

# default
[cpu_utilisation_analysis]
threshold = 10.0 # target value to start the analysis
Expand Down
2 changes: 1 addition & 1 deletion modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (ca *Cagent) initModules() {
return storcli.CreateModule(ca.Config.StorCLI.BinaryPath)
},
func() monitoring.Module {
return raid.CreateModule()
return raid.CreateModule(ca.Config.SoftwareRAIDMonitoring)
},
}

Expand Down
6 changes: 4 additions & 2 deletions pkg/monitoring/raid/raid.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ var log = logrus.WithField("package", "raid")

type RAID struct {
mdstatFilePath string
enabled bool
}

func CreateModule() monitoring.Module {
func CreateModule(enabled bool) monitoring.Module {
return &RAID{
mdstatFilePath: common.HostProc("mdstat"),
enabled: enabled,
}
}

Expand All @@ -37,7 +39,7 @@ func (r *RAID) GetDescription() string {
}

func (r *RAID) IsEnabled() bool {
return runtime.GOOS == "linux"
return r.enabled && runtime.GOOS == "linux"
}

func (r *RAID) readAndParseMdstat() raidArrays {
Expand Down

0 comments on commit 3bec3ef

Please sign in to comment.