func mkdir(dir *tricorder.DirectorySpec, name string) *tricorder.DirectorySpec { subdir, err := dir.RegisterDirectory(name) if err != nil { panic(err) } return subdir }
func (m *timeMetric) register(dir *tricorder.DirectorySpec, name, use string) error { if err := dir.RegisterMetric(name, &m.value, units.None, use); err != nil { return err } return dir.RegisterMetric(name+"-fraction", &m.fraction, units.None, use+" during last probe interval") }
func (configuration *Configuration) registerMetrics( dir *tricorder.DirectorySpec) error { netDir, err := dir.RegisterDirectory("network") if err != nil { return err } return configuration.NetworkReaderContext.RegisterMetrics(netDir, units.Byte, "network speed") }
func (ctx *ReaderContext) registerMetrics(dir *tricorder.DirectorySpec, unit units.Unit, description string) error { err := dir.RegisterMetric("speed", &ctx.maxIOPerSecond, unit, description) if err != nil { return err } return dir.RegisterMetric("limit", &ctx.speedPercent, units.None, "percent limit") }
func (p *ldapconfig) register(dir *tricorder.DirectorySpec) error { if err := dir.RegisterMetric("healthy", &p.healthy, units.None, "Is LDAP reachable and configured?"); err != nil { return err } latencyBucketer := tricorder.NewGeometricBucketer(0.1, 10e3) p.ldapLatencyDistribution = latencyBucketer.NewCumulativeDistribution() if err := dir.RegisterMetric("latency", p.ldapLatencyDistribution, units.Millisecond, "LDAP latency"); err != nil { return err } return nil }
func register(dir *tricorder.DirectorySpec) *prober { p := new(prober) if err := p.findGateway(); err != nil { panic(err) } if err := dir.RegisterMetric("gateway-address", &p.gatewayAddress, units.None, "gateway address"); err != nil { panic(err) } if err := dir.RegisterMetric("gateway-interface", &p.gatewayInterfaceName, units.None, "gateway interface"); err != nil { panic(err) } latencyBucketer := tricorder.NewGeometricBucketer(0.1, 10e3) p.gatewayPingTimeDistribution = latencyBucketer.NewDistribution() if err := dir.RegisterMetric("gateway-ping-time", p.gatewayPingTimeDistribution, units.Millisecond, "ping time to gateway"); err != nil { panic(err) } p.gatewayRttDistribution = latencyBucketer.NewDistribution() if err := dir.RegisterMetric("gateway-rtt", p.gatewayRttDistribution, units.Millisecond, "round-trip time to gateway"); err != nil { panic(err) } return p }
func (configuration *Configuration) registerMetrics( dir *tricorder.DirectorySpec) error { scannerDir, err := dir.RegisterDirectory("scanner") if err != nil { return err } err = configuration.FsScanContext.RegisterMetrics(scannerDir) if err != nil { return err } netDir, err := dir.RegisterDirectory("network") if err != nil { return err } return configuration.NetworkReaderContext.RegisterMetrics(netDir, units.BytePerSecond, "network speed") }
func (p *testprogconfig) register(dir *tricorder.DirectorySpec) error { if err := dir.RegisterMetric("healthy", &p.healthy, units.None, "Healthy?"); err != nil { return err } if err := dir.RegisterMetric("exit-code", &p.exitCode, units.None, "Program exit value"); err != nil { return err } if err := dir.RegisterMetric("exit-error", &p.exitError, units.None, "Probe exited with error"); err != nil { return err } if err := dir.RegisterMetric("stdout", &p.stdout, units.None, "Program's stdout"); err != nil { return err } if err := dir.RegisterMetric("stderr", &p.stderr, units.None, "Program's stderr"); err != nil { return err } return nil }
func (p *pidconfig) register(dir *tricorder.DirectorySpec) error { if err := dir.RegisterMetric("healthy", &p.healthy, units.None, "Is process healthy?"); err != nil { return err } if err := dir.RegisterMetric("pidfile-exists", &p.pidFileExists, units.None, "Does pidfile exist?"); err != nil { return err } if err := dir.RegisterMetric("pid-exists", &p.pidExists, units.None, "Does pid exist?"); err != nil { return err } return nil }
func (p *urlconfig) register(dir *tricorder.DirectorySpec) error { if err := dir.RegisterMetric("healthy", &p.healthy, units.None, "Healthy?"); err != nil { return err } if err := dir.RegisterMetric("status-code", &p.statusCode, units.None, "Status code"); err != nil { return err } if err := dir.RegisterMetric("error", &p.error, units.None, "Error if any"); err != nil { return err } return nil }
func (ctx *ReaderContext) registerMetrics(dir *tricorder.DirectorySpec, unit units.Unit, description string) error { err := dir.RegisterMetric("speed", &ctx.maxIOPerSecond, unit, description) if err != nil { return err } err = dir.RegisterMetric("limit", &ctx.speedPercent, units.None, "percent limit") if err != nil { return err } ctx.sleepTimeDistribution = sleepBucketer.NewCumulativeDistribution() return dir.RegisterMetric("sleep-time", ctx.sleepTimeDistribution, units.Millisecond, "sleep time") }
func register(dir *tricorder.DirectorySpec) *prober { p := new(prober) if err := dir.RegisterMetric("available", &p.available, units.Byte, "estimate of memory available for applications"); err != nil { panic(err) } if err := dir.RegisterMetric("free", &p.free, units.Byte, "free memory"); err != nil { panic(err) } if err := dir.RegisterMetric("total", &p.total, units.Byte, "total memory"); err != nil { panic(err) } return p }
func register(dir *tricorder.DirectorySpec) *prober { p := new(prober) if err := dir.RegisterMetric("1m", &p.oneMinute, units.None, "load average for the last minute"); err != nil { panic(err) } if err := dir.RegisterMetric("5m", &p.fiveMinutes, units.None, "load average for the last minute"); err != nil { panic(err) } if err := dir.RegisterMetric("15m", &p.fifteenMinutes, units.None, "load average for the last minute"); err != nil { panic(err) } return p }
func (p *prober) registerLoadavg(dir *tricorder.DirectorySpec) error { dir = mkdir(dir, "loadavg") if err := dir.RegisterMetric("1m", &p.loadavg.oneMinute, units.None, "load average for the last minute"); err != nil { return err } if err := dir.RegisterMetric("5m", &p.loadavg.fiveMinutes, units.None, "load average for the last minute"); err != nil { return err } if err := dir.RegisterMetric("15m", &p.loadavg.fifteenMinutes, units.None, "load average for the last minute"); err != nil { return err } return nil }
func register(dir *tricorder.DirectorySpec) *prober { p := new(prober) if err := dir.RegisterMetric("hostname", &p.hostname, units.None, "system hostname"); err != nil { panic(err) } version := getVersion() if err := dir.RegisterMetric("version/raw", &version, units.None, "raw kernel version"); err != nil { panic(err) } if err := dir.RegisterMetric("random/entropy-available", &p.randomEntropyAvailable, units.Byte, "entropy available for the random number generator"); err != nil { panic(err) } return p }
func register(dir *tricorder.DirectorySpec) *prober { p := new(prober) p.numCpus = getNumCpus() if p.numCpus > 0 { if err := dir.RegisterMetric("idle-time", &p.idleTime, units.Second, "idle time since last boot"); err != nil { panic(err) } } getNumCpus() if err := dir.RegisterMetric("time", &p.probeTime, units.None, "time of last probe"); err != nil { panic(err) } if err := dir.RegisterMetric("uptime", &p.upTime, units.Second, "time since last boot"); err != nil { panic(err) } return p }
func (s *Store) registerMetrics(d *tricorder.DirectorySpec) (err error) { if err = s.supplier.RegisterMetrics(d); err != nil { return } // Allow this store instance to be GCed maxValuesPerPage := s.supplier.MaxValuesPerPage() metrics := s.metrics if err = d.RegisterMetric( "/pagesPerMetric", metrics.PagesPerMetricDist, units.None, "Number of pages used per metric"); err != nil { return } var primitiveMetrics storePrimitiveMetricsType storeGroup := tricorder.NewGroup() storeGroup.RegisterUpdateFunc(func() time.Time { metrics.Metrics(&primitiveMetrics) return time.Now() }) if err = d.RegisterMetricInGroup( "/pageUtilization", func() float64 { metricValueCount := primitiveMetrics.UniqueMetricValueCount pagesInUseCount := metrics.PagesPerMetricDist.Sum() metricCount := metrics.PagesPerMetricDist.Count() extraValueCount := float64(metricValueCount) - float64(metricCount) return extraValueCount / pagesInUseCount / float64(maxValuesPerPage) }, storeGroup, units.None, "Page utilization 0.0 - 1.0"); err != nil { return } if err = d.RegisterMetricInGroup( "/metricValueCount", &primitiveMetrics.UniqueMetricValueCount, storeGroup, units.None, "Number of unique metrics values"); err != nil { return } if err = d.RegisterMetricInGroup( "/timeSpan", primitiveMetrics.TimeSpan, storeGroup, units.Second, "Span of time in store"); err != nil { return } if err = d.RegisterMetricInGroup( "/valuePageCount", metrics.PagesPerMetricDist.Sum, storeGroup, units.None, "Number of pages used for values."); err != nil { return } if err = d.RegisterMetricInGroup( "/timestampPageCount", &primitiveMetrics.TimeStampPageCount, storeGroup, units.None, "Number of pages used for timestamps."); err != nil { return } if err = d.RegisterMetricInGroup( "/totalPagesInUseCount", func() int64 { return primitiveMetrics.TimeStampPageCount + int64(metrics.PagesPerMetricDist.Sum()) }, storeGroup, units.None, "Total number of pages used."); err != nil { return } return }
func (s *pageQueueType) RegisterMetrics(d *tricorder.DirectorySpec) ( err error) { var queueStats btreepq.PageQueueStats queueGroup := tricorder.NewGroup() queueGroup.RegisterUpdateFunc(func() time.Time { s.PageQueueStats(&queueStats) return time.Now() }) if err = d.RegisterMetricInGroup( "/highPriorityCount", &queueStats.HighPriorityCount, queueGroup, units.None, "Number of pages in high priority queue"); err != nil { return } if err = d.RegisterMetricInGroup( "/lowPriorityCount", &queueStats.LowPriorityCount, queueGroup, units.None, "Number of pages in low priority queue"); err != nil { return } if err = d.RegisterMetricInGroup( "/totalPages", queueStats.TotalCount, queueGroup, units.None, "Total number of pages."); err != nil { return } if err = d.RegisterMetricInGroup( "/nextLowPrioritySeqNo", &queueStats.NextLowPrioritySeqNo, queueGroup, units.None, "Next seq no in low priority queue, 0 if empty"); err != nil { return } if err = d.RegisterMetricInGroup( "/nextHighPrioritySeqNo", &queueStats.NextHighPrioritySeqNo, queueGroup, units.None, "Next seq no in high priority queue, 0 if empty"); err != nil { return } if err = d.RegisterMetricInGroup( "/endSeqNo", &queueStats.EndSeqNo, queueGroup, units.None, "All seq no smaller than this. Marks end of both queues."); err != nil { return } if err = d.RegisterMetricInGroup( "/highPriorityRatio", queueStats.HighPriorityRatio, queueGroup, units.None, "High priority page ratio"); err != nil { return } if err = d.RegisterMetric( "/expanding", s.IsExpanding, units.None, "Is page queue expanding."); err != nil { return } if err = d.RegisterMetric( "/maxValuesPerPage", &s.valueCountPerPage, units.None, "Maximum number ofvalues that can fit in a page."); err != nil { return } if err = d.RegisterMetric( "/inactiveThreshhold", &s.inactiveThreshhold, units.None, "The ratio of inactive pages needed before they are reclaimed first"); err != nil { return } if err = d.RegisterMetric( "/btreeDegree", &s.degree, units.None, "The degree of the btrees in the queue"); err != nil { return } return }
func (m *methodWrapper) registerMetrics(dir *tricorder.DirectorySpec) error { m.failedCallsDistribution = bucketer.NewCumulativeDistribution() err := dir.RegisterMetric("failed-call-durations", m.failedCallsDistribution, units.Millisecond, "duration of failed calls") if err != nil { return err } err = dir.RegisterMetric("num-denied-calls", &m.numDeniedCalls, units.None, "number of denied calls to method") if err != nil { return err } err = dir.RegisterMetric("num-permitted-calls", &m.numPermittedCalls, units.None, "number of permitted calls to method") if err != nil { return err } m.successfulCallsDistribution = bucketer.NewCumulativeDistribution() err = dir.RegisterMetric("successful-call-durations", m.successfulCallsDistribution, units.Millisecond, "duration of successful calls") if err != nil { return err } if m.plain { return nil } m.failedRRCallsDistribution = bucketer.NewCumulativeDistribution() err = dir.RegisterMetric("failed-request-reply-call-durations", m.failedRRCallsDistribution, units.Millisecond, "duration of failed request-reply calls") if err != nil { return err } m.successfulRRCallsDistribution = bucketer.NewCumulativeDistribution() err = dir.RegisterMetric("successful-request-reply-call-durations", m.successfulRRCallsDistribution, units.Millisecond, "duration of successful request-reply calls") if err != nil { return err } return nil }