class VarzPoller(Poller): endpoint = '/varz' uptime = ts_mon.FloatMetric('uptime') accepting_builds = ts_mon.BooleanMetric('buildbot/master/accepting_builds') connected = ts_mon.GaugeMetric('buildbot/master/builders/connected_slaves') current_builds = ts_mon.GaugeMetric( 'buildbot/master/builders/current_builds') pending_builds = ts_mon.GaugeMetric( 'buildbot/master/builders/pending_builds') state = ts_mon.StringMetric('buildbot/master/builders/state') total = ts_mon.GaugeMetric('buildbot/master/builders/total_slaves') def handle_response(self, data): self.uptime.set(data['server_uptime'], fields=self.fields()) self.accepting_builds.set(data['accepting_builds'], self.fields()) for builder_name, builder_info in data['builders'].iteritems(): fields = self.fields({'builder': builder_name}) self.connected.set(builder_info.get('connected_slaves', 0), fields=fields) self.current_builds.set(builder_info.get('current_builds', 0), fields=fields) self.pending_builds.set(builder_info.get('pending_builds', 0), fields=fields) self.state.set(builder_info.get('state', 'unknown'), fields=fields) self.total.set(builder_info.get('total_slaves', 0), fields=fields)
def String(name, reset_after=False): """Returns a metric handle for a string named |name|.""" return ts_mon.StringMetric(name)
def String(name): """Returns a metric handle for a string named |name|.""" return ts_mon.StringMetric(name)
def StringMetric(name, reset_after=False, description=None, field_spec=_MISSING): """Returns a metric handle for a string named |name|.""" return ts_mon.StringMetric(name, description=description, field_spec=field_spec)
"""Puppet metrics""" from __future__ import print_function import time import yaml from infra_libs import ts_mon from chromite.lib import cros_logging as logging config_version = ts_mon.GaugeMetric( 'puppet/version/config', description='The version of the puppet configuration.' ' By default this is the time that the configuration was parsed') puppet_version = ts_mon.StringMetric( 'puppet/version/puppet', description='Version of puppet client installed.') events = ts_mon.GaugeMetric( 'puppet/events', description='Number of changes the puppet client made to the system in its' ' last run, by success or failure') resources = ts_mon.GaugeMetric( 'puppet/resources', description='Number of resources known by the puppet client in its last' ' run') times = ts_mon.FloatMetric( 'puppet/times', description='Time taken to perform various parts of the last puppet run', units=ts_mon.MetricsDataUnits.SECONDS) age = ts_mon.FloatMetric('puppet/age', description='Time since last run', units=ts_mon.MetricsDataUnits.SECONDS)
load_average = ts_mon.FloatMetric('dev/proc/load_average', description='Number of processes currently ' 'in the system run queue.') # tsmon pipeline uses backend clocks when assigning timestamps to metric points. # By comparing point timestamp to the point value (i.e. time by machine's local # clock), we can potentially detect some anomalies (clock drift, unusually high # metrics pipeline delay, completely wrong clocks, etc). # # It is important to gather this metric right before the flush. unix_time = ts_mon.GaugeMetric( 'dev/unix_time', description='Number of milliseconds since epoch ' 'based on local machine clock.') os_name = ts_mon.StringMetric('proc/os/name', description='OS name on the machine ') os_version = ts_mon.StringMetric('proc/os/version', description='OS version on the machine ') os_arch = ts_mon.StringMetric('proc/os/arch', description='OS architecture on this machine') python_arch = ts_mon.StringMetric('proc/python/arch', description='python userland ' 'architecture on this machine') def get_uptime(): uptime.set(int(time.time() - START_TIME))
'Number of slaves currently connected, per builder', [ts_mon.StringField('master'), ts_mon.StringField('builder')]) current_builds = ts_mon.GaugeMetric( 'buildbot/master/builders/current_builds', 'Number of builds currently running, per builder', [ts_mon.StringField('master'), ts_mon.StringField('builder')]) pending_builds = ts_mon.GaugeMetric( 'buildbot/master/builders/pending_builds', 'Number of builds pending, per builder', [ts_mon.StringField('master'), ts_mon.StringField('builder')]) last_build_status = ts_mon.StringMetric( 'buildbot/master/builders/last_result', 'The build result of the last completed build.', [ts_mon.StringField('master'), ts_mon.StringField('builder')]) consecutive_failures = ts_mon.GaugeMetric( 'buildbot/master/builders/consecutive_failures', 'The number of consecutive failures until now.', [ ts_mon.StringField('master'), ts_mon.StringField('builder'), ts_mon.StringField('failure_type') ]) state = ts_mon.StringMetric( 'buildbot/master/builders/state', 'State of this builder - building, idle, or offline', [ts_mon.StringField('master'), ts_mon.StringField('builder')]) total = ts_mon.GaugeMetric(