All of lore.kernel.org
 help / color / mirror / Atom feed
* openbmc/phosphor-health-monitor issues, please help check.
@ 2020-09-21  9:42 Bruce Lee (李昀峻)
  2020-09-23  6:12 ` Vijay Khemka
  0 siblings, 1 reply; 2+ messages in thread
From: Bruce Lee (李昀峻) @ 2020-09-21  9:42 UTC (permalink / raw)
  To: openbmc@lists.ozlabs.org, vijaykhemka@fb.com


[-- Attachment #1.1: Type: text/plain, Size: 2512 bytes --]

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:image003.jpg@01D6903E.94B636F0]

[cid:image004.jpg@01D6903E.94B636F0]

Best Regards,
Bruce


[-- Attachment #1.2: Type: text/html, Size: 15639 bytes --]

[-- Attachment #2: image003.jpg --]
[-- Type: image/jpeg, Size: 26229 bytes --]

[-- Attachment #3: image004.jpg --]
[-- Type: image/jpeg, Size: 25741 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: openbmc/phosphor-health-monitor issues, please help check.
  2020-09-21  9:42 openbmc/phosphor-health-monitor issues, please help check Bruce Lee (李昀峻)
@ 2020-09-23  6:12 ` Vijay Khemka
  0 siblings, 0 replies; 2+ messages in thread
From: Vijay Khemka @ 2020-09-23  6:12 UTC (permalink / raw)
  To: Bruce Lee (李昀峻), openbmc@lists.ozlabs.org


[-- Attachment #1.1: Type: text/plain, Size: 2834 bytes --]

Hi Bruce,
Let me look into this.

Regards
-Vijay

From: "Bruce Lee (李昀峻)" <Bruce_Lee@quantatw.com>
Date: Monday, September 21, 2020 at 2:42 AM
To: "openbmc@lists.ozlabs.org" <openbmc@lists.ozlabs.org>, Vijay Khemka <vijaykhemka@fb.com>
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:image001.jpg@01D69135.E3EBE470]

[cid:image002.jpg@01D69135.E3EBE470]

Best Regards,
Bruce


[-- Attachment #1.2: Type: text/html, Size: 15388 bytes --]

[-- Attachment #2: image001.jpg --]
[-- Type: image/jpeg, Size: 26230 bytes --]

[-- Attachment #3: image002.jpg --]
[-- Type: image/jpeg, Size: 25742 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-23  6:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-21  9:42 openbmc/phosphor-health-monitor issues, please help check Bruce Lee (李昀峻)
2020-09-23  6:12 ` Vijay Khemka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.