def do_monitor(): try: exception = sys.exc_info()[1] stack = traceback.format_exc() if exception is not None: # pagerduty pagerduty.raiseEvent("BluemixZoneDemo incident: %s" % exception, "Exception stack:\n%s" % stack) # slack data = {'text': "BluemixZoneDemo incident: %s\nException stack:\n%s" % (exception, stack)} slack.postToSlack(data) except: print(sys.exc_info()[0]) print(traceback.format_exc())
def do_monitor(): try: exception = sys.exc_info()[1] stack = traceback.format_exc() if exception is not None: # pagerduty pagerduty.raiseEvent("BluemixZoneDemo incident: %s" % exception, "Exception stack:\n%s" % stack) # slack data = { 'text': "BluemixZoneDemo incident: %s\nException stack:\n%s" % (exception, stack) } slack.postToSlack(data) except: logger.error(sys.exc_info()[0]) logger.error(traceback.format_exc())
if monitoringTestEnabled is not None and monitoringTestEnabled == "true": try: print " Testing monitoring" raise Exception("Test Exception") except: do_monitor() raise return "Monitoring testing disabled." # ============================================================================= # Start # ============================================================================= from gevent.pywsgi import WSGIServer from geventwebsocket import WebSocketError from geventwebsocket.handler import WebSocketHandler import pagerduty import slack server = WSGIServer((host, port), app, handler_class=WebSocketHandler) print(" * Starting web socket server") # tell slack we are starting data = {'text': "BluemixZoneDemo starting"} slack.postToSlack(data) server.serve_forever()
if monitoringTestEnabled is not None and monitoringTestEnabled == "true": try: self.logger.info("Testing monitoring") raise Exception("Test Exception") except: do_monitor() raise return "Monitoring testing disabled." # ============================================================================= # Start # ============================================================================= from gevent.pywsgi import WSGIServer from geventwebsocket import WebSocketError from geventwebsocket.handler import WebSocketHandler import pagerduty import slack server = WSGIServer((host, port), app, handler_class=WebSocketHandler) logger.info("Starting web socket server") # tell slack we are starting data = {'text': "BluemixZoneDemo starting"} slack.postToSlack(data) server.serve_forever()