2020-08-14 15:14:57 +02:00
|
|
|
package stats
|
2020-08-13 18:33:49 +02:00
|
|
|
|
2020-11-17 17:10:59 +01:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
var logPackage = log.WithField("package", "stats")
|
2020-08-13 18:33:49 +02:00
|
|
|
|
2020-08-19 18:59:56 +02:00
|
|
|
// Client is the interface to be implement by a client to access the external data.
|
2020-08-14 15:14:57 +02:00
|
|
|
type Client interface {
|
|
|
|
GetData() (Data, error)
|
2020-08-13 18:33:49 +02:00
|
|
|
}
|
|
|
|
|
2020-08-14 15:14:57 +02:00
|
|
|
// Data is a datapoint representing a snapshot of the resources of a system to a given time.
|
|
|
|
type Data struct {
|
2020-11-06 09:46:21 +01:00
|
|
|
Hostname string
|
2020-08-13 18:33:49 +02:00
|
|
|
Date time.Time
|
|
|
|
CPU float64
|
|
|
|
Processes []Process
|
2020-08-19 16:36:31 +02:00
|
|
|
Disk Memory
|
|
|
|
Mem Memory
|
2020-08-13 18:33:49 +02:00
|
|
|
}
|
|
|
|
|
2020-08-19 18:59:56 +02:00
|
|
|
// Process is the representation of a UNIX process with some of its information.
|
2020-08-13 18:33:49 +02:00
|
|
|
type Process struct {
|
|
|
|
Name string
|
|
|
|
Pid int
|
|
|
|
CPU float64
|
|
|
|
}
|
|
|
|
|
2020-08-19 16:36:31 +02:00
|
|
|
// Memory represents the usage of disk or RAM space.
|
2020-08-19 18:59:56 +02:00
|
|
|
// It shows the used and the total available space.
|
2020-08-19 16:36:31 +02:00
|
|
|
type Memory struct {
|
2020-08-13 18:33:49 +02:00
|
|
|
Used int
|
|
|
|
Total int
|
|
|
|
}
|