// GetOrRegisterPrivateCPU produces a registered in PrivateCPURegistry MetricCPU. func (ir *IndexRegistry) GetOrRegisterPrivateCPU(coreno int) operating.MetricCPU { ir.PrivateMutex.Lock() defer ir.PrivateMutex.Unlock() name := fmt.Sprintf("cpu-%d", coreno) if metric := ir.PrivateCPURegistry.Get(name); metric != nil { return metric.(operating.MetricCPU) } i := *system.NewMetricCPU(ir.Registry, name) ir.PrivateCPURegistry.Register(name, i) // error is ignored // errs when the type is not derived from (go-)metrics types return i }
func init() { Reg1s = IndexRegistry{ Registry: metrics.NewRegistry(), PrivateCPURegistry: metrics.NewRegistry(), PrivateInterfaceRegistry: metrics.NewRegistry(), PrivateDFRegistry: metrics.NewRegistry(), } Reg1s.PrivateCPUAll = /* *Reg1s.RegisterCPU */ *system.NewMetricCPU( /* pcreg := */ metrics.NewRegistry(), "all") // pcreg.Register("all", Reg1s.PrivateCPUAll) Reg1s.RAM = system.NewMetricRAM(Reg1s.Registry) Reg1s.Swap = operating.NewMetricSwap(Reg1s.Registry) Reg1s.Load = operating.NewMetricLoad(Reg1s.Registry) }