Skip to content

Commit 3de12cd

Browse files
authored
Merge branch 'master' into override-config-with-env-variables
2 parents a783604 + affe05e commit 3de12cd

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

collector/pkg/collector/metrics.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7+
"net/url"
8+
"os"
9+
"os/exec"
10+
"strings"
11+
"time"
12+
713
"github.com/analogj/scrutiny/collector/pkg/common/shell"
814
"github.com/analogj/scrutiny/collector/pkg/config"
915
"github.com/analogj/scrutiny/collector/pkg/detect"
1016
"github.com/analogj/scrutiny/collector/pkg/errors"
1117
"github.com/analogj/scrutiny/collector/pkg/models"
1218
"github.com/samber/lo"
1319
"github.com/sirupsen/logrus"
14-
"net/url"
15-
"os"
16-
"os/exec"
17-
"strings"
1820
)
1921

2022
type MetricsCollector struct {
@@ -90,8 +92,9 @@ func (mc *MetricsCollector) Run() error {
9092
//go mc.Collect(&wg, device.WWN, device.DeviceName, device.DeviceType)
9193
mc.Collect(device.WWN, device.DeviceName, device.DeviceType)
9294

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

97100
//mc.logger.Infoln("Main: Waiting for workers to finish")
@@ -113,7 +116,7 @@ func (mc *MetricsCollector) Validate() error {
113116
return nil
114117
}
115118

116-
//func (mc *MetricsCollector) Collect(wg *sync.WaitGroup, deviceWWN string, deviceName string, deviceType string) {
119+
// func (mc *MetricsCollector) Collect(wg *sync.WaitGroup, deviceWWN string, deviceName string, deviceType string) {
117120
func (mc *MetricsCollector) Collect(deviceWWN string, deviceName string, deviceType string) {
118121
//defer wg.Done()
119122
if len(deviceWWN) == 0 {

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
//configure env variable parsing.
5253
c.SetEnvPrefix("COLLECTOR")

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)