| OLD | NEW |
| 1 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import logging | 5 import logging |
| 6 import os | 6 import os |
| 7 import socket | 7 import socket |
| 8 import sys | 8 import sys |
| 9 import time | 9 import time |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 'the time that the configuration was parsed') | 21 'the time that the configuration was parsed') |
| 22 puppet_version = ts_mon.StringMetric('puppet/version/puppet', | 22 puppet_version = ts_mon.StringMetric('puppet/version/puppet', |
| 23 description='Version of puppet client installed.') | 23 description='Version of puppet client installed.') |
| 24 events = ts_mon.GaugeMetric('puppet/events', | 24 events = ts_mon.GaugeMetric('puppet/events', |
| 25 description='Number of changes the puppet client made to the system in its ' | 25 description='Number of changes the puppet client made to the system in its ' |
| 26 'last run, by success or failure') | 26 'last run, by success or failure') |
| 27 resources = ts_mon.GaugeMetric('puppet/resources', | 27 resources = ts_mon.GaugeMetric('puppet/resources', |
| 28 description='Number of resources known by the puppet client in its last ' | 28 description='Number of resources known by the puppet client in its last ' |
| 29 'run') | 29 'run') |
| 30 times = ts_mon.FloatMetric('puppet/times', | 30 times = ts_mon.FloatMetric('puppet/times', |
| 31 description='Time taken to perform various parts of the last puppet run') | 31 description='Time taken to perform various parts of the last puppet run', |
| 32 age = ts_mon.FloatMetric('puppet/age', description='Time since last run') | 32 units=ts_mon.MetricsDataUnits.SECONDS) |
| 33 age = ts_mon.FloatMetric('puppet/age', |
| 34 description='Time since last run', |
| 35 units=ts_mon.MetricsDataUnits.SECONDS) |
| 33 | 36 |
| 34 | 37 |
| 35 def _lastrunfile(): # pragma: no cover | 38 def _lastrunfile(): # pragma: no cover |
| 36 if sys.platform == 'win32': | 39 if sys.platform == 'win32': |
| 37 return os.path.join(puppet_metrics_win32.common_appdata_path(), | 40 return os.path.join(puppet_metrics_win32.common_appdata_path(), |
| 38 'PuppetLabs\\puppet\\var\\state\\last_run_summary.yaml') | 41 'PuppetLabs\\puppet\\var\\state\\last_run_summary.yaml') |
| 39 return '/var/lib/puppet_last_run_summary.yaml' | 42 return '/var/lib/puppet_last_run_summary.yaml' |
| 40 | 43 |
| 41 | 44 |
| 42 def get_puppet_summary(time_fn=time.time): | 45 def get_puppet_summary(time_fn=time.time): |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 logging.warning('resources not found in %s', path) | 91 logging.warning('resources not found in %s', path) |
| 89 | 92 |
| 90 try: | 93 try: |
| 91 for key, value in data['time'].iteritems(): | 94 for key, value in data['time'].iteritems(): |
| 92 if key == 'last_run': | 95 if key == 'last_run': |
| 93 age.set(time_fn() - value) | 96 age.set(time_fn() - value) |
| 94 elif key != 'total': | 97 elif key != 'total': |
| 95 times.set(value, {'step': key}) | 98 times.set(value, {'step': key}) |
| 96 except KeyError: | 99 except KeyError: |
| 97 logging.warning('time not found in %s', path) | 100 logging.warning('time not found in %s', path) |
| OLD | NEW |