mirror of
https://github.com/henrygd/beszel.git
synced 2026-03-28 00:16:16 +01:00
S.M.A.R.T support (#614)
* add agent smart support * refactor(system): update JSON tags in SmartData struct * refactor(agent): use serial number as the key of SmartDataMap Updated the SmartManager's methods to use the device's serial number as the key in the SmartDataMap instead of the device name. * refactor: use raw values in smart attributes for nvme devices * feat: add S.M.A.R.T. data display in web ui Introduced a new Disks tab in the SystemDetail component to display disk information and S.M.A.R.T. data. The tab includes a table for visualizing disk attributes and their statuses. Also added SmartData and SmartAttribute interfaces to support the new functionality.
This commit is contained in:
@@ -8,29 +8,30 @@ import (
|
||||
)
|
||||
|
||||
type Stats struct {
|
||||
Cpu float64 `json:"cpu"`
|
||||
MaxCpu float64 `json:"cpum,omitempty"`
|
||||
Mem float64 `json:"m"`
|
||||
MemUsed float64 `json:"mu"`
|
||||
MemPct float64 `json:"mp"`
|
||||
MemBuffCache float64 `json:"mb"`
|
||||
MemZfsArc float64 `json:"mz,omitempty"` // ZFS ARC memory
|
||||
Swap float64 `json:"s,omitempty"`
|
||||
SwapUsed float64 `json:"su,omitempty"`
|
||||
DiskTotal float64 `json:"d"`
|
||||
DiskUsed float64 `json:"du"`
|
||||
DiskPct float64 `json:"dp"`
|
||||
DiskReadPs float64 `json:"dr"`
|
||||
DiskWritePs float64 `json:"dw"`
|
||||
MaxDiskReadPs float64 `json:"drm,omitempty"`
|
||||
MaxDiskWritePs float64 `json:"dwm,omitempty"`
|
||||
NetworkSent float64 `json:"ns"`
|
||||
NetworkRecv float64 `json:"nr"`
|
||||
MaxNetworkSent float64 `json:"nsm,omitempty"`
|
||||
MaxNetworkRecv float64 `json:"nrm,omitempty"`
|
||||
Temperatures map[string]float64 `json:"t,omitempty"`
|
||||
ExtraFs map[string]*FsStats `json:"efs,omitempty"`
|
||||
GPUData map[string]GPUData `json:"g,omitempty"`
|
||||
Cpu float64 `json:"cpu"`
|
||||
MaxCpu float64 `json:"cpum,omitempty"`
|
||||
Mem float64 `json:"m"`
|
||||
MemUsed float64 `json:"mu"`
|
||||
MemPct float64 `json:"mp"`
|
||||
MemBuffCache float64 `json:"mb"`
|
||||
MemZfsArc float64 `json:"mz,omitempty"` // ZFS ARC memory
|
||||
Swap float64 `json:"s,omitempty"`
|
||||
SwapUsed float64 `json:"su,omitempty"`
|
||||
DiskTotal float64 `json:"d"`
|
||||
DiskUsed float64 `json:"du"`
|
||||
DiskPct float64 `json:"dp"`
|
||||
DiskReadPs float64 `json:"dr"`
|
||||
DiskWritePs float64 `json:"dw"`
|
||||
MaxDiskReadPs float64 `json:"drm,omitempty"`
|
||||
MaxDiskWritePs float64 `json:"dwm,omitempty"`
|
||||
NetworkSent float64 `json:"ns"`
|
||||
NetworkRecv float64 `json:"nr"`
|
||||
MaxNetworkSent float64 `json:"nsm,omitempty"`
|
||||
MaxNetworkRecv float64 `json:"nrm,omitempty"`
|
||||
Temperatures map[string]float64 `json:"t,omitempty"`
|
||||
ExtraFs map[string]*FsStats `json:"efs,omitempty"`
|
||||
GPUData map[string]GPUData `json:"g,omitempty"`
|
||||
SmartData map[string]SmartData `json:"sm,omitempty"`
|
||||
}
|
||||
|
||||
type GPUData struct {
|
||||
@@ -73,6 +74,31 @@ const (
|
||||
Freebsd
|
||||
)
|
||||
|
||||
type SmartData struct {
|
||||
ModelFamily string `json:"mf,omitempty"`
|
||||
ModelName string `json:"mn,omitempty"`
|
||||
SerialNumber string `json:"sn,omitempty"`
|
||||
FirmwareVersion string `json:"fv,omitempty"`
|
||||
Capacity uint64 `json:"c,omitempty"`
|
||||
SmartStatus string `json:"s,omitempty"`
|
||||
DiskName string `json:"dn,omitempty"` // something like /dev/sda
|
||||
DiskType string `json:"dt,omitempty"`
|
||||
Temperature int `json:"t,omitempty"`
|
||||
Attributes []*SmartAttribute `json:"a,omitempty"`
|
||||
}
|
||||
|
||||
type SmartAttribute struct {
|
||||
Id int `json:"id,omitempty"`
|
||||
Name string `json:"n"`
|
||||
Value int `json:"v,omitempty"`
|
||||
Worst int `json:"w,omitempty"`
|
||||
Threshold int `json:"t,omitempty"`
|
||||
RawValue int `json:"rv"`
|
||||
RawString string `json:"rs,omitempty"`
|
||||
Flags string `json:"f,omitempty"`
|
||||
WhenFailed string `json:"wf,omitempty"`
|
||||
}
|
||||
|
||||
type Info struct {
|
||||
Hostname string `json:"h"`
|
||||
KernelVersion string `json:"k,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user