adding device protocl and type to the. Adding class for parsing smartctl --scan json output, for device detection. added an example/test file for smartctl -x -j added a placeholder settings panel. moved dashboard & details compoonent out of "Admin" directory.

This commit is contained in:
Jason Kulatunga
2020-09-16 08:09:50 -07:00
parent 98415e625d
commit 5101a37964
27 changed files with 1957 additions and 25 deletions
+12 -1
View File
@@ -23,6 +23,18 @@ type BaseCollector struct {
func (c *BaseCollector) DetectStorageDevices() ([]models.Device, error) {
//availableDisksJson, err := c.ExecCmd("smartctl", []string{"-j", "--scan"}, "", os.Environ())
//if err != nil {
// c.logger.Errorf("Error getting block storage info: %v", err)
// return nil, err
//}
//
//var smartctlScan models.Scan
//err = json.Unmarshal([]byte(availableDisksJson), &smartctlScan)
//if err != nil {
// return nil, err
//}
block, err := ghw.Block()
if err != nil {
c.logger.Errorf("Error getting block storage info: %v", err)
@@ -83,7 +95,6 @@ func (c *BaseCollector) DetectStorageDevices() ([]models.Device, error) {
approvedDisks = append(approvedDisks, diskModel)
}
return approvedDisks, nil
}
+2
View File
@@ -14,6 +14,8 @@ type Device struct {
Capacity int64 `json:"capacity"`
FormFactor string `json:"form_factor"`
SmartSupport bool `json:"smart_support"`
DeviceProtocol string `json:"device_protocol"` //protocol determines which smart attribute types are available (ATA, NVMe, SCSI)
DeviceType string `json:"device_type"` //device type is used for querying with -d/t flag, should only be used by collector.
}
type DeviceWrapper struct {
+19
View File
@@ -0,0 +1,19 @@
package models
type Scan struct {
JSONFormatVersion []int `json:"json_format_version"`
Smartctl struct {
Version []int `json:"version"`
SvnRevision string `json:"svn_revision"`
PlatformInfo string `json:"platform_info"`
BuildInfo string `json:"build_info"`
Argv []string `json:"argv"`
ExitStatus int `json:"exit_status"`
} `json:"smartctl"`
Devices []struct {
Name string `json:"name"`
InfoName string `json:"info_name"`
Type string `json:"type"`
Protocol string `json:"protocol"`
} `json:"devices"`
}