def logCaptureCallback(filename, lines): linesText = "".join(lines) logger.debug("Your log captured lines:%s" % linesText) index = linesText.find("[STUCK]") # Thread stuck issue happened if index >= 0: snippetIndex = index - 500 snippet = linesText[max(0, snippetIndex):] status = const.CHECK_STATUS_CRITICAL detail_msg = """It seems your application hang on server %s. We found [STUCK] word in log file %s. -------- Your log snippet:%s""" % (app_server, filename, snippet) logger.info(detail_msg) (successful, echo_msg) = api_helper.updateNonnumericalResult(itm_code, status, detail_msg) if successful: logger.info("update status successful.") else: logger.info("fail to update status. echo message: %s" % (echo_msg,))
def logCaptureCallback(filename, lines): linesText = "".join(lines) logger.debug("Your log captured lines:%s" % linesText) index = linesText.find("[STUCK]") # Thread stuck issue happened if index >= 0: snippetIndex = index - 500 snippet = linesText[max(0, snippetIndex):] status = const.CHECK_STATUS_CRITICAL detail_msg = """It seems your application hang on server %s. We found [STUCK] word in log file %s. -------- Your log snippet:%s""" % (app_server, filename, snippet) logger.info(detail_msg) (successful, echo_msg) = api_helper.updateNonnumericalResult( itm_code, status, detail_msg) if successful: logger.info("update status successful.") else: logger.info("fail to update status. echo message: %s" % (echo_msg, ))
notification_msg = "some notification message in your email" return (status, detail_msg, notification_msg) def main(itm_code): try: try: (status, detail_msg, notification_msg) = check() except Exception, e: logger.exception(e) exception_msg = "%s" % e api_helper.registerException(itm_code, exception_msg) else: logger.info("Check status: %s" % status) logger.info("Check detail message: %s" % detail_msg) (successful, echo_msg) = api_helper.updateNonnumericalResult(itm_code, status, detail_msg, notification_msg) if successful: logger.info("update status successful.") else: logger.info("fail to update status. echo message: %s" % (echo_msg,)) except Exception, e: logger.exception(e) if __name__ == "__main__": itm_code = 'UNIT_TEST_NONNUMERICAL' logger.info("=================================") logger.info("===check item: %s" % itm_code) logger.info("=================================")
notification_msg = "some notification message in your email" return (status, detail_msg, notification_msg) def main(itm_code): try: try: (status, detail_msg, notification_msg) = check() except Exception, e: logger.exception(e) exception_msg = "%s" % e api_helper.registerException(itm_code, exception_msg) else: logger.info("Check status: %s" % status) logger.info("Check detail message: %s" % detail_msg) (successful, echo_msg) = api_helper.updateNonnumericalResult( itm_code, status, detail_msg, notification_msg) if successful: logger.info("update status successful.") else: logger.info("fail to update status. echo message: %s" % (echo_msg, )) except Exception, e: logger.exception(e) if __name__ == "__main__": itm_code = 'UNIT_TEST_NONNUMERICAL' logger.info("=================================") logger.info("===check item: %s" % itm_code) logger.info("=================================")