91 lines
3.4 KiB
Go
91 lines
3.4 KiB
Go
package protocol
|
|
|
|
const (
|
|
ServerStatsRequest = "server_stats"
|
|
ServerStatsResult = "server_stats_result"
|
|
)
|
|
|
|
type ServerStats struct {
|
|
SampledAt string `json:"sampled_at"`
|
|
Host ServerHostStats `json:"host"`
|
|
CPU ServerCPUStats `json:"cpu"`
|
|
Memory ServerMemoryStats `json:"memory"`
|
|
Storage []ServerDiskStats `json:"storage"`
|
|
Data ServerDataStats `json:"data"`
|
|
Process ServerProcessStats `json:"process"`
|
|
GPU ServerGPUStats `json:"gpu"`
|
|
}
|
|
type ServerHostStats struct {
|
|
Hostname string `json:"hostname"`
|
|
OS string `json:"os"`
|
|
Platform string `json:"platform"`
|
|
PlatformVersion string `json:"platform_version"`
|
|
Kernel string `json:"kernel"`
|
|
Arch string `json:"arch"`
|
|
UptimeSeconds uint64 `json:"uptime_seconds"`
|
|
Load1 *float64 `json:"load1,omitempty"`
|
|
Load5 *float64 `json:"load5,omitempty"`
|
|
Load15 *float64 `json:"load15,omitempty"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|
|
type ServerCPUStats struct {
|
|
Model string `json:"model"`
|
|
LogicalCores int `json:"logical_cores"`
|
|
PhysicalCores int `json:"physical_cores"`
|
|
UsagePercent float64 `json:"usage_percent"`
|
|
PerCorePercent []float64 `json:"per_core_percent,omitempty"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|
|
type ServerMemoryStats struct {
|
|
TotalBytes uint64 `json:"total_bytes"`
|
|
UsedBytes uint64 `json:"used_bytes"`
|
|
AvailableBytes uint64 `json:"available_bytes"`
|
|
UsedPercent float64 `json:"used_percent"`
|
|
SwapTotalBytes uint64 `json:"swap_total_bytes"`
|
|
SwapUsedBytes uint64 `json:"swap_used_bytes"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|
|
type ServerDiskStats struct {
|
|
Mount string `json:"mount"`
|
|
Device string `json:"device"`
|
|
FSType string `json:"fs_type"`
|
|
TotalBytes uint64 `json:"total_bytes"`
|
|
UsedBytes uint64 `json:"used_bytes"`
|
|
FreeBytes uint64 `json:"free_bytes"`
|
|
UsedPercent float64 `json:"used_percent"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|
|
type ServerDataStats struct {
|
|
Dir string `json:"dir"`
|
|
DBBytes uint64 `json:"db_bytes"`
|
|
ArtifactsBytes uint64 `json:"artifacts_bytes"`
|
|
TotalBytes uint64 `json:"total_bytes"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|
|
type ServerProcessStats struct {
|
|
PID int32 `json:"pid"`
|
|
StartedAt string `json:"started_at"`
|
|
RSSBytes uint64 `json:"rss_bytes,omitempty"`
|
|
CPUPercent float64 `json:"cpu_percent,omitempty"`
|
|
Goroutines int `json:"goroutines,omitempty"`
|
|
HeapBytes uint64 `json:"heap_bytes,omitempty"`
|
|
Threads int `json:"threads,omitempty"`
|
|
GoVersion string `json:"go_version,omitempty"`
|
|
Build string `json:"build,omitempty"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|
|
type ServerGPUStats struct {
|
|
Available bool `json:"available"`
|
|
Reason string `json:"reason,omitempty"`
|
|
Devices []ServerGPUDevice `json:"devices,omitempty"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|
|
type ServerGPUDevice struct {
|
|
Name string `json:"name"`
|
|
Vendor string `json:"vendor,omitempty"`
|
|
UtilizationPercent *float64 `json:"utilization_percent,omitempty"`
|
|
MemoryTotalBytes *uint64 `json:"memory_total_bytes,omitempty"`
|
|
MemoryUsedBytes *uint64 `json:"memory_used_bytes,omitempty"`
|
|
TemperatureC *float64 `json:"temperature_c,omitempty"`
|
|
}
|