def healthcheck_response(api_status): """Content and format health status response.""" health_status = dict([('framingService', api_status)]) API = ManagementApi('http://{0}:15672'.format(broker['host']), broker['user'], broker['pass']) try: result = API.aliveness_test('/') if result['status'] == 'ok': health_status['messageBroker'] = "Running" except Exception: health_status['messageBroker'] = "Not Running" return json.dumps(health_status, indent=1, sort_keys=True)
def healthcheck_response(api_status): """Content and format health status response.""" elastic = ElasticIndex() health_status = dict([('indexService', api_status)]) health_status['elasticsearch'] = ''.join( elastic._healthcheck().get("status")) API = ManagementApi('http://{0}:15672'.format(broker['host']), broker['user'], broker['pass']) try: result = API.aliveness_test('/') if result['status'] == 'ok': health_status['messageBroker'] = "Running" except Exception: health_status['messageBroker'] = "Not Running" return json.dumps(health_status, indent=1, sort_keys=True)
from amqpstorm.management import ApiConnectionError from amqpstorm.management import ApiError from amqpstorm.management import ManagementApi if __name__ == '__main__': API = ManagementApi('http://localhost:15672', 'guest', 'guest') try: result = API.aliveness_test('/') if result['status'] == 'ok': print("RabbitMQ is alive!") else: print("RabbitMQ is not alive! :(") except ApiConnectionError as why: print('Connection Error: %s' % why) except ApiError as why: print('ApiError: %s' % why)
def test_api_aliveness_test(self): api = ManagementApi(HTTP_URL, USERNAME, PASSWORD) self.assertEqual(api.aliveness_test(), {'status': 'ok'})
def test_api_url_with_slash(self): api = ManagementApi(HTTP_URL + '/', USERNAME, PASSWORD) self.assertEqual(api.aliveness_test('/'), {'status': 'ok'})
from amqpstorm.management import ApiConnectionError from amqpstorm.management import ApiError from amqpstorm.management import ManagementApi if __name__ == '__main__': API = ManagementApi('http://127.0.0.1:15672', 'guest', 'guest') try: result = API.aliveness_test('/') if result['status'] == 'ok': print("RabbitMQ is alive!") else: print("RabbitMQ is not alive! :(") except ApiConnectionError as why: print('Connection Error: %s' % why) except ApiError as why: print('ApiError: %s' % why)