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

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: Add HttpsMonitor 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 elif endpoint.startswith('pubsub://'): 221 elif endpoint.startswith('pubsub://'):
221 if credentials: 222 if credentials:
222 url = urlparse.urlparse(endpoint) 223 url = urlparse.urlparse(endpoint)
223 project = url.netloc 224 project = url.netloc
224 topic = url.path.strip('/') 225 topic = url.path.strip('/')
225 interface.state.global_monitor = monitors.PubSubMonitor( 226 interface.state.global_monitor = monitors.PubSubMonitor(
226 credentials, project, topic, use_instrumented_http=True) 227 credentials, project, topic, use_instrumented_http=True)
227 else: 228 else:
228 logging.error('ts_mon monitoring is disabled because credentials are not ' 229 logging.error('ts_mon monitoring is disabled because credentials are not '
229 'available') 230 'available')
231 elif endpoint.startswith('https://'):
232 interface.state.global_monitor = monitors.HttpsMonitor(endpoint,
233 credentials)
230 elif endpoint.lower() == 'none': 234 elif endpoint.lower() == 'none':
231 logging.info('ts_mon monitoring has been explicitly disabled') 235 logging.info('ts_mon monitoring has been explicitly disabled')
232 else: 236 else:
233 logging.error('ts_mon monitoring is disabled because the endpoint provided' 237 logging.error('ts_mon monitoring is disabled because the endpoint provided'
234 ' is invalid or not supported: %s', endpoint) 238 ' is invalid or not supported: %s', endpoint)
235 239
236 interface.state.flush_mode = args.ts_mon_flush 240 interface.state.flush_mode = args.ts_mon_flush
237 241
238 if args.ts_mon_flush == 'auto': 242 if args.ts_mon_flush == 'auto':
239 interface.state.flush_thread = interface._FlushThread( 243 interface.state.flush_thread = interface._FlushThread(
240 args.ts_mon_flush_interval_secs) 244 args.ts_mon_flush_interval_secs)
241 interface.state.flush_thread.start() 245 interface.state.flush_thread.start()
242 246
243 standard_metrics.init() 247 standard_metrics.init()
OLDNEW
« infra_libs/ts_mon/common/pb_to_popo.py ('K') | « infra_libs/ts_mon/common/test/pb_to_popo_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698