ctop/models/main.go

58 lines
909 B
Go
Raw Normal View History

2017-06-27 17:46:03 +02:00
package models
import "time"
type Log struct {
Timestamp time.Time
Message string
}
type Meta map[string]string
2019-07-06 01:05:21 +02:00
// NewMeta returns an initialized Meta map.
// An optional series of key, values may be provided to populate the map prior to returning
func NewMeta(kvs ...string) Meta {
m := make(Meta)
2020-01-03 13:07:21 +01:00
var i int
for i < len(kvs)-1 {
m[kvs[i]] = kvs[i+1]
i += 2
2019-07-06 01:05:21 +02:00
}
return m
}
func (m Meta) Get(k string) string {
if s, ok := m[k]; ok {
return s
}
return ""
}
type Metrics struct {
NCpus uint8
2017-03-12 02:35:40 +01:00
CPUUtil int
NetTx int64
NetRx int64
MemLimit int64
MemPercent int
MemUsage int64
IOBytesRead int64
IOBytesWrite int64
Pids int
}
func NewMetrics() Metrics {
return Metrics{
2017-06-10 15:00:54 +02:00
CPUUtil: -1,
NetTx: -1,
NetRx: -1,
MemUsage: -1,
MemPercent: -1,
IOBytesRead: -1,
IOBytesWrite: -1,
Pids: -1,
}
}