34 lines
741 B
Go
34 lines
741 B
Go
package collectors
|
|
|
|
type StatusInfo struct {
|
|
CPULoad1 float32
|
|
CPULoad5 float32
|
|
CPULoad15 float32
|
|
Year int
|
|
Month int
|
|
Day int
|
|
Hour int
|
|
Minute int
|
|
Second int
|
|
BatteryPercent int
|
|
BatteryStatus string
|
|
}
|
|
|
|
func Collect() (*StatusInfo, error) {
|
|
year, month, day, hour, minute, second := datetime()
|
|
cpuLoad1, cpuLoad5, cpuLoad15 := cpuLoad()
|
|
return &StatusInfo{
|
|
CPULoad1: cpuLoad1,
|
|
CPULoad5: cpuLoad5,
|
|
CPULoad15: cpuLoad15,
|
|
Year: year,
|
|
Month: int(month),
|
|
Day: day,
|
|
Hour: hour,
|
|
Minute: minute,
|
|
Second: second,
|
|
BatteryPercent: 100,
|
|
BatteryStatus: "Charging",
|
|
}, nil
|
|
}
|