@@ -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
2022type 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) {
117120func (mc * MetricsCollector ) Collect (deviceWWN string , deviceName string , deviceType string ) {
118121 //defer wg.Done()
119122 if len (deviceWWN ) == 0 {
0 commit comments