def _update_stats_endpoint(): stats_enabled = subprocess.call('nc -z localhost 8001'.split()) == 0 if stats_enabled: os.system('supervisorctl start register_stats') else: os.system('supervisorctl stop register_stats') service_id = '{}:stats'.format(socket.gethostname()) consul_get('agent/service/deregister/{}'.format(service_id))
def _store_start_timestamp(container_id, container_created_string): # Converting "2014-12-11T09:24:13.852579969Z" to an epoch timestamp docker_timestamp = container_created_string[:-4] epoch_timestamp = str(calendar.timegm(datetime.strptime( docker_timestamp, "%Y-%m-%dT%H:%M:%S.%f").timetuple())) key = "kv/start_timestamp/" + container_id if consul_get(key).status_code == requests.codes.not_found: response = consul_put(key, epoch_timestamp) assert response.status_code == requests.codes.ok
def _store_start_timestamp(container_id, container_created_string): # Converting "2014-12-11T09:24:13.852579969Z" to an epoch timestamp docker_timestamp = container_created_string[:-4] epoch_timestamp = str( calendar.timegm( datetime.strptime(docker_timestamp, "%Y-%m-%dT%H:%M:%S.%f").timetuple())) key = "kv/start_timestamp/" + container_id if consul_get(key).status_code == requests.codes.not_found: response = consul_put(key, epoch_timestamp) assert response.status_code == requests.codes.ok
def _mark_health_status(service_id, health_check_code): endpoint = _get_consul_health_endpoint(health_check_code) assert consul_get('agent/check/{endpoint}/service:{service_id}'.format(**locals())).status_code == requests.codes.ok
def _report_health_status(service_id, health_check_code): endpoint = _get_consul_health_endpoint(health_check_code) response = consul_get( 'agent/check/{endpoint}/service:{service_id}'.format(**locals())) response.raise_for_status()
def _store_start_timestamp(container_id, container_created_timestamp): key = "kv/start_timestamp/" + container_id if consul_get(key).status_code == requests.codes.not_found: response = consul_put(key, str(container_created_timestamp)) assert response.status_code == requests.codes.ok
def _report_health_status(service_id, health_check_code): endpoint = _get_consul_health_endpoint(health_check_code) response = consul_get('agent/check/{endpoint}/service:{service_id}'.format(**locals())) response.raise_for_status()