OLD | NEW |
1 # Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2016 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 json | 5 import json |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import re | 8 import re |
9 import socket | 9 import socket |
10 import time | 10 import time |
(...skipping 22 matching lines...) Expand all Loading... |
33 description='battery temperature in deg C') | 33 description='battery temperature in deg C') |
34 batt_charge = ts_mon.FloatMetric('dev/mobile/battery/charge', | 34 batt_charge = ts_mon.FloatMetric('dev/mobile/battery/charge', |
35 description='percentage charge of battery') | 35 description='percentage charge of battery') |
36 dev_status = ts_mon.StringMetric('dev/mobile/status', | 36 dev_status = ts_mon.StringMetric('dev/mobile/status', |
37 description='operational state of device') | 37 description='operational state of device') |
38 dev_type = ts_mon.StringMetric('dev/mobile/type', | 38 dev_type = ts_mon.StringMetric('dev/mobile/type', |
39 description='device hardware or type') | 39 description='device hardware or type') |
40 dev_os = ts_mon.StringMetric('dev/mobile/os', | 40 dev_os = ts_mon.StringMetric('dev/mobile/os', |
41 description='operating system of the device') | 41 description='operating system of the device') |
42 dev_uptime = ts_mon.FloatMetric('dev/mobile/uptime', | 42 dev_uptime = ts_mon.FloatMetric('dev/mobile/uptime', |
43 description='device uptime in seconds') | 43 description='device uptime in seconds', |
| 44 units=ts_mon.MetricsDataUnits.SECONDS) |
44 mem_free = ts_mon.GaugeMetric( | 45 mem_free = ts_mon.GaugeMetric( |
45 'dev/mobile/mem/free', | 46 'dev/mobile/mem/free', |
46 description='available memory (free + cached + buffers) in kb') | 47 description='available memory (free + cached + buffers) in kb', |
| 48 units=ts_mon.MetricsDataUnits.KIBIBYTES) |
47 mem_total = ts_mon.GaugeMetric( | 49 mem_total = ts_mon.GaugeMetric( |
48 'dev/mobile/mem/total', | 50 'dev/mobile/mem/total', |
49 description='total memory (device ram - kernel leaks) in kb') | 51 description='total memory (device ram - kernel leaks) in kb', |
| 52 units=ts_mon.MetricsDataUnits.KIBIBYTES) |
50 proc_count = ts_mon.GaugeMetric('dev/mobile/proc/count', | 53 proc_count = ts_mon.GaugeMetric('dev/mobile/proc/count', |
51 description='process count') | 54 description='process count') |
52 | 55 |
53 metric_read_status = ts_mon.StringMetric( | 56 metric_read_status = ts_mon.StringMetric( |
54 'dev/android_device_metric_read/status', | 57 'dev/android_device_metric_read/status', |
55 description='status of the last metric read') | 58 description='status of the last metric read') |
56 | 59 |
57 | 60 |
58 def get_device_statuses(device_file=ANDROID_DEVICE_FILE, now=None): | 61 def get_device_statuses(device_file=ANDROID_DEVICE_FILE, now=None): |
59 now = now or time.time() | 62 now = now or time.time() |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 timestamp = json_data.get('timestamp', 0) | 136 timestamp = json_data.get('timestamp', 0) |
134 if now >= timestamp + ANDROID_DEVICE_FILE_STALENESS_S: | 137 if now >= timestamp + ANDROID_DEVICE_FILE_STALENESS_S: |
135 metric_read_status.set('stale_file') | 138 metric_read_status.set('stale_file') |
136 logging.error('Android device file %s is %ss stale (max %ss)', | 139 logging.error('Android device file %s is %ss stale (max %ss)', |
137 device_file, now - timestamp, | 140 device_file, now - timestamp, |
138 ANDROID_DEVICE_FILE_STALENESS_S) | 141 ANDROID_DEVICE_FILE_STALENESS_S) |
139 return [] | 142 return [] |
140 | 143 |
141 metric_read_status.set('good') | 144 metric_read_status.set('good') |
142 return json_data.get('devices', []) | 145 return json_data.get('devices', []) |
OLD | NEW |