Skip to contentSkip to conversation

openbmc/phosphor-health-monitor issues, please help check.

DISCUSSION Bruce Lee (李昀峻) 2 participants 2 messages Sep 21, 2020 – Sep 23, 2020

lore
Share & tools
lore
#0 lore raw

Hi Vijay,

I found one question in openbmc/phosphor-health-monitor
The service healthMon via above functions created has not the org.freedesktop.DBus.ObjectManager on the root,
and this will cause the sensor not be generated correctly via redfish url /redfish/v1/Chassis/chassis/Sensors/CPU, /redfish/v1/Chassis/chassis/Sensors/Memory Because redfish will method GetSubTree to collect sensors via org.freedesktop.DBus.ObjectManager
I found a solution for your reference and show at bellow, you can use sdbusplus/server/manager.hpp which provide a function to add ObjectManager on the root. Hence, I can get CPU, Memory information correctly via redfish url /redfish/v1/Chassis/chassis/Sensors/CPU, /redfish/v1/Chassis/chassis/Sensors/Memory

#include <sdbusplus/server/manager.hpp>

class HealthMon
{
public:

    HealthMon() = delete;
    HealthMon(const HealthMon&) = delete;
    HealthMon& operator=(const HealthMon&) = delete;
    HealthMon(HealthMon&&) = delete;
    HealthMon& operator=(HealthMon&&) = delete;
    virtual ~HealthMon() = default;

    /** @brief Constructs HealthMon
     *
     * @param[in] bus     - Handle to system dbus
     */
    HealthMon(sdbusplus::bus::bus& bus) : bus(bus)
    {
        // read json file
        sensorConfigs = getHealthConfig();
        createHealthSensors();
        add_manager("/");
    }

    /** @brief Parsing Health config JSON file  */
    Json parseConfigFile(std::string configFile);

    /** @brief reading config for each health sensor component */
    void getConfigData(Json& data, HealthConfig& cfg);

    /** @brief Map of the object HealthSensor */
    std::unordered_map<std::string, std::shared_ptr<HealthSensor>>
        healthSensors;

    /** @brief Create sensors for health monitoring */
    void createHealthSensors();

    void add_manager(const std::string& path)
    {
        managers_.emplace_back(
            std::make_unique<sdbusplus::server::manager::manager>(
                sdbusplus::server::manager::manager(
                bus, path.c_str())));
    }
  private:
    sdbusplus::bus::bus& bus;
    std::vector<HealthConfig> sensorConfigs;
    std::vector<HealthConfig> getHealthConfig();
    std::vector<std::unique_ptr<sdbusplus::server::manager::manager>> managers_;
};

This pic is the add org.freedesktop.DBus.ObjectManager on the root for reference. [cid:[email protected]]

[cid:[email protected]]

Best Regards,
Bruce

#1 lore raw

Hi Bruce,
Let me look into this.

Regards
-Vijay

From: "Bruce Lee (李昀峻)" <[email protected]>
Date: Monday, September 21, 2020 at 2:42 AM
To: "[email protected]" <[email protected]>, Vijay Khemka <[email protected]>
Subject: openbmc/phosphor-health-monitor issues, please help check.

Hi Vijay,

I found one question in openbmc/phosphor-health-monitor
The service healthMon via above functions created has not the org.freedesktop.DBus.ObjectManager on the root,
and this will cause the sensor not be generated correctly via redfish url /redfish/v1/Chassis/chassis/Sensors/CPU, /redfish/v1/Chassis/chassis/Sensors/Memory Because redfish will method GetSubTree to collect sensors via org.freedesktop.DBus.ObjectManager
I found a solution for your reference and show at bellow, you can use sdbusplus/server/manager.hpp which provide a function to add ObjectManager on the root. Hence, I can get CPU, Memory information correctly via redfish url /redfish/v1/Chassis/chassis/Sensors/CPU, /redfish/v1/Chassis/chassis/Sensors/Memory

#include <sdbusplus/server/manager.hpp>

class HealthMon
{
public:

    HealthMon() = delete;
    HealthMon(const HealthMon&) = delete;
    HealthMon& operator=(const HealthMon&) = delete;
    HealthMon(HealthMon&&) = delete;
    HealthMon& operator=(HealthMon&&) = delete;
    virtual ~HealthMon() = default;

    /** @brief Constructs HealthMon
     *
     * @param[in] bus     - Handle to system dbus
     */
    HealthMon(sdbusplus::bus::bus& bus) : bus(bus)
    {
        // read json file
        sensorConfigs = getHealthConfig();
        createHealthSensors();
        add_manager("/");
    }

    /** @brief Parsing Health config JSON file  */
    Json parseConfigFile(std::string configFile);

    /** @brief reading config for each health sensor component */
    void getConfigData(Json& data, HealthConfig& cfg);

    /** @brief Map of the object HealthSensor */
    std::unordered_map<std::string, std::shared_ptr<HealthSensor>>
        healthSensors;

    /** @brief Create sensors for health monitoring */
    void createHealthSensors();

    void add_manager(const std::string& path)
    {
        managers_.emplace_back(
            std::make_unique<sdbusplus::server::manager::manager>(
                sdbusplus::server::manager::manager(
                bus, path.c_str())));
    }
  private:
    sdbusplus::bus::bus& bus;
    std::vector<HealthConfig> sensorConfigs;
    std::vector<HealthConfig> getHealthConfig();
    std::vector<std::unique_ptr<sdbusplus::server::manager::manager>> managers_;
};

This pic is the add org.freedesktop.DBus.ObjectManager on the root for reference. [cid:[email protected]]

[cid:[email protected]]

Best Regards,
Bruce