b44ef5cb9c
/scrutiny/config/collector.yaml Adding ability to specify host identifier (label), that is updated on every collector run. Can be specified by `host-id` CLI or `COLLECTOR_HOST_ID` env var. Created a config class, interface and associated tests. Created a "TransformDetectedDrives" function, that will allow users to insert drives not detected by Smarctl --scan, ignore drives that they dont want, and override smartctl device type. Added Upsert functionality when registering devices. Replaced "github.com/jinzhu/gorm" with "gorm.io/gorm" (ORM location moved, was using incorrect lib url) Removed machineid library.
38 lines
810 B
Go
38 lines
810 B
Go
package detect
|
|
|
|
import (
|
|
"github.com/analogj/scrutiny/collector/pkg/models"
|
|
"strings"
|
|
)
|
|
|
|
func DevicePrefix() string {
|
|
return ""
|
|
}
|
|
|
|
func (d *Detect) Start() ([]models.Device, error) {
|
|
// call the base/common functionality to get a list of devices
|
|
detectedDevices, err := d.SmartctlScan()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
//inflate device info for detected devices.
|
|
for ndx, _ := range detectedDevices {
|
|
d.SmartCtlInfo(&detectedDevices[ndx]) //ignore errors.
|
|
}
|
|
|
|
return detectedDevices, nil
|
|
}
|
|
|
|
//WWN values NVMe and SCSI
|
|
func (d *Detect) wwnFallback(detectedDevice *models.Device) {
|
|
|
|
//fallback to serial number
|
|
if len(detectedDevice.WWN) == 0 {
|
|
detectedDevice.WWN = detectedDevice.SerialNumber
|
|
}
|
|
|
|
//wwn must always be lowercase.
|
|
detectedDevice.WWN = strings.ToLower(detectedDevice.WWN)
|
|
}
|