def getImpact(severity, sessionKey): try: csv_path = getLookupFile('alert_impact', sessionKey) if os.path.exists(csv_path): log.debug("Lookup file %s found. Proceeding..." % csv_path) lookup = CsvLookup(csv_path) query = {"severity_id": str(severity)} log.debug("Querying lookup with filter=%s" % query) matches = lookup.lookup(query, {"impact"}) if len(matches) > 0: log.debug("Matched impact in lookup, returning value=%s" % matches["impact"]) return matches["impact"] else: log.debug( "No matching impact found in lookup, falling back to default_impact=%s" % (config['default_impact'])) else: log.warn( "Lookup file %s not found. Falling back to default_impact=%s" % (csv_path, config['default_impact'])) except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() log.warn( "Unable to get impact. Falling back to default_impact=%s. Error: %s. Line: %s" % (config['default_impact'], exc_type, exc_tb.tb_lineno)) return config['default_impact']
def getPriority(impact, urgency): #/servicesNS/nobody/alert_manager/data/transforms/lookups/alert_priority try: csv_path = getLookupFile('alert_priority') if os.path.exists(csv_path): log.debug("Lookup file %s found. Proceeding..." % csv_path) lookup = CsvLookup(csv_path) query = {"impact": impact, "urgency": urgency} log.debug("Querying lookup with filter=%s" % query) matches = lookup.lookup(query, {"priority"}) if len(matches) > 0: log.debug("Matched priority in lookup, returning value=%s" % matches["priority"]) return matches["priority"] else: log.debug( "No matching priority found in lookup, falling back to default_priority=%s" % (config['default_priority'])) else: log.warn( "Lookup file %s not found. Falling back to default_priority=%s" % (csv_path, config['default_priority'])) except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() log.warn( "Unable to get priority. Falling back to default_priority=%s. Error: %s. Line: %s" % (config['default_priority'], exc_type, exc_tb.tb_lineno)) return config['default_priority']
def getPriority(impact, urgency, default_priority, sessionKey): log.debug("getPriority(): Try to calculate priority for impact=%s urgency=%s" % (impact, urgency)) try: csv_path = getLookupFile("alert_priority", sessionKey) if os.path.exists(csv_path): log.debug("Lookup file %s found. Proceeding..." % csv_path) lookup = CsvLookup(csv_path) query = {"impact": impact, "urgency": urgency} log.debug("Querying lookup with filter=%s" % query) matches = lookup.lookup(query, {"priority"}) if len(matches) > 0: log.debug("Matched priority in lookup, returning value=%s" % matches["priority"]) return matches["priority"] else: log.debug( "No matching priority found in lookup, falling back to default_priority=%s" % (config["default_priority"]) ) else: log.warn( "Lookup file %s not found. Falling back to default_priority=%s" % (csv_path, config["default_priority"]) ) except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() log.warn( "Unable to get priority. Falling back to default_priority=%s. Error: %s. Line: %s" % (default_priority, exc_type, exc_tb.tb_lineno) ) return default_priority
def getPriority(impact, urgency, default_priority, sessionKey): log.debug( "getPriority(): Try to calculate priority for impact=%s urgency=%s" % (impact, urgency)) try: csv_path = getLookupFile('alert_priority', sessionKey) if os.path.exists(csv_path): log.debug("Lookup file %s found. Proceeding..." % csv_path) lookup = CsvLookup(csv_path) query = {"impact": impact, "urgency": urgency} log.debug("Querying lookup with filter=%s" % query) matches = lookup.lookup(query, {"priority"}) if len(matches) > 0: log.debug("Matched priority in lookup, returning value=%s" % matches["priority"]) return matches["priority"] else: log.debug( "No matching priority found in lookup, falling back to default_priority=%s" % (config['default_priority'])) else: log.warn( "Lookup file %s not found. Falling back to default_priority=%s" % (csv_path, config['default_priority'])) except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() log.warn( "Unable to get priority. Falling back to default_priority=%s. Error: %s. Line: %s" % (default_priority, exc_type, exc_tb.tb_lineno)) return default_priority
def getImpact(severity): try: csv_path = getLookupFile('alert_impact') if os.path.exists(csv_path): log.debug("Lookup file %s found. Proceeding..." % csv_path) lookup = CsvLookup(csv_path) query = { "severity_id": str(severity) } log.debug("Querying lookup with filter=%s" % query) matches = lookup.lookup(query, { "impact" }) if len(matches) > 0: log.debug("Matched impact in lookup, returning value=%s" % matches["impact"]) return matches["impact"] else: log.debug("No matching impact found in lookup, falling back to default_impact=%s" % (config['default_impact'])) else: log.warn("Lookup file %s not found. Falling back to default_impact=%s" % (csv_path, config['default_impact'])) except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() log.warn("Unable to get impact. Falling back to default_impact=%s. Error: %s. Line: %s" % (config['default_impact'], exc_type, exc_tb.tb_lineno)) return config['default_impact']
def getPriority(impact, urgency): #/servicesNS/nobody/alert_manager/data/transforms/lookups/alert_priority try: csv_path = getLookupFile('alert_priority') if os.path.exists(csv_path): log.debug("Lookup file %s found. Proceeding..." % csv_path) lookup = CsvLookup(csv_path) query = { "impact": impact, "urgency": urgency } log.debug("Querying lookup with filter=%s" % query) matches = lookup.lookup(query, { "priority" }) if len(matches) > 0: log.debug("Matched priority in lookup, returning value=%s" % matches["priority"]) return matches["priority"] else: log.debug("No matching priority found in lookup, falling back to default_priority=%s" % (config['default_priority'])) else: log.warn("Lookup file %s not found. Falling back to default_priority=%s" % (csv_path, config['default_priority'])) except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() log.warn("Unable to get priority. Falling back to default_priority=%s. Error: %s. Line: %s" % (config['default_priority'], exc_type, exc_tb.tb_lineno)) return config['default_priority']