Add support for monitoring sensor temperatures (#21)

This commit is contained in:
Leon
2024-06-01 19:11:54 +08:00
committed by GitHub
parent 611ad8be20
commit 968faca950
4 changed files with 197 additions and 77 deletions
+15
View File
@@ -4,6 +4,11 @@ import (
pb "github.com/nezhahq/agent/proto"
)
type SensorTemperature struct {
Name string
Temperature float64
}
type HostState struct {
CPU float64
MemUsed uint64
@@ -20,9 +25,18 @@ type HostState struct {
TcpConnCount uint64
UdpConnCount uint64
ProcessCount uint64
Temperatures []SensorTemperature
}
func (s *HostState) PB() *pb.State {
var ts []*pb.State_SensorTemperature
for _, t := range s.Temperatures {
ts = append(ts, &pb.State_SensorTemperature{
Name: t.Name,
Temperature: t.Temperature,
})
}
return &pb.State{
Cpu: s.CPU,
MemUsed: s.MemUsed,
@@ -39,6 +53,7 @@ func (s *HostState) PB() *pb.State {
TcpConnCount: s.TcpConnCount,
UdpConnCount: s.UdpConnCount,
ProcessCount: s.ProcessCount,
Temperatures: ts,
}
}