analyzer

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Level       AlertLevel             `json:"level"`
	Device      string                 `json:"device"`
	Title       string                 `json:"title"`
	Description string                 `json:"description"`
	Timestamp   time.Time              `json:"timestamp"`
	Data        map[string]interface{} `json:"data,omitempty"`
}

Alert represents a disk health alert

type AlertConfig

type AlertConfig struct {
	Enabled        bool       `json:"enabled"`
	WebhookURL     string     `json:"webhook_url,omitempty"`
	WebhookTimeout int        `json:"webhook_timeout"` // seconds
	MinLevel       AlertLevel `json:"min_level"`
	Cooldown       int        `json:"cooldown"` // minutes between alerts for same device
}

AlertConfig configures the alert system

type AlertLevel

type AlertLevel string

AlertLevel defines the severity level for alerts

const (
	AlertInfo     AlertLevel = "INFO"
	AlertWarning  AlertLevel = "WARNING"
	AlertCritical AlertLevel = "CRITICAL"
)

type AlertManager

type AlertManager struct {
	// contains filtered or unexported fields
}

AlertManager manages disk health alerts

func NewAlertManager

func NewAlertManager(config AlertConfig) *AlertManager

NewAlertManager creates a new alert manager

func (*AlertManager) CheckAndAlert

func (am *AlertManager) CheckAndAlert(result *AnalysisResult) error

CheckAndAlert analyzes a SMART result and sends alerts if necessary

func (*AlertManager) ClearCooldown

func (am *AlertManager) ClearCooldown(device string)

ClearCooldown clears the cooldown for a specific device

func (*AlertManager) GetLastAlertTime

func (am *AlertManager) GetLastAlertTime(device string) (time.Time, bool)

GetLastAlertTime returns the last alert time for a device

type AnalysisResult

type AnalysisResult struct {
	Device             string
	OverallHealth      HealthStatus
	PredictedFailure   bool
	FailureProbability float64 // 0-100%
	TimeToFailure      *time.Duration
	Issues             []Issue
	Recommendations    []string
	SSDWearAnalysis    *SSDWearInfo
}

AnalysisResult contains the results of SMART analysis

type AnalyzerConfig

type AnalyzerConfig struct {
	// Temperature thresholds in Celsius
	TempWarning  int
	TempCritical int

	// SSD wear thresholds (percentage)
	WearWarning  float64
	WearCritical float64

	// Enable predictive analysis
	EnablePredictive bool
}

AnalyzerConfig contains configuration for SMART analysis

type HealthStatus

type HealthStatus string

HealthStatus represents the health status of a drive

const (
	HealthGood     HealthStatus = "GOOD"
	HealthWarning  HealthStatus = "WARNING"
	HealthCritical HealthStatus = "CRITICAL"
	HealthFailing  HealthStatus = "FAILING"
	HealthUnknown  HealthStatus = "UNKNOWN"
)

type HistoryDB

type HistoryDB struct {
	// contains filtered or unexported fields
}

HistoryDB manages SMART data history

func NewHistoryDB

func NewHistoryDB(dbPath string) (*HistoryDB, error)

NewHistoryDB creates a new history database

func (*HistoryDB) CleanOldRecords

func (h *HistoryDB) CleanOldRecords(olderThan time.Duration) error

CleanOldRecords removes records older than the specified duration

func (*HistoryDB) Close

func (h *HistoryDB) Close() error

Close closes the database connection

func (*HistoryDB) GetDevices

func (h *HistoryDB) GetDevices() ([]string, error)

GetDevices returns all devices with recorded history

func (*HistoryDB) GetHistory

func (h *HistoryDB) GetHistory(device string, since time.Time, limit int) ([]SMARTHistoryRecord, error)

GetHistory retrieves historical records for a device

func (*HistoryDB) GetTrend

func (h *HistoryDB) GetTrend(device string, since time.Time) (*TrendData, error)

GetTrend analyzes trends for a device over a time period

func (*HistoryDB) RecordAnalysis

func (h *HistoryDB) RecordAnalysis(smart *types.SMARTInfo, result *AnalysisResult) error

RecordAnalysis stores a SMART analysis result

type Issue

type Issue struct {
	Severity    Severity
	Code        string
	Description string
	AttributeID uint8
	Value       string
}

Issue represents a specific SMART issue

type SMARTAnalyzer

type SMARTAnalyzer struct {
	// contains filtered or unexported fields
}

SMARTAnalyzer analyzes SMART data for predictive failure detection

func NewSMARTAnalyzer

func NewSMARTAnalyzer() *SMARTAnalyzer

NewSMARTAnalyzer creates a new SMART analyzer with default config

func NewSMARTAnalyzerWithConfig

func NewSMARTAnalyzerWithConfig(config AnalyzerConfig) *SMARTAnalyzer

NewSMARTAnalyzerWithConfig creates a new SMART analyzer with custom config

func (*SMARTAnalyzer) Analyze

func (a *SMARTAnalyzer) Analyze(smart *types.SMARTInfo) *AnalysisResult

Analyze performs comprehensive SMART analysis

type SMARTHistoryRecord

type SMARTHistoryRecord struct {
	ID                 int64
	Device             string
	Timestamp          time.Time
	Temperature        int
	PowerOnHours       int64
	HealthStatus       HealthStatus
	FailureProbability float64
	RemainingLife      float64
	PercentUsed        float64
	IssueCount         int
	CriticalIssues     int
	WarningIssues      int
}

SMARTHistoryRecord represents a historical SMART reading

type SSDWearInfo

type SSDWearInfo struct {
	WearLevelingCount uint64
	ProgramEraseCount uint64
	PercentUsed       float64
	EstimatedLifespan time.Duration
	RemainingLife     float64 // 0-100%
	WearStatus        HealthStatus
}

SSDWearInfo contains SSD-specific wear analysis

type Severity

type Severity string

Severity levels for issues

const (
	SeverityInfo     Severity = "INFO"
	SeverityWarning  Severity = "WARNING"
	SeverityCritical Severity = "CRITICAL"
)

type TrendData

type TrendData struct {
	Device               string
	StartTime            time.Time
	EndTime              time.Time
	AvgTemperature       float64
	MaxTemperature       int
	MinTemperature       int
	TempTrend            string // "increasing", "stable", "decreasing"
	HealthTrend          string // "improving", "stable", "degrading"
	SSDWearRate          float64
	EstimatedFailureDate *time.Time
	RecordCount          int
}

TrendData represents trend analysis over a time period

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL