mirror of
https://github.com/henrygd/beszel.git
synced 2025-12-16 18:26:16 +01:00
Skip virtual disks (#1332)
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -250,6 +251,29 @@ func (sm *SmartManager) parseScan(output []byte) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// isVirtualDevice checks if a device is a virtual disk that should be filtered out
|
||||
func (sm *SmartManager) isVirtualDevice(data *smart.SmartInfoForSata) bool {
|
||||
vendorUpper := strings.ToUpper(data.ScsiVendor)
|
||||
productUpper := strings.ToUpper(data.ScsiProduct)
|
||||
modelUpper := strings.ToUpper(data.ModelName)
|
||||
|
||||
switch {
|
||||
case strings.Contains(vendorUpper, "IET"), // iSCSI Enterprise Target
|
||||
strings.Contains(productUpper, "VIRTUAL"),
|
||||
strings.Contains(productUpper, "QEMU"),
|
||||
strings.Contains(productUpper, "VBOX"),
|
||||
strings.Contains(productUpper, "VMWARE"),
|
||||
strings.Contains(vendorUpper, "MSFT"), // Microsoft Hyper-V
|
||||
strings.Contains(modelUpper, "VIRTUAL"),
|
||||
strings.Contains(modelUpper, "QEMU"),
|
||||
strings.Contains(modelUpper, "VBOX"),
|
||||
strings.Contains(modelUpper, "VMWARE"):
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// parseSmartForSata parses the output of smartctl --all -j for SATA/ATA devices and updates the SmartDataMap
|
||||
// Returns hasValidData and exitStatus
|
||||
func (sm *SmartManager) parseSmartForSata(output []byte) (bool, int) {
|
||||
@@ -264,6 +288,12 @@ func (sm *SmartManager) parseSmartForSata(output []byte) (bool, int) {
|
||||
return false, data.Smartctl.ExitStatus
|
||||
}
|
||||
|
||||
// Skip virtual devices (e.g., Kubernetes PVCs, QEMU, VirtualBox, etc.)
|
||||
if sm.isVirtualDevice(&data) {
|
||||
slog.Debug("skipping virtual device", "device", data.Device.Name, "model", data.ModelName)
|
||||
return false, data.Smartctl.ExitStatus
|
||||
}
|
||||
|
||||
sm.Lock()
|
||||
defer sm.Unlock()
|
||||
|
||||
|
||||
@@ -211,6 +211,8 @@ type SmartInfoForSata struct {
|
||||
// Wwn WwnInfo `json:"wwn"`
|
||||
FirmwareVersion string `json:"firmware_version"`
|
||||
UserCapacity UserCapacity `json:"user_capacity"`
|
||||
ScsiVendor string `json:"scsi_vendor"`
|
||||
ScsiProduct string `json:"scsi_product"`
|
||||
// LogicalBlockSize int `json:"logical_block_size"`
|
||||
// PhysicalBlockSize int `json:"physical_block_size"`
|
||||
// RotationRate int `json:"rotation_rate"`
|
||||
|
||||
Reference in New Issue
Block a user