2017-06-27 15:46:03 +00:00
|
|
|
package models
|
2017-01-20 12:41:26 +00:00
|
|
|
|
2017-07-04 12:32:25 +00:00
|
|
|
import "time"
|
|
|
|
|
|
|
|
type Log struct {
|
|
|
|
Timestamp time.Time
|
|
|
|
Message string
|
|
|
|
}
|
|
|
|
|
2019-06-08 21:34:43 +00:00
|
|
|
type Meta map[string]string
|
|
|
|
|
2019-07-05 23:05:21 +00: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 12:07:21 +00:00
|
|
|
var i int
|
|
|
|
for i < len(kvs)-1 {
|
|
|
|
m[kvs[i]] = kvs[i+1]
|
|
|
|
i += 2
|
2019-07-05 23:05:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
2019-06-08 21:34:43 +00:00
|
|
|
|
|
|
|
func (m Meta) Get(k string) string {
|
|
|
|
if s, ok := m[k]; ok {
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2017-01-20 12:41:26 +00:00
|
|
|
type Metrics struct {
|
2017-03-12 01:35:40 +00:00
|
|
|
CPUUtil int
|
|
|
|
NetTx int64
|
|
|
|
NetRx int64
|
|
|
|
MemLimit int64
|
|
|
|
MemPercent int
|
|
|
|
MemUsage int64
|
|
|
|
IOBytesRead int64
|
|
|
|
IOBytesWrite int64
|
|
|
|
Pids int
|
2017-01-20 12:41:26 +00:00
|
|
|
}
|
|
|
|
|
2017-02-28 23:23:24 +00:00
|
|
|
func NewMetrics() Metrics {
|
|
|
|
return Metrics{
|
2017-06-10 13:00:54 +00:00
|
|
|
CPUUtil: -1,
|
|
|
|
NetTx: -1,
|
|
|
|
NetRx: -1,
|
|
|
|
MemUsage: -1,
|
|
|
|
MemPercent: -1,
|
|
|
|
IOBytesRead: -1,
|
|
|
|
IOBytesWrite: -1,
|
|
|
|
Pids: -1,
|
2017-02-28 23:23:24 +00:00
|
|
|
}
|
|
|
|
}
|