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 Float(name, reset_after=False): """Returns a metric handle for a float named |name|.""" return ts_mon.FloatMetric(name)
"""Send system monitoring data to the timeseries monitoring API.""" import argparse import os import random import sys import time import psutil from infra.libs.service_utils import outer_loop from infra.services.sysmon import root_setup from infra_libs import logs from infra_libs import ts_mon cpu_time = ts_mon.FloatMetric('dev/cpu/time') disk_free = ts_mon.GaugeMetric('dev/disk/free') disk_total = ts_mon.GaugeMetric('dev/disk/total') # inode counts are only available on Unix. if os.name == 'posix': inodes_free = ts_mon.GaugeMetric('dev/inodes/free') inodes_total = ts_mon.GaugeMetric('dev/inodes/total') mem_free = ts_mon.GaugeMetric('dev/mem/free') mem_total = ts_mon.GaugeMetric('dev/mem/total') net_up = ts_mon.GaugeMetric('dev/net/up') net_down = ts_mon.GaugeMetric('dev/net/down')
def Float(name): """Returns a metric handle for a float named |name|.""" return ts_mon.FloatMetric(name)
def FloatMetric(name, reset_after=False, description=None, field_spec=_MISSING): """Returns a metric handle for a float named |name|.""" return ts_mon.FloatMetric(name, description=description, field_spec=field_spec)
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) _LAST_RUN_FILE = '/var/lib/puppet_last_run_summary.yaml' def get_puppet_summary(time_fn=time.time): path = _LAST_RUN_FILE try: with open(path) as fh: data = yaml.safe_load(fh) except IOError:
import errno import os import platform import sys import time import psutil from chromite.lib import cros_logging as logging from infra_libs import ts_mon cpu_count = ts_mon.GaugeMetric('dev/cpu/count', description='Number of CPU cores.') cpu_time = ts_mon.FloatMetric('dev/cpu/time', description='percentage of time spent by the CPU' ' in different states.') disk_free = ts_mon.GaugeMetric( 'dev/disk/free', description='Available bytes on disk partition.', units=ts_mon.MetricsDataUnits.BYTES) disk_total = ts_mon.GaugeMetric('dev/disk/total', description='Total bytes on disk partition.', units=ts_mon.MetricsDataUnits.BYTES) # inode counts are only available on Unix. if os.name == 'posix': # pragma: no cover inodes_free = ts_mon.GaugeMetric( 'dev/inodes/free', description='Number of available inodes on '
import collections import itertools import os import time import buildbot.status.results from buildbot.status.base import StatusReceiverMultiService from twisted.internet import defer, reactor, task, threads from twisted.python import log, threadpool from infra_libs import ts_mon uptime = ts_mon.FloatMetric('buildbot/master/uptime', 'Time (in seconds) since the master was started', [ts_mon.StringField('master')]) accepting_builds = ts_mon.BooleanMetric( 'buildbot/master/accepting_builds', 'Whether the master\'s BuildRequestDistributor is running', [ts_mon.StringField('master')]) connected = ts_mon.GaugeMetric( 'buildbot/master/builders/connected_slaves', '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'),