-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: Supraseal healthpage output (#325)
* supraffi: healthpage api * wire in health page getter * batchseal: Report nvme metrics to prometheus * make gen * batchseal: Fix data units
- Loading branch information
Showing
6 changed files
with
345 additions
and
3 deletions.
There are no files selected for viewing
Submodule supra_seal
updated
4 files
+1 −1 | c1/c1.hpp | |
+89 −0 | nvme/nvme_controller_t.hpp | |
+19 −0 | sealing/supra_seal.cpp | |
+1 −0 | sealing/supra_seal.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package supraffi | ||
|
||
import "time" | ||
|
||
// HealthInfo represents NVMe device health information in a more Go-friendly format | ||
type HealthInfo struct { | ||
// Critical warning flags | ||
CriticalWarning byte | ||
|
||
// Temperature information in Celsius | ||
Temperature float64 | ||
TemperatureSensors []float64 | ||
WarningTempTime time.Duration | ||
CriticalTempTime time.Duration | ||
|
||
// Reliability metrics | ||
AvailableSpare uint8 | ||
AvailableSpareThreshold uint8 | ||
PercentageUsed uint8 | ||
|
||
// Usage statistics | ||
DataUnitsRead uint64 // in 512-byte units | ||
DataUnitsWritten uint64 // in 512-byte units | ||
HostReadCommands uint64 | ||
HostWriteCommands uint64 | ||
ControllerBusyTime time.Duration | ||
|
||
// Power and error statistics | ||
PowerCycles uint64 | ||
PowerOnHours time.Duration | ||
UnsafeShutdowns uint64 | ||
MediaErrors uint64 | ||
ErrorLogEntries uint64 | ||
} | ||
|
||
// Helper methods for interpreting critical warning flags | ||
const ( | ||
WarningSpareSpace = 1 << 0 | ||
WarningTemperature = 1 << 1 | ||
WarningReliability = 1 << 2 | ||
WarningReadOnly = 1 << 3 | ||
WarningVolatileMemory = 1 << 4 | ||
WarningPersistentMemory = 1 << 5 | ||
) | ||
|
||
// HasWarning checks if a specific warning flag is set | ||
func (h *HealthInfo) HasWarning(flag byte) bool { | ||
return (h.CriticalWarning & flag) != 0 | ||
} | ||
|
||
// GetWarnings returns a slice of active warning descriptions | ||
func (h *HealthInfo) GetWarnings() []string { | ||
var warnings []string | ||
|
||
if h.HasWarning(WarningSpareSpace) { | ||
warnings = append(warnings, "available spare space has fallen below threshold") | ||
} | ||
if h.HasWarning(WarningTemperature) { | ||
warnings = append(warnings, "temperature is above critical threshold") | ||
} | ||
if h.HasWarning(WarningReliability) { | ||
warnings = append(warnings, "device reliability has been degraded") | ||
} | ||
if h.HasWarning(WarningReadOnly) { | ||
warnings = append(warnings, "media has been placed in read only mode") | ||
} | ||
if h.HasWarning(WarningVolatileMemory) { | ||
warnings = append(warnings, "volatile memory backup device has failed") | ||
} | ||
if h.HasWarning(WarningPersistentMemory) { | ||
warnings = append(warnings, "persistent memory region has become read-only") | ||
} | ||
|
||
return warnings | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.