diff options
author | Eriks Sneiders <eriks.sneiders@zabbix.com> | 2022-03-23 10:37:09 +0300 |
---|---|---|
committer | Eriks Sneiders <eriks.sneiders@zabbix.com> | 2022-03-31 17:45:19 +0300 |
commit | e51a1c17994dea552054b772f81220d0fd383168 (patch) | |
tree | 68c503d6c8d8b30d9cdf23e000728b9e37546de5 /src/go/plugins | |
parent | 423c1912c32ada68e96d699998cec8aaf0024d25 (diff) |
...G...... [ZBXNEXT-7559] fixed smart.disk.discovery path output field for raid devices
Diffstat (limited to 'src/go/plugins')
-rw-r--r-- | src/go/plugins/smart/smart.go | 2 | ||||
-rw-r--r-- | src/go/plugins/smart/smartfs.go | 35 |
2 files changed, 7 insertions, 30 deletions
diff --git a/src/go/plugins/smart/smart.go b/src/go/plugins/smart/smart.go index e7560abcd5c..0401f0eead1 100644 --- a/src/go/plugins/smart/smart.go +++ b/src/go/plugins/smart/smart.go @@ -123,7 +123,7 @@ func (p *Plugin) diskDiscovery() (jsonArray []byte, err error) { DeviceType: getType(dev.Info.DevType, dev.RotationRate, dev.SmartAttributes.Table), Model: dev.ModelName, SerialNumber: dev.SerialNumber, - Path: dev.Info.Name, + Path: dev.Info.path, Attributes: getAttributes(dev), }) } diff --git a/src/go/plugins/smart/smartfs.go b/src/go/plugins/smart/smartfs.go index 0c694fe0cad..4a573cb11c2 100644 --- a/src/go/plugins/smart/smartfs.go +++ b/src/go/plugins/smart/smartfs.go @@ -157,6 +157,7 @@ type deviceInfo struct { Name string `json:"name"` InfoName string `json:"info_name"` DevType string `json:"type"` + path string `json:"-"` } type smartctl struct { @@ -247,12 +248,7 @@ func (p *Plugin) execute(jsonRunner bool) (*runner, error) { // executeSingle returns device data for single device from smartctl based on provided path. func (p *Plugin) executeSingle(path string) (device []byte, err error) { - basicDev, raidDev, megaraidDev, err := p.getDevices() - if err != nil { - return nil, err - } - - device, err = p.executeSmartctl(fmt.Sprintf("-a %s -j", getDeviceName(path, basicDev, raidDev, megaraidDev)), false) + device, err = p.executeSmartctl(fmt.Sprintf("-a %s -j", path), false) if err != nil { return nil, fmt.Errorf("Failed to execute smartctl: %s.", err.Error()) } @@ -260,29 +256,6 @@ func (p *Plugin) executeSingle(path string) (device []byte, err error) { return } -// getDeviceName returns single device name, based on the provided path. -func getDeviceName(path string, basicDev, raidDev, megaraidDev []deviceInfo) string { - for _, b := range basicDev { - if b.Name == path { - return b.Name - } - } - - for _, b := range raidDev { - if b.Name == path { - return b.InfoName - } - } - - for _, b := range megaraidDev { - if b.Name == path { - return fmt.Sprintf("-a %s -d %s -j ", b.Name, b.DevType) - } - } - - return path -} - //executeBase executed runners for basic devices retrieved from smartctl. func (r *runner) executeBase(basicDev []deviceInfo, jsonRunner bool) error { r.startBasicRunners(jsonRunner) @@ -480,6 +453,8 @@ func (r *runner) getBasicDevices(jsonRunner bool) { return } + dp.Info.path = name + r.mux.Lock() if jsonRunner { @@ -555,8 +530,10 @@ runner: if dp.SmartStatus != nil { if raid.rType == satType { dp.Info.Name = fmt.Sprintf("%s %s", raid.name, raid.rType) + dp.Info.path = fmt.Sprintf("%s -d %s", raid.name, raid.rType) } else { dp.Info.Name = fmt.Sprintf("%s %s,%d", raid.name, raid.rType, i) + dp.Info.path = fmt.Sprintf("%s -d %s,%d", raid.name, raid.rType, i) } if r.setRaidDevices(dp, device, raid.rType, jsonRunner) { |