##// END OF EJS Templates
feat(metric): added new metric calculation. Fixes: RCCE-5
ilin.s -
r5268:39887b2a default
parent child Browse files
Show More
@@ -18,6 +18,7 b''
18
18
19 import os
19 import os
20 import sys
20 import sys
21 import time
21 import logging
22 import logging
22
23
23 import click
24 import click
@@ -25,6 +26,7 b' import click'
25 from pyramid.paster import setup_logging
26 from pyramid.paster import setup_logging
26
27
27 from rhodecode.lib.pyramid_utils import bootstrap
28 from rhodecode.lib.pyramid_utils import bootstrap
29 from rhodecode.lib.statsd_client import StatsdClient
28 from .backends import SshWrapper
30 from .backends import SshWrapper
29
31
30 log = logging.getLogger(__name__)
32 log = logging.getLogger(__name__)
@@ -65,8 +67,9 b' def main(ini_path, mode, user, user_id, '
65 'Please make sure this is set and available during execution '
67 'Please make sure this is set and available during execution '
66 'of this script.')
68 'of this script.')
67 connection_info = os.environ.get('SSH_CONNECTION', '')
69 connection_info = os.environ.get('SSH_CONNECTION', '')
68
70 time_start = time.time()
69 with bootstrap(ini_path, env={'RC_CMD_SSH_WRAPPER': '1'}) as env:
71 with bootstrap(ini_path, env={'RC_CMD_SSH_WRAPPER': '1'}) as env:
72 statsd = StatsdClient.statsd
70 try:
73 try:
71 ssh_wrapper = SshWrapper(
74 ssh_wrapper = SshWrapper(
72 command, connection_info, mode,
75 command, connection_info, mode,
@@ -74,6 +77,10 b' def main(ini_path, mode, user, user_id, '
74 except Exception:
77 except Exception:
75 log.exception('Failed to execute SshWrapper')
78 log.exception('Failed to execute SshWrapper')
76 sys.exit(-5)
79 sys.exit(-5)
77
78 return_code = ssh_wrapper.wrap()
80 return_code = ssh_wrapper.wrap()
81 operation_took = time.time() - time_start
82 if statsd:
83 operation_took_ms = round(1000.0 * operation_took)
84 statsd.timing("rhodecode_ssh_wrapper_timing.histogram", operation_took_ms,
85 use_decimals=False)
79 sys.exit(return_code)
86 sys.exit(return_code)
General Comments 0
You need to be logged in to leave comments. Login now