You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rition/rition-probe/service/service.go

39 lines
762 B

package service
import (
"rition-probe/client"
"rition-probe/probe"
"time"
)
type Config struct {
ClientConfig client.Config
MonitorDiskDevice string
MonitorDiskMountPoint string
MonitorNetworkInterface string
ReportInterval time.Duration `json:"reportInterval,omitempty"`
}
type Service struct {
config Config
probe *probe.Probe
client *client.Client
prevCpuLoadDataCollectTime time.Time
prevCpuLoadData float64
}
func NewService(config Config) *Service {
service := Service{
config: config,
probe: probe.NewProbe(),
client: client.NetClient(config.ClientConfig),
}
service.prevCpuLoadData = service.probe.CurrentCPUTotalPercent()
service.prevCpuLoadDataCollectTime = time.Now()
return &service
}