+def gather_message(json_data):
+ """ Assemble error messages """
+ msg = None
+ try:
+ if 'components' in json_data:
+ components = json_data['components']
+ for component in components:
+ items = components[component]
+ if 'components' in items:
+ for item in items['components']:
+ if 'status' in items['components'][item] and items['components'][item]['status'].upper() == 'DOWN':
+ if msg is not None:
+ msg += "\n{0}: {1}".format(item, items['components'][item]['details']['error'])
+ else:
+ msg = "{0}: {1}".format(item, items['components'][item]['details']['error'])
+ else:
+ if 'status' in items and items['status'].upper() == 'DOWN':
+ if msg is not None:
+ if 'details' in items and 'error' in items['details']:
+ error = items['details']['error']
+ else:
+ error = "No error message"
+ if msg is not None:
+ msg += "\n{0}: {1}".format(component, error)
+ else:
+ msg = "{0}: {1}".format(component, error)
+ else:
+ sys.exit(3)
+ except:
+ sys.exit(3)
+ return msg
+