Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Side by Side Diff: infra_libs/ts_mon/config.py

Issue 2114073002: Add HttpsMonitor (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 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 json 5 import json
6 import logging 6 import logging
7 import os 7 import os
8 import socket 8 import socket
9 import sys 9 import sys
10 import urlparse 10 import urlparse
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 parser.add_argument( 76 parser.add_argument(
77 '--ts-mon-config-file', 77 '--ts-mon-config-file',
78 default=default_config_file, 78 default=default_config_file,
79 help='path to a JSON config file that contains suitable values for ' 79 help='path to a JSON config file that contains suitable values for '
80 '"endpoint" and "credentials" for this machine. This config file is ' 80 '"endpoint" and "credentials" for this machine. This config file is '
81 'intended to be shared by all processes on the machine, as the ' 81 'intended to be shared by all processes on the machine, as the '
82 'values depend on the machine\'s position in the network, IP ' 82 'values depend on the machine\'s position in the network, IP '
83 'whitelisting and deployment of credentials. (default: %(default)s)') 83 'whitelisting and deployment of credentials. (default: %(default)s)')
84 parser.add_argument( 84 parser.add_argument(
85 '--ts-mon-endpoint', 85 '--ts-mon-endpoint',
86 help='url (including file://, pubsub://project/topic) to post monitoring ' 86 help='url (including file://, pubsub://project/topic, https://) to post '
87 'metrics to. If set, overrides the value in --ts-mon-config-file') 87 'monitoring metrics to. If set, overrides the value in '
88 '--ts-mon-config-file')
88 parser.add_argument( 89 parser.add_argument(
89 '--ts-mon-credentials', 90 '--ts-mon-credentials',
90 help='path to a pkcs8 json credential file. If set, overrides the value ' 91 help='path to a pkcs8 json credential file. If set, overrides the value '
91 'in --ts-mon-config-file') 92 'in --ts-mon-config-file')
92 parser.add_argument( 93 parser.add_argument(
93 '--ts-mon-flush', 94 '--ts-mon-flush',
94 choices=('manual', 'auto'), default='auto', 95 choices=('manual', 'auto'), default='auto',
95 help=('metric push behavior: manual (only send when flush() is called), ' 96 help=('metric push behavior: manual (only send when flush() is called), '
96 'or auto (send automatically every --ts-mon-flush-interval-secs ' 97 'or auto (send automatically every --ts-mon-flush-interval-secs '
97 'seconds). (default: %(default)s)')) 98 'seconds). (default: %(default)s)'))
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 elif endpoint.startswith('pubsub://'): 226 elif endpoint.startswith('pubsub://'):
226 if credentials: 227 if credentials:
227 url = urlparse.urlparse(endpoint) 228 url = urlparse.urlparse(endpoint)
228 project = url.netloc 229 project = url.netloc
229 topic = url.path.strip('/') 230 topic = url.path.strip('/')
230 interface.state.global_monitor = monitors.PubSubMonitor( 231 interface.state.global_monitor = monitors.PubSubMonitor(
231 credentials, project, topic, use_instrumented_http=True) 232 credentials, project, topic, use_instrumented_http=True)
232 else: 233 else:
233 logging.error('ts_mon monitoring is disabled because credentials are not ' 234 logging.error('ts_mon monitoring is disabled because credentials are not '
234 'available') 235 'available')
236 elif endpoint.startswith('https://'):
237 interface.state.global_monitor = monitors.HttpsMonitor(endpoint,
238 credentials)
235 elif endpoint.lower() == 'none': 239 elif endpoint.lower() == 'none':
236 logging.info('ts_mon monitoring has been explicitly disabled') 240 logging.info('ts_mon monitoring has been explicitly disabled')
237 else: 241 else:
238 logging.error('ts_mon monitoring is disabled because the endpoint provided' 242 logging.error('ts_mon monitoring is disabled because the endpoint provided'
239 ' is invalid or not supported: %s', endpoint) 243 ' is invalid or not supported: %s', endpoint)
240 244
241 interface.state.flush_mode = args.ts_mon_flush 245 interface.state.flush_mode = args.ts_mon_flush
242 246
243 if args.ts_mon_flush == 'auto': 247 if args.ts_mon_flush == 'auto':
244 interface.state.flush_thread = interface._FlushThread( 248 interface.state.flush_thread = interface._FlushThread(
245 args.ts_mon_flush_interval_secs) 249 args.ts_mon_flush_interval_secs)
246 interface.state.flush_thread.start() 250 interface.state.flush_thread.start()
247 251
248 standard_metrics.init() 252 standard_metrics.init()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698