Documentation
¶
Index ¶
- Constants
- type DB
- func (d *DB) Close() error
- func (d *DB) DeleteTarget(id uint) error
- func (d *DB) GetHistory(target string, start, end time.Time) ([]MonitorRecord, error)
- func (d *DB) GetLatestRecord(target string) (*MonitorRecord, error)
- func (d *DB) GetLatestTrace(target string) (*MonitorRecord, error)
- func (d *DB) GetRecordDetail(id uint) (*MonitorRecord, error)
- func (d *DB) GetTargets(onlyEnabled bool) ([]Target, error)
- func (d *DB) GetUser(username string) (*User, error)
- func (d *DB) HasAnyUser() bool
- func (d *DB) PruneOldData(retentionDays int) error
- func (d *DB) SaveRecord(r *MonitorRecord) error
- func (d *DB) SaveTarget(t *Target) error
- func (d *DB) SaveUser(u *User) error
- type MonitorRecord
- type Target
- type User
Constants ¶
View Source
const ( ProbeModeICMP = "MODE_ICMP" ProbeModeHTTP = "MODE_HTTP" ProbeModeSSH = "MODE_SSH" ProbeModeIPERF = "MODE_IPERF" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) DeleteTarget ¶
func (*DB) GetHistory ¶
GetHistory fetches records for a specific target within a time range. Optimization: We exclude TraceJson to reduce I/O for general charts.
func (*DB) GetLatestRecord ¶
func (d *DB) GetLatestRecord(target string) (*MonitorRecord, error)
GetLatestRecord fetches the most recent record for a target
func (*DB) GetLatestTrace ¶
func (d *DB) GetLatestTrace(target string) (*MonitorRecord, error)
GetLatestTrace fetches the most recent record that includes traceroute data
func (*DB) GetRecordDetail ¶
func (d *DB) GetRecordDetail(id uint) (*MonitorRecord, error)
GetRecordDetail fetches the full record including TraceJson by ID
func (*DB) HasAnyUser ¶
func (*DB) PruneOldData ¶
PruneOldData deletes records older than the specified retention days
func (*DB) SaveRecord ¶
func (d *DB) SaveRecord(r *MonitorRecord) error
SaveRecord persists a monitoring record
func (*DB) SaveTarget ¶
type MonitorRecord ¶
type MonitorRecord struct {
ID uint `gorm:"primaryKey" json:"id"`
CreatedAt time.Time `gorm:"index;not null" json:"created_at"` // Time-series index
Target string `gorm:"index;type:varchar(128);not null" json:"target"`
// Ping Metrics (Always present)
LatencyMs float64 `gorm:"not null" json:"latency_ms"` // Average RTT in milliseconds
PacketLoss float64 `gorm:"not null" json:"packet_loss"` // Loss Percentage (0.0 - 100.0)
// Traceroute Data (JSON Blob)
TraceJson []byte `gorm:"type:text" json:"trace_json,omitempty"`
// Speed Test Metrics
SpeedUp float64 `gorm:"default:0" json:"speed_up"` // Mbps
SpeedDown float64 `gorm:"default:0" json:"speed_down"` // Mbps
}
MonitorRecord represents a single monitoring data point (snapshot)
type Target ¶
type Target struct {
ID uint `gorm:"primaryKey" json:"id"`
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Name string `gorm:"type:varchar(64);not null" json:"name"`
Address string `gorm:"type:varchar(128);uniqueIndex;not null" json:"address"` // IP or Domain
Desc string `gorm:"type:text" json:"desc"`
Enabled bool `gorm:"default:true" json:"enabled"`
// --- Probing Configuration (Phase 13) ---
// ProbeMode: ICMP, SSH, HTTP, IPERF3
ProbeType string `gorm:"column:probe_type;type:varchar(20);default:'MODE_ICMP'" json:"probe_type"`
// ProbeConfig (JSON stored as text for flexibility)
// Includes URL for HTTP, Port for Iperf, Credentials for SSH
ProbeConfig string `gorm:"column:probe_config;type:text" json:"probe_config"`
}
Target represents a monitoring destination
type User ¶
type User struct {
ID uint `gorm:"primaryKey" json:"id"`
CreatedAt time.Time `gorm:"not null" json:"created_at"`
Username string `gorm:"type:varchar(64);uniqueIndex;not null" json:"username"`
Password string `gorm:"type:varchar(128);not null" json:"-"` // Hashed
}
User represents a system administrator
Click to show internal directories.
Click to hide internal directories.