Matt Spinler | 403d1f5 | 2021-02-01 15:35:25 -0600 | [diff] [blame^] | 1 | /** |
| 2 | * Copyright © 2021 IBM Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #pragma once |
| 17 | |
| 18 | #include <sdbusplus/bus.hpp> |
| 19 | #include <sdbusplus/bus/match.hpp> |
| 20 | #include <sdeventplus/event.hpp> |
| 21 | |
| 22 | namespace sensor::monitor |
| 23 | { |
| 24 | |
| 25 | /** |
| 26 | * @class ThresholdAlarmLogger |
| 27 | * |
| 28 | * This class watches the threshold interfaces |
| 29 | * openbmc_project.Sensor.Threshold.Warning |
| 30 | * openbmc_project.Sensor.Threshold.Critical |
| 31 | * openbmc_project.Sensor.Threshold.PerformanceLoss |
| 32 | * |
| 33 | * and creates event logs when their high and low alarm |
| 34 | * properties set and clear. The error names of the |
| 35 | * event logs are based on the sensor type and look like: |
| 36 | * |
| 37 | * xyz.openbmc_project.Sensor.Threshold.Error.TemperatureWarningHigh |
| 38 | * xyz.openbmc_project.Sensor.Threshold.Error.TemperatureWarningHighClear |
| 39 | */ |
| 40 | class ThresholdAlarmLogger |
| 41 | { |
| 42 | public: |
| 43 | ThresholdAlarmLogger() = delete; |
| 44 | ~ThresholdAlarmLogger() = default; |
| 45 | ThresholdAlarmLogger(const ThresholdAlarmLogger&) = default; |
| 46 | ThresholdAlarmLogger& operator=(const ThresholdAlarmLogger&) = default; |
| 47 | ThresholdAlarmLogger(ThresholdAlarmLogger&&) = default; |
| 48 | ThresholdAlarmLogger& operator=(ThresholdAlarmLogger&&) = default; |
| 49 | |
| 50 | /** |
| 51 | * @brief Constructor |
| 52 | * |
| 53 | * Looks for existing active threshold alarms. |
| 54 | * |
| 55 | * @param[in] bus - The sdbusplus bus object |
| 56 | * @param[in] event - The sdeventplus event object |
| 57 | */ |
| 58 | ThresholdAlarmLogger(sdbusplus::bus::bus& bus, sdeventplus::Event& event); |
| 59 | |
| 60 | private: |
| 61 | /** |
| 62 | * @brief The propertiesChanged handler for all of the thresholds |
| 63 | * interfaces. |
| 64 | * |
| 65 | * Creates event logs for high/low alarm sets and clears. |
| 66 | * |
| 67 | * @param[in] msg - The signal message payload. |
| 68 | */ |
| 69 | void propertiesChanged(sdbusplus::message::message& msg); |
| 70 | |
| 71 | /** |
| 72 | * @brief The sdbusplus bus object |
| 73 | */ |
| 74 | sdbusplus::bus::bus& bus; |
| 75 | |
| 76 | /** |
| 77 | * @brief The sdeventplus Event object |
| 78 | */ |
| 79 | sdeventplus::Event& event; |
| 80 | |
| 81 | /** |
| 82 | * @brief The Warning interface match object |
| 83 | */ |
| 84 | sdbusplus::bus::match::match warningMatch; |
| 85 | |
| 86 | /** |
| 87 | * @brief The Critical interface match object |
| 88 | */ |
| 89 | sdbusplus::bus::match::match criticalMatch; |
| 90 | |
| 91 | /** |
| 92 | * @brief The PerformanceLoss interface match object |
| 93 | */ |
| 94 | sdbusplus::bus::match::match perfLossMatch; |
| 95 | }; |
| 96 | |
| 97 | } // namespace sensor::monitor |