Skip to content

Commit 0641b5e

Browse files
authored
Merge pull request AnalogJ#710 from pabsi/706-add-wait-time-between-checks
Add a wait between disks checks
2 parents 57dc547 + c168e1e commit 0641b5e

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

collector/pkg/collector/metrics.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"os"
1616
"os/exec"
1717
"strings"
18+
"time"
1819
)
1920

2021
type MetricsCollector struct {
@@ -90,8 +91,9 @@ func (mc *MetricsCollector) Run() error {
9091
//go mc.Collect(&wg, device.WWN, device.DeviceName, device.DeviceType)
9192
mc.Collect(device.WWN, device.DeviceName, device.DeviceType)
9293

93-
// TODO: we may need to sleep for between each call to smartctl -a
94-
//time.Sleep(30 * time.Millisecond)
94+
if mc.config.GetInt("commands.metrics_smartctl_wait") > 0 {
95+
time.Sleep(time.Duration(mc.config.GetInt("commands.metrics_smartctl_wait")) * time.Millisecond)
96+
}
9597
}
9698

9799
//mc.logger.Infoln("Main: Waiting for workers to finish")

collector/pkg/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func (c *configuration) Init() error {
4747
c.SetDefault("commands.metrics_scan_args", "--scan --json")
4848
c.SetDefault("commands.metrics_info_args", "--info --json")
4949
c.SetDefault("commands.metrics_smart_args", "--xall --json")
50+
c.SetDefault("commands.metrics_smartctl_wait", 0)
5051

5152
//c.SetDefault("collect.short.command", "-a -o on -S on")
5253

example.collector.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ devices:
8181
# metrics_scan_args: '--scan --json' # used to detect devices
8282
# metrics_info_args: '--info --json' # used to determine device unique ID & register device with Scrutiny
8383
# metrics_smart_args: '--xall --json' # used to retrieve smart data for each device.
84+
# metrics_smartctl_wait: 0 # time to wait in seconds between each disk's check
8485

8586

8687
########################################################################################################################

0 commit comments

Comments
 (0)