blob: 90beaaaa4afae0bc097f5b19ba0021fdbd9fb44d [file] [log] [blame]
Jayaprakash Mutyalaed6972a2022-02-01 23:48:09 +00001/*
2// Copyright (c) 2022 Intel 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#include <error_monitors/base_gpio_monitor.hpp>
18#include <host_error_monitor.hpp>
19#include <sdbusplus/asio/object_server.hpp>
20
21namespace host_error_monitor::memhot_monitor
22{
23class MemhotMonitor :
24 public host_error_monitor::base_gpio_monitor::BaseGPIOMonitor
25{
26 const static host_error_monitor::base_gpio_monitor::AssertValue
27 assertValue =
28 host_error_monitor::base_gpio_monitor::AssertValue::lowAssert;
29 size_t cpuNum;
30
31 void logEvent() override
32 {
33 std::string cpuNumber = "CPU " + std::to_string(cpuNum);
34 std::string msg = cpuNumber + " Memhot.";
35 std::string redfishMsgArgs = cpuNumber + " memory";
36
37 sd_journal_send(
38 "MESSAGE=HostError: %s", msg.c_str(), "PRIORITY=%i", LOG_ERR,
39 "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.ComponentOverTemperature",
40 "REDFISH_MESSAGE_ARGS=%s", redfishMsgArgs.c_str(), NULL);
41 }
42
43 public:
Ed Tanousee00ccc2023-03-01 10:37:43 -080044 MemhotMonitor(boost::asio::io_context& io,
Jayaprakash Mutyalaed6972a2022-02-01 23:48:09 +000045 std::shared_ptr<sdbusplus::asio::connection> conn,
46 const std::string& signalName, const size_t cpuNum) :
47 BaseGPIOMonitor(io, conn, signalName, assertValue),
48 cpuNum(cpuNum)
49 {
50 if (valid)
51 {
52 startMonitoring();
53 }
54 }
55};
56} // namespace host_error_monitor::memhot_monitor