Loading src/monitoring/service/MetricsDBTools.py +25 −28 Original line number Diff line number Diff line Loading @@ -264,68 +264,65 @@ class MetricsDB(): for kpi in kpi_list: alarm = False kpi_value = kpi[2] kpiMinIsNone = ((kpiMinValue is None) or math.isnan(kpiMinValue)) kpiMaxIsNone = ((kpiMaxValue is None) or math.isnan(kpiMaxValue)) if (kpiMinValue == kpi_value and kpiMaxValue == kpi_value and inRange): alarm = True elif ( inRange and kpiMinValue is not None and kpiMaxValue is not None and includeMinValue and includeMaxValue): elif (inRange and not kpiMinIsNone and not kpiMaxIsNone and includeMinValue and includeMaxValue): if (kpi_value >= kpiMinValue and kpi_value <= kpiMaxValue): alarm = True elif ( inRange and kpiMinValue is not None and kpiMaxValue is not None and includeMinValue and not includeMaxValue): elif (inRange and not kpiMinIsNone and not kpiMaxIsNone and includeMinValue and not includeMaxValue): if (kpi_value >= kpiMinValue and kpi_value < kpiMaxValue): alarm = True elif ( inRange and kpiMinValue is not None and kpiMaxValue is not None and not includeMinValue and includeMaxValue): elif (inRange and not kpiMinIsNone and not kpiMaxIsNone and not includeMinValue and includeMaxValue): if (kpi_value > kpiMinValue and kpi_value <= kpiMaxValue): alarm = True elif ( inRange and kpiMinValue is not None and kpiMaxValue is not None and not includeMinValue and not includeMaxValue): elif (inRange and not kpiMinIsNone and not kpiMaxIsNone and not includeMinValue and not includeMaxValue): if (kpi_value > kpiMinValue and kpi_value < kpiMaxValue): alarm = True elif ( not inRange and kpiMinValue is not None and kpiMaxValue is not None and includeMinValue and includeMaxValue): elif (not inRange and not kpiMinIsNone and not kpiMaxIsNone and includeMinValue and includeMaxValue): if (kpi_value <= kpiMinValue or kpi_value >= kpiMaxValue): alarm = True elif ( not inRange and kpiMinValue is not None and kpiMaxValue is not None and includeMinValue and not includeMaxValue): elif (not inRange and not kpiMinIsNone and not kpiMaxIsNone and includeMinValue and not includeMaxValue): if (kpi_value <= kpiMinValue or kpi_value > kpiMaxValue): alarm = True elif ( not inRange and kpiMinValue is not None and kpiMaxValue is not None and not includeMinValue and includeMaxValue): elif (not inRange and not kpiMinIsNone and not kpiMaxIsNone and not includeMinValue and includeMaxValue): if (kpi_value < kpiMinValue or kpi_value >= kpiMaxValue): alarm = True elif ( not inRange and kpiMinValue is not None and kpiMaxValue is not None and not includeMinValue and not includeMaxValue): elif (not inRange and not kpiMinIsNone and not kpiMaxIsNone and not includeMinValue and not includeMaxValue): if (kpi_value < kpiMinValue or kpi_value > kpiMaxValue): alarm = True elif (inRange and kpiMinValue is not None and kpiMaxValue is None and includeMinValue): elif (inRange and not kpiMinIsNone and kpiMaxIsNone and includeMinValue): if (kpi_value >= kpiMinValue): alarm = True elif (inRange and kpiMinValue is not None and kpiMaxValue is None and not includeMinValue): elif (inRange and not kpiMinIsNone and kpiMaxIsNone and not includeMinValue): if (kpi_value > kpiMinValue): alarm = True elif (not inRange and kpiMinValue is not None and kpiMaxValue is None and not includeMinValue): elif (not inRange and not kpiMinIsNone and kpiMaxIsNone and includeMinValue): if (kpi_value <= kpiMinValue): alarm = True elif (not inRange and kpiMinValue is not None and kpiMaxValue is None and not includeMinValue): if (kpi_value <= kpiMinValue): elif (not inRange and not kpiMinIsNone and kpiMaxIsNone and not includeMinValue): if (kpi_value < kpiMinValue): alarm = True elif (inRange and kpiMinValue is None and kpiMaxValue is not None and includeMaxValue): elif (inRange and kpiMinIsNone and not kpiMaxIsNone and includeMaxValue): if (kpi_value <= kpiMaxValue): alarm = True elif (inRange and kpiMinValue is None and kpiMaxValue is not None and not includeMaxValue): elif (inRange and kpiMinIsNone and not kpiMaxIsNone and not includeMaxValue): if (kpi_value < kpiMaxValue): alarm = True elif (not inRange and kpiMinValue is None and kpiMaxValue is not None and not includeMaxValue): elif (not inRange and kpiMinIsNone and not kpiMaxIsNone and includeMaxValue): if (kpi_value >= kpiMaxValue): alarm = True elif (not inRange and kpiMinValue is None and kpiMaxValue is not None and not includeMaxValue): if (kpi_value >= kpiMaxValue): elif (not inRange and kpiMinIsNone and not kpiMaxIsNone and not includeMaxValue): if (kpi_value > kpiMaxValue): alarm = True if alarm: valid_kpi_list.append(kpi) if valid_kpi_list: alarm_queue.put_nowait(valid_kpi_list) LOGGER.debug(f"Alarm of KPI {kpi_id} triggered -> kpi_value:{kpi[2]}, timestamp:{kpi[1]}") else: LOGGER.debug(f"No new alarms triggered for the alarm of KPI {kpi_id}") else: LOGGER.debug(f"No new data for the alarm of KPI {kpi_id}") except (Exception) as e: Loading src/monitoring/service/MonitoringServiceServicerImpl.py +2 −2 Original line number Diff line number Diff line Loading @@ -407,8 +407,8 @@ class MonitoringServiceServicerImpl(MonitoringServiceServicer): alarm_description = request.alarm_description alarm_name = request.name kpi_id = request.kpi_id.kpi_id.uuid kpi_min_value = request.kpi_value_range.kpiMinValue.floatVal kpi_max_value = request.kpi_value_range.kpiMaxValue.floatVal kpi_min_value = float(request.kpi_value_range.kpiMinValue.floatVal) kpi_max_value = float(request.kpi_value_range.kpiMaxValue.floatVal) in_range = request.kpi_value_range.inRange include_min_value = request.kpi_value_range.includeMinValue include_max_value = request.kpi_value_range.includeMaxValue Loading Loading
src/monitoring/service/MetricsDBTools.py +25 −28 Original line number Diff line number Diff line Loading @@ -264,68 +264,65 @@ class MetricsDB(): for kpi in kpi_list: alarm = False kpi_value = kpi[2] kpiMinIsNone = ((kpiMinValue is None) or math.isnan(kpiMinValue)) kpiMaxIsNone = ((kpiMaxValue is None) or math.isnan(kpiMaxValue)) if (kpiMinValue == kpi_value and kpiMaxValue == kpi_value and inRange): alarm = True elif ( inRange and kpiMinValue is not None and kpiMaxValue is not None and includeMinValue and includeMaxValue): elif (inRange and not kpiMinIsNone and not kpiMaxIsNone and includeMinValue and includeMaxValue): if (kpi_value >= kpiMinValue and kpi_value <= kpiMaxValue): alarm = True elif ( inRange and kpiMinValue is not None and kpiMaxValue is not None and includeMinValue and not includeMaxValue): elif (inRange and not kpiMinIsNone and not kpiMaxIsNone and includeMinValue and not includeMaxValue): if (kpi_value >= kpiMinValue and kpi_value < kpiMaxValue): alarm = True elif ( inRange and kpiMinValue is not None and kpiMaxValue is not None and not includeMinValue and includeMaxValue): elif (inRange and not kpiMinIsNone and not kpiMaxIsNone and not includeMinValue and includeMaxValue): if (kpi_value > kpiMinValue and kpi_value <= kpiMaxValue): alarm = True elif ( inRange and kpiMinValue is not None and kpiMaxValue is not None and not includeMinValue and not includeMaxValue): elif (inRange and not kpiMinIsNone and not kpiMaxIsNone and not includeMinValue and not includeMaxValue): if (kpi_value > kpiMinValue and kpi_value < kpiMaxValue): alarm = True elif ( not inRange and kpiMinValue is not None and kpiMaxValue is not None and includeMinValue and includeMaxValue): elif (not inRange and not kpiMinIsNone and not kpiMaxIsNone and includeMinValue and includeMaxValue): if (kpi_value <= kpiMinValue or kpi_value >= kpiMaxValue): alarm = True elif ( not inRange and kpiMinValue is not None and kpiMaxValue is not None and includeMinValue and not includeMaxValue): elif (not inRange and not kpiMinIsNone and not kpiMaxIsNone and includeMinValue and not includeMaxValue): if (kpi_value <= kpiMinValue or kpi_value > kpiMaxValue): alarm = True elif ( not inRange and kpiMinValue is not None and kpiMaxValue is not None and not includeMinValue and includeMaxValue): elif (not inRange and not kpiMinIsNone and not kpiMaxIsNone and not includeMinValue and includeMaxValue): if (kpi_value < kpiMinValue or kpi_value >= kpiMaxValue): alarm = True elif ( not inRange and kpiMinValue is not None and kpiMaxValue is not None and not includeMinValue and not includeMaxValue): elif (not inRange and not kpiMinIsNone and not kpiMaxIsNone and not includeMinValue and not includeMaxValue): if (kpi_value < kpiMinValue or kpi_value > kpiMaxValue): alarm = True elif (inRange and kpiMinValue is not None and kpiMaxValue is None and includeMinValue): elif (inRange and not kpiMinIsNone and kpiMaxIsNone and includeMinValue): if (kpi_value >= kpiMinValue): alarm = True elif (inRange and kpiMinValue is not None and kpiMaxValue is None and not includeMinValue): elif (inRange and not kpiMinIsNone and kpiMaxIsNone and not includeMinValue): if (kpi_value > kpiMinValue): alarm = True elif (not inRange and kpiMinValue is not None and kpiMaxValue is None and not includeMinValue): elif (not inRange and not kpiMinIsNone and kpiMaxIsNone and includeMinValue): if (kpi_value <= kpiMinValue): alarm = True elif (not inRange and kpiMinValue is not None and kpiMaxValue is None and not includeMinValue): if (kpi_value <= kpiMinValue): elif (not inRange and not kpiMinIsNone and kpiMaxIsNone and not includeMinValue): if (kpi_value < kpiMinValue): alarm = True elif (inRange and kpiMinValue is None and kpiMaxValue is not None and includeMaxValue): elif (inRange and kpiMinIsNone and not kpiMaxIsNone and includeMaxValue): if (kpi_value <= kpiMaxValue): alarm = True elif (inRange and kpiMinValue is None and kpiMaxValue is not None and not includeMaxValue): elif (inRange and kpiMinIsNone and not kpiMaxIsNone and not includeMaxValue): if (kpi_value < kpiMaxValue): alarm = True elif (not inRange and kpiMinValue is None and kpiMaxValue is not None and not includeMaxValue): elif (not inRange and kpiMinIsNone and not kpiMaxIsNone and includeMaxValue): if (kpi_value >= kpiMaxValue): alarm = True elif (not inRange and kpiMinValue is None and kpiMaxValue is not None and not includeMaxValue): if (kpi_value >= kpiMaxValue): elif (not inRange and kpiMinIsNone and not kpiMaxIsNone and not includeMaxValue): if (kpi_value > kpiMaxValue): alarm = True if alarm: valid_kpi_list.append(kpi) if valid_kpi_list: alarm_queue.put_nowait(valid_kpi_list) LOGGER.debug(f"Alarm of KPI {kpi_id} triggered -> kpi_value:{kpi[2]}, timestamp:{kpi[1]}") else: LOGGER.debug(f"No new alarms triggered for the alarm of KPI {kpi_id}") else: LOGGER.debug(f"No new data for the alarm of KPI {kpi_id}") except (Exception) as e: Loading
src/monitoring/service/MonitoringServiceServicerImpl.py +2 −2 Original line number Diff line number Diff line Loading @@ -407,8 +407,8 @@ class MonitoringServiceServicerImpl(MonitoringServiceServicer): alarm_description = request.alarm_description alarm_name = request.name kpi_id = request.kpi_id.kpi_id.uuid kpi_min_value = request.kpi_value_range.kpiMinValue.floatVal kpi_max_value = request.kpi_value_range.kpiMaxValue.floatVal kpi_min_value = float(request.kpi_value_range.kpiMinValue.floatVal) kpi_max_value = float(request.kpi_value_range.kpiMaxValue.floatVal) in_range = request.kpi_value_range.inRange include_min_value = request.kpi_value_range.includeMinValue include_max_value = request.kpi_value_range.includeMaxValue Loading