Esempio n. 1
0
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)
Esempio n. 2
0
def get_master_state(master_path, master_target):
    """Adds metrics for the builders and their logs within a master directory.

  Args:
    master_path (str): The path of the master's base directory.
    master_target (ts_mon.TaskTarget): The monitoring target to use for metrics
        associated with this master.
  """
    if not os.path.isdir(master_path):
        logging.error('Master path is not a directory: %s', master_path)
        return None

    active_log_size = ts_mon.GaugeMetric('proc/master/active_log_size',
                                         target=master_target)
    for d in os.listdir(master_path):
        path = os.path.join(master_path, d)
        if not os.path.isdir(path):
            continue
        get_builder_state(active_log_size, d, path)
Esempio n. 3
0
def Gauge(name, reset_after=False):
    """Returns a metric handle for a gauge named |name|."""
    return ts_mon.GaugeMetric(name)
Esempio n. 4
0
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')

proc_count = ts_mon.GaugeMetric('dev/proc/count')
Esempio n. 5
0
def Gauge(name):
    """Returns a metric handle for a gauge named |name|."""
    return ts_mon.GaugeMetric(name)
Esempio n. 6
0
def GaugeMetric(name, reset_after=False, description=None, field_spec=_MISSING):
  """Returns a metric handle for a gauge named |name|."""
  return ts_mon.GaugeMetric(name, description=description,
                            field_spec=field_spec)
Esempio n. 7
0
# Copyright (c) 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""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)
Esempio n. 8
0
"""System metrics."""

from __future__ import print_function

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(
Esempio n. 9
0
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'),
     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.',