Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 1 | /* |
Tomáš Pecka | 43ef7ba | 2023-04-13 15:56:48 +0200 | [diff] [blame] | 2 | * Copyright (C) 2020-2023 CESNET, https://photonics.cesnet.cz/ |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 3 | * |
| 4 | * Written by Tomáš Pecka <tomas.pecka@fit.cvut.cz> |
| 5 | * |
| 6 | */ |
| 7 | |
Tomáš Pecka | 5a4c035 | 2023-12-12 12:29:28 +0100 | [diff] [blame] | 8 | #include <boost/algorithm/string.hpp> |
Tomáš Pecka | 43ef7ba | 2023-04-13 15:56:48 +0200 | [diff] [blame] | 9 | #include <regex> |
| 10 | #include <sysrepo-cpp/Connection.hpp> |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 11 | #include "Sysrepo.h" |
Tomáš Pecka | 2117ce5 | 2023-05-12 11:28:34 +0200 | [diff] [blame] | 12 | #include "utils/alarms.h" |
Jan Kundrát | b98b4f9 | 2024-10-17 17:39:24 +0200 | [diff] [blame] | 13 | #include "utils/benchmark.h" |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 14 | #include "utils/log.h" |
Tomáš Pecka | ba2dc31 | 2021-01-23 22:29:11 +0100 | [diff] [blame] | 15 | #include "utils/sysrepo.h" |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 16 | |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 17 | namespace { |
| 18 | |
Tomáš Pecka | 1b3c173 | 2023-05-12 11:45:01 +0200 | [diff] [blame] | 19 | const auto ALARM_CLEARED = "cleared"; |
Tomáš Pecka | 2117ce5 | 2023-05-12 11:28:34 +0200 | [diff] [blame] | 20 | const auto ALARM_SENSOR_MISSING = "velia-alarms:sensor-missing-alarm"; |
Tomáš Pecka | 1b3c173 | 2023-05-12 11:45:01 +0200 | [diff] [blame] | 21 | const auto ALARM_MISSING_SEVERITY = "warning"; |
| 22 | const auto ALARM_MISSING_DESCRIPTION = "Sensor value not reported. Maybe the sensor was unplugged?"; |
Tomáš Pecka | 2117ce5 | 2023-05-12 11:28:34 +0200 | [diff] [blame] | 23 | const auto ALARM_THRESHOLD_CROSSING_LOW = "velia-alarms:sensor-low-value-alarm"; |
Tomáš Pecka | 6121285 | 2024-09-30 14:36:50 +0200 | [diff] [blame] | 24 | const auto ALARM_THRESHOLD_CROSSING_LOW_DESCRIPTION = "Sensor value crossed low threshold ({} < {})."; |
Tomáš Pecka | 2117ce5 | 2023-05-12 11:28:34 +0200 | [diff] [blame] | 25 | const auto ALARM_THRESHOLD_CROSSING_HIGH = "velia-alarms:sensor-high-value-alarm"; |
Tomáš Pecka | 6121285 | 2024-09-30 14:36:50 +0200 | [diff] [blame] | 26 | const auto ALARM_THRESHOLD_CROSSING_HIGH_DESCRIPTION = "Sensor value crossed high threshold ({} > {})."; |
| 27 | const auto ALARM_THRESHOLD_OK = "Sensor value is within normal parameters."; |
Tomáš Pecka | 5a4c035 | 2023-12-12 12:29:28 +0100 | [diff] [blame] | 28 | const auto ALARM_SENSOR_NONOPERATIONAL = "velia-alarms:sensor-nonoperational"; |
| 29 | const auto ALARM_SENSOR_NONOPERATIONAL_SEVERITY = "warning"; |
| 30 | const auto ALARM_SENSOR_NONOPERATIONAL_DESCRIPTION = "Sensor is nonoperational. The values it reports may not be relevant."; |
Tomáš Pecka | 2117ce5 | 2023-05-12 11:28:34 +0200 | [diff] [blame] | 31 | |
Tomáš Pecka | 43ef7ba | 2023-04-13 15:56:48 +0200 | [diff] [blame] | 32 | /** @brief Extracts component path prefix from an XPath under /ietf-hardware/component node |
| 33 | * |
| 34 | * Example input: /ietf-hardware:hardware/component[name='ne:psu:child']/oper-state/disabled |
| 35 | * Example output: /ietf-hardware:hardware/component[name='ne:psu:child'] |
| 36 | */ |
| 37 | std::string extractComponentPrefix(const std::string& componentXPath) |
| 38 | { |
| 39 | static const std::regex regex(R"((/ietf-hardware:hardware/component\[name=('|").*?(\2)\]).*)"); |
| 40 | std::smatch match; |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 41 | |
Tomáš Pecka | 43ef7ba | 2023-04-13 15:56:48 +0200 | [diff] [blame] | 42 | if (std::regex_match(componentXPath, match, regex)) { |
| 43 | return match.str(1); |
| 44 | } |
| 45 | |
| 46 | throw std::logic_error("Invalid xPath provided ('" + componentXPath + "')"); |
| 47 | } |
Tomáš Pecka | 1b3c173 | 2023-05-12 11:45:01 +0200 | [diff] [blame] | 48 | |
| 49 | void logAlarm(velia::Log logger, const std::string_view sensor, const std::string_view alarm, const std::string_view severity) |
| 50 | { |
| 51 | logger->info("Alarm {}: {} for {}", alarm, severity, sensor); |
| 52 | } |
Tomáš Pecka | 9af4739 | 2023-05-23 14:56:48 +0200 | [diff] [blame] | 53 | |
| 54 | bool isThresholdCrossingLow(velia::ietf_hardware::State state) |
| 55 | { |
| 56 | return state == velia::ietf_hardware::State::WarningLow || state == velia::ietf_hardware::State::CriticalLow; |
| 57 | } |
| 58 | |
| 59 | bool isThresholdCrossingHigh(velia::ietf_hardware::State state) |
| 60 | { |
| 61 | return state == velia::ietf_hardware::State::WarningHigh || state == velia::ietf_hardware::State::CriticalHigh; |
| 62 | } |
| 63 | |
| 64 | std::string toYangAlarmSeverity(velia::ietf_hardware::State state) |
| 65 | { |
| 66 | switch (state) { |
| 67 | case velia::ietf_hardware::State::WarningLow: |
| 68 | case velia::ietf_hardware::State::WarningHigh: |
| 69 | return "warning"; |
| 70 | case velia::ietf_hardware::State::CriticalLow: |
| 71 | case velia::ietf_hardware::State::CriticalHigh: |
| 72 | return "critical"; |
| 73 | default: { |
| 74 | std::ostringstream oss; |
| 75 | oss << "No severity associated with sensor threshold State " << state; |
| 76 | throw std::logic_error(oss.str()); |
| 77 | } |
| 78 | } |
| 79 | } |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 80 | } |
| 81 | |
Tomáš Pecka | 43ef7ba | 2023-04-13 15:56:48 +0200 | [diff] [blame] | 82 | namespace velia::ietf_hardware::sysrepo { |
| 83 | |
| 84 | /** @brief The constructor expects the HardwareState instance which will provide the actual hardware state data and the poll interval */ |
| 85 | Sysrepo::Sysrepo(::sysrepo::Session session, std::shared_ptr<IETFHardware> hwState, std::chrono::microseconds pollInterval) |
| 86 | : m_log(spdlog::get("hardware")) |
| 87 | , m_pollInterval(std::move(pollInterval)) |
| 88 | , m_session(std::move(session)) |
| 89 | , m_hwState(std::move(hwState)) |
| 90 | , m_quit(false) |
Tomáš Pecka | 2117ce5 | 2023-05-12 11:28:34 +0200 | [diff] [blame] | 91 | { |
Tomáš Pecka | 2117ce5 | 2023-05-12 11:28:34 +0200 | [diff] [blame] | 92 | m_pollThread = std::thread([&]() { |
Tomáš Pecka | 43ef7ba | 2023-04-13 15:56:48 +0200 | [diff] [blame] | 93 | auto conn = m_session.getConnection(); |
| 94 | |
| 95 | DataTree prevValues; |
Tomáš Pecka | c0991ce | 2023-12-20 15:46:03 +0100 | [diff] [blame] | 96 | std::set<std::string> seenSensors; |
Tomáš Pecka | 1b3c173 | 2023-05-12 11:45:01 +0200 | [diff] [blame] | 97 | std::map<std::string, State> thresholdsStates; |
Tomáš Pecka | 26b3821 | 2024-01-16 17:23:31 +0100 | [diff] [blame] | 98 | std::set<std::pair<std::string, std::string>> activeSideLoadedAlarms; |
Tomáš Pecka | 11b49b8 | 2024-10-21 14:28:30 +0200 | [diff] [blame] | 99 | std::set<std::pair<std::string, std::string>> seenSideLoadedAlarms; |
Tomáš Pecka | 43ef7ba | 2023-04-13 15:56:48 +0200 | [diff] [blame] | 100 | |
Tomáš Pecka | 9bd6127 | 2024-01-31 15:08:13 +0100 | [diff] [blame] | 101 | alarms::pushInventory( |
| 102 | m_session, |
| 103 | { |
| 104 | {ALARM_THRESHOLD_CROSSING_LOW, "Sensor value is below the low threshold."}, |
| 105 | {ALARM_THRESHOLD_CROSSING_HIGH, "Sensor value is above the high threshold."}, |
| 106 | {ALARM_SENSOR_MISSING, "Sensor is missing."}, |
| 107 | {ALARM_SENSOR_NONOPERATIONAL, "Sensor is flagged as nonoperational."}, |
| 108 | }); |
Tomáš Pecka | 2848fd0 | 2024-01-30 12:05:59 +0100 | [diff] [blame] | 109 | |
Tomáš Pecka | 43ef7ba | 2023-04-13 15:56:48 +0200 | [diff] [blame] | 110 | while (!m_quit) { |
Jan Kundrát | b98b4f9 | 2024-10-17 17:39:24 +0200 | [diff] [blame] | 111 | auto benchmark = std::make_optional<velia::utils::MeasureTime>("ietf-hardware/poll"); |
Tomáš Pecka | 43ef7ba | 2023-04-13 15:56:48 +0200 | [diff] [blame] | 112 | m_log->trace("IetfHardware poll"); |
| 113 | |
Tomáš Pecka | 26b3821 | 2024-01-16 17:23:31 +0100 | [diff] [blame] | 114 | auto [hwStateValues, thresholds, activeSensors, sideLoadedAlarms] = m_hwState->process(); |
Tomáš Pecka | 43ef7ba | 2023-04-13 15:56:48 +0200 | [diff] [blame] | 115 | std::set<std::string> deletedComponents; |
Tomáš Pecka | 8784429 | 2024-01-30 15:20:21 +0100 | [diff] [blame] | 116 | std::vector<std::string> newSensors; |
Tomáš Pecka | 43ef7ba | 2023-04-13 15:56:48 +0200 | [diff] [blame] | 117 | |
Tomáš Pecka | c0991ce | 2023-12-20 15:46:03 +0100 | [diff] [blame] | 118 | for (const auto& sensorXPath : activeSensors) { |
| 119 | if (!seenSensors.contains(sensorXPath)) { |
Tomáš Pecka | 8784429 | 2024-01-30 15:20:21 +0100 | [diff] [blame] | 120 | newSensors.emplace_back(extractComponentPrefix(sensorXPath)); |
Tomáš Pecka | c0991ce | 2023-12-20 15:46:03 +0100 | [diff] [blame] | 121 | } |
| 122 | } |
| 123 | seenSensors.merge(activeSensors); |
| 124 | |
Tomáš Pecka | 8784429 | 2024-01-30 15:20:21 +0100 | [diff] [blame] | 125 | if (!newSensors.empty()) { |
Tomáš Pecka | bbfc1c3 | 2024-01-31 13:58:11 +0100 | [diff] [blame] | 126 | alarms::addResourcesToInventory(m_session, { |
| 127 | {ALARM_THRESHOLD_CROSSING_LOW, newSensors}, |
| 128 | {ALARM_THRESHOLD_CROSSING_HIGH, newSensors}, |
| 129 | {ALARM_SENSOR_MISSING, newSensors}, |
| 130 | {ALARM_SENSOR_NONOPERATIONAL, newSensors}, |
| 131 | }); |
Tomáš Pecka | 8784429 | 2024-01-30 15:20:21 +0100 | [diff] [blame] | 132 | } |
| 133 | |
Tomáš Pecka | 43ef7ba | 2023-04-13 15:56:48 +0200 | [diff] [blame] | 134 | /* Some data readers can stop returning data in some cases (e.g. ejected PSU). |
| 135 | * Prune tree components that were removed before updating to avoid having not current data from previous invocations. |
| 136 | */ |
| 137 | for (const auto& [k, v] : prevValues) { |
| 138 | if (!hwStateValues.contains(k)) { |
| 139 | deletedComponents.emplace(extractComponentPrefix(k)); |
| 140 | } |
| 141 | } |
| 142 | |
Jan Kundrát | 498c3f8 | 2023-05-24 19:25:48 +0200 | [diff] [blame] | 143 | std::vector<std::string> discards; |
| 144 | discards.reserve(deletedComponents.size()); |
| 145 | std::copy(deletedComponents.begin(), deletedComponents.end(), std::back_inserter(discards)); |
Tomáš Pecka | 43ef7ba | 2023-04-13 15:56:48 +0200 | [diff] [blame] | 146 | |
Jan Kundrát | 58855c4 | 2024-09-25 19:31:56 +0200 | [diff] [blame] | 147 | m_log->trace("updating HW state ({} entries)", hwStateValues.size()); |
Jan Kundrát | 498c3f8 | 2023-05-24 19:25:48 +0200 | [diff] [blame] | 148 | utils::valuesPush(hwStateValues, {}, discards, m_session, ::sysrepo::Datastore::Operational); |
Tomáš Pecka | 43ef7ba | 2023-04-13 15:56:48 +0200 | [diff] [blame] | 149 | |
Tomáš Pecka | 26b3821 | 2024-01-16 17:23:31 +0100 | [diff] [blame] | 150 | /* Publish sideloaded alarms */ |
| 151 | for (const auto& [alarm, resource, severity, text] : sideLoadedAlarms) { |
Tomáš Pecka | 11b49b8 | 2024-10-21 14:28:30 +0200 | [diff] [blame] | 152 | // Sideloaded alarms' resources are not registered using the code above, let's register those too |
| 153 | if (!seenSideLoadedAlarms.contains({alarm, resource})) { |
| 154 | alarms::addResourcesToInventory(m_session, {{ALARM_SENSOR_MISSING, {resource}}}); |
| 155 | seenSideLoadedAlarms.insert({alarm, resource}); |
| 156 | } |
Tomáš Pecka | 26b3821 | 2024-01-16 17:23:31 +0100 | [diff] [blame] | 157 | |
| 158 | bool isActive = activeSideLoadedAlarms.contains({alarm, resource}); |
Tomáš Pecka | 8f4075b | 2024-10-22 13:54:48 +0200 | [diff] [blame] | 159 | if (isActive && severity == ALARM_CLEARED) { |
| 160 | alarms::push(m_session, alarm, resource, ALARM_CLEARED, text); |
Tomáš Pecka | 26b3821 | 2024-01-16 17:23:31 +0100 | [diff] [blame] | 161 | activeSideLoadedAlarms.erase({alarm, resource}); |
Tomáš Pecka | 8f4075b | 2024-10-22 13:54:48 +0200 | [diff] [blame] | 162 | } else if (!isActive && severity != ALARM_CLEARED) { |
Tomáš Pecka | d694bc5 | 2024-01-30 09:53:06 +0100 | [diff] [blame] | 163 | alarms::push(m_session, alarm, resource, severity, text); |
Tomáš Pecka | 26b3821 | 2024-01-16 17:23:31 +0100 | [diff] [blame] | 164 | activeSideLoadedAlarms.insert({alarm, resource}); |
| 165 | } |
| 166 | } |
| 167 | |
Tomáš Pecka | 5a4c035 | 2023-12-12 12:29:28 +0100 | [diff] [blame] | 168 | /* Look for nonoperational sensors to set alarms */ |
| 169 | for (const auto& [leaf, value] : hwStateValues) { |
| 170 | if (boost::ends_with(leaf, "/sensor-data/oper-status")) { |
| 171 | std::optional<std::string> oldValue; |
| 172 | |
| 173 | if (auto it = prevValues.find(leaf); it != prevValues.end()) { |
| 174 | oldValue = it->second; |
| 175 | } |
| 176 | |
| 177 | if (value == "nonoperational" && oldValue != "nonoperational") { |
Tomáš Pecka | d694bc5 | 2024-01-30 09:53:06 +0100 | [diff] [blame] | 178 | alarms::push(m_session, ALARM_SENSOR_NONOPERATIONAL, extractComponentPrefix(leaf), ALARM_SENSOR_NONOPERATIONAL_SEVERITY, ALARM_SENSOR_NONOPERATIONAL_DESCRIPTION); |
Tomáš Pecka | 5a4c035 | 2023-12-12 12:29:28 +0100 | [diff] [blame] | 179 | } else if (value == "ok" && oldValue && oldValue != "ok" /* don't call clear-alarm if we see this node for the first time, i.e., oldvalue is nullopt */) { |
Tomáš Pecka | d694bc5 | 2024-01-30 09:53:06 +0100 | [diff] [blame] | 180 | alarms::push(m_session, ALARM_SENSOR_NONOPERATIONAL, extractComponentPrefix(leaf), ALARM_CLEARED, ALARM_SENSOR_NONOPERATIONAL_DESCRIPTION); |
Tomáš Pecka | 5a4c035 | 2023-12-12 12:29:28 +0100 | [diff] [blame] | 181 | } |
| 182 | } |
| 183 | } |
| 184 | |
Tomáš Pecka | 6121285 | 2024-09-30 14:36:50 +0200 | [diff] [blame] | 185 | for (const auto& [sensorXPath, updatedThresholdCrossing] : thresholds) { |
| 186 | auto [state, newValue, exceededThresholdValue] = updatedThresholdCrossing; |
| 187 | |
Tomáš Pecka | 1b3c173 | 2023-05-12 11:45:01 +0200 | [diff] [blame] | 188 | // missing prevState can be considered as Normal |
| 189 | const State prevState = [&, sensorXPath = sensorXPath] { |
| 190 | if (auto it = thresholdsStates.find(sensorXPath); it != thresholdsStates.end()) { |
| 191 | return it->second; |
| 192 | } |
| 193 | return State::Normal; |
| 194 | }(); |
| 195 | const auto componentXPath = extractComponentPrefix(sensorXPath); |
| 196 | |
| 197 | if (state == State::NoValue) { |
Jan Kundrát | 2ec3748 | 2024-01-11 21:38:20 +0100 | [diff] [blame] | 198 | logAlarm(m_log, componentXPath, ALARM_SENSOR_MISSING, ALARM_MISSING_SEVERITY); |
Tomáš Pecka | d694bc5 | 2024-01-30 09:53:06 +0100 | [diff] [blame] | 199 | alarms::push(m_session, ALARM_SENSOR_MISSING, componentXPath, ALARM_MISSING_SEVERITY, ALARM_MISSING_DESCRIPTION); |
Tomáš Pecka | 1b3c173 | 2023-05-12 11:45:01 +0200 | [diff] [blame] | 200 | } else if (prevState == State::NoValue) { |
Jan Kundrát | 2ec3748 | 2024-01-11 21:38:20 +0100 | [diff] [blame] | 201 | logAlarm(m_log, componentXPath, ALARM_SENSOR_MISSING, ALARM_CLEARED); |
Tomáš Pecka | 1b3c173 | 2023-05-12 11:45:01 +0200 | [diff] [blame] | 202 | /* The alarm message is same for both setting and clearing the alarm. RFC8632 says that it is |
| 203 | * "The string used to inform operators about the alarm. This MUST contain enough information for an operator to be able to understand the problem and how to resolve it.", |
| 204 | * i.e., from my POV it does not make sense to say something like "cleared" when clearing the alarm as this would not be beneficial for the operator to understand what happened. |
| 205 | */ |
Tomáš Pecka | d694bc5 | 2024-01-30 09:53:06 +0100 | [diff] [blame] | 206 | alarms::push(m_session, ALARM_SENSOR_MISSING, componentXPath, ALARM_CLEARED, ALARM_MISSING_DESCRIPTION); |
Tomáš Pecka | 1b3c173 | 2023-05-12 11:45:01 +0200 | [diff] [blame] | 207 | } |
| 208 | |
Tomáš Pecka | 9af4739 | 2023-05-23 14:56:48 +0200 | [diff] [blame] | 209 | /* |
| 210 | * We set new threshold alarms first. In case the sensor value transitions from high to low (or low to high) we don't want to lose any active alarm on the resource. |
| 211 | * |
| 212 | * In case new state corresponds to threshold crossing (wither lower bound or upper bound) we set the alarm. |
| 213 | * Since we receive only changes to states it should be sufficient to just check if the new state crossed the threshold. |
| 214 | * We shouldn't receive any "no-op" state change (e.g. warning low to warning low) and even if we did receive such change, we would only set the same alarm again. |
| 215 | * We can however receive a change from critical threshold to warning threshold (or warning to critical) but that is no problem. |
| 216 | * We only need to set the same alarm again with the new severity. |
| 217 | */ |
| 218 | if (isThresholdCrossingLow(state)) { |
| 219 | logAlarm(m_log, componentXPath, ALARM_THRESHOLD_CROSSING_LOW, toYangAlarmSeverity(state)); |
Tomáš Pecka | 6121285 | 2024-09-30 14:36:50 +0200 | [diff] [blame] | 220 | alarms::push(m_session, ALARM_THRESHOLD_CROSSING_LOW, componentXPath, toYangAlarmSeverity(state), |
| 221 | fmt::format(fmt::runtime(ALARM_THRESHOLD_CROSSING_LOW_DESCRIPTION), *newValue, *exceededThresholdValue)); |
Tomáš Pecka | 9af4739 | 2023-05-23 14:56:48 +0200 | [diff] [blame] | 222 | } else if (isThresholdCrossingHigh(state)) { |
| 223 | logAlarm(m_log, componentXPath, ALARM_THRESHOLD_CROSSING_HIGH, toYangAlarmSeverity(state)); |
Tomáš Pecka | 6121285 | 2024-09-30 14:36:50 +0200 | [diff] [blame] | 224 | alarms::push(m_session, ALARM_THRESHOLD_CROSSING_HIGH, componentXPath, toYangAlarmSeverity(state), |
| 225 | fmt::format(fmt::runtime(ALARM_THRESHOLD_CROSSING_HIGH_DESCRIPTION), *newValue, *exceededThresholdValue)); |
Tomáš Pecka | 9af4739 | 2023-05-23 14:56:48 +0200 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | /* Now we can clear the old threshold alarms that are no longer active, i.e., we transition away from the CriticalLow/WarningLow or CriticalHigh/WarningHigh. */ |
| 229 | if (!isThresholdCrossingLow(state) && isThresholdCrossingLow(prevState)) { |
| 230 | logAlarm(m_log, componentXPath, ALARM_THRESHOLD_CROSSING_LOW, ALARM_CLEARED); |
Tomáš Pecka | 6121285 | 2024-09-30 14:36:50 +0200 | [diff] [blame] | 231 | alarms::push(m_session, ALARM_THRESHOLD_CROSSING_LOW, componentXPath, ALARM_CLEARED, ALARM_THRESHOLD_OK); |
Tomáš Pecka | 9af4739 | 2023-05-23 14:56:48 +0200 | [diff] [blame] | 232 | } else if (!isThresholdCrossingHigh(state) && isThresholdCrossingHigh(prevState)) { |
| 233 | logAlarm(m_log, componentXPath, ALARM_THRESHOLD_CROSSING_HIGH, ALARM_CLEARED); |
Tomáš Pecka | 6121285 | 2024-09-30 14:36:50 +0200 | [diff] [blame] | 234 | alarms::push(m_session, ALARM_THRESHOLD_CROSSING_HIGH, componentXPath, ALARM_CLEARED, ALARM_THRESHOLD_OK); |
Tomáš Pecka | 9af4739 | 2023-05-23 14:56:48 +0200 | [diff] [blame] | 235 | } |
| 236 | |
Tomáš Pecka | 1b3c173 | 2023-05-12 11:45:01 +0200 | [diff] [blame] | 237 | thresholdsStates[sensorXPath] = state; |
| 238 | } |
| 239 | |
Tomáš Pecka | 43ef7ba | 2023-04-13 15:56:48 +0200 | [diff] [blame] | 240 | prevValues = std::move(hwStateValues); |
Jan Kundrát | b98b4f9 | 2024-10-17 17:39:24 +0200 | [diff] [blame] | 241 | benchmark.reset(); |
Tomáš Pecka | 43ef7ba | 2023-04-13 15:56:48 +0200 | [diff] [blame] | 242 | std::this_thread::sleep_for(m_pollInterval); |
Tomáš Pecka | bbfc1c3 | 2024-01-31 13:58:11 +0100 | [diff] [blame] | 243 | } |
Tomáš Pecka | 2117ce5 | 2023-05-12 11:28:34 +0200 | [diff] [blame] | 244 | }); |
Tomáš Pecka | 43ef7ba | 2023-04-13 15:56:48 +0200 | [diff] [blame] | 245 | } |
Václav Kubernát | 7efd6d5 | 2021-11-09 01:31:11 +0100 | [diff] [blame] | 246 | |
Tomáš Pecka | 43ef7ba | 2023-04-13 15:56:48 +0200 | [diff] [blame] | 247 | Sysrepo::~Sysrepo() |
| 248 | { |
| 249 | m_log->trace("Requesting poll thread stop"); |
| 250 | m_quit = true; |
| 251 | m_pollThread.join(); |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 252 | } |
| 253 | } |