Add server stats websocket reporting
This commit is contained in:
@@ -282,6 +282,7 @@ type Message struct {
|
||||
// whole set) and the attention_acks_changed push (the delta). See
|
||||
// attention_acks.go.
|
||||
AttentionAcks *AttentionAcks `json:"attention_acks,omitempty"`
|
||||
ServerStats *ServerStats `json:"server_stats,omitempty"`
|
||||
// App notification stream (see notifications.go): After is the
|
||||
// subscribe_notifications cursor, Notifications the subscribe reply,
|
||||
// Notification one push, and IDs the clear_notifications request, the
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
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"`
|
||||
}
|
||||
Reference in New Issue
Block a user