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

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