2022-10-14 19:55:35 +02:00
|
|
|
package model
|
|
|
|
|
|
|
|
type Metrics struct {
|
2022-10-14 22:13:21 +02:00
|
|
|
Now int64 `json:"now"`
|
|
|
|
Sessions map[string]SessionMetrics
|
2022-10-14 19:55:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Metrics) PushSession(svcName string, sm SessionMetrics) {
|
|
|
|
if m.Sessions == nil {
|
|
|
|
m.Sessions = make(map[string]SessionMetrics)
|
|
|
|
}
|
|
|
|
if prev, found := m.Sessions[svcName]; found {
|
|
|
|
prev.BytesRead += sm.BytesRead
|
|
|
|
prev.BytesWritten += sm.BytesWritten
|
|
|
|
prev.LastUpdate = sm.LastUpdate
|
|
|
|
m.Sessions[svcName] = prev
|
|
|
|
} else {
|
|
|
|
m.Sessions[svcName] = sm
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type SessionMetrics struct {
|
|
|
|
BytesRead int64
|
|
|
|
BytesWritten int64
|
|
|
|
LastUpdate int64
|
|
|
|
}
|