Support retrieving 'utilization' from ME
ME exposes sensors which express host CPU utilization in range 0-255.
This change introduces following things:
- 'MESensor' sensor type introduced alongside legacy 'METemp' for clarity
- ability to expose 'utilization' sensor with range 0-100 (percent)
- scaling utilization value from 0-255 to 0-100
Testing:
- added following configuration on platform:
{
"Address": 190,
"Class": "MESensor",
"Name": "Host CPU Core Utilization",
"SensorType": "utilization",
"ScaleValue": 0.392,
"Type": "IpmbSensor"
}
- configuration properly loaded
- sensors appear on D-Bus and Redfish:
{
"@odata.id": "/redfish/v1/Chassis/WC_Baseboard/Sensors/Host_CPU_Core_Utilization",
"@odata.type": "#Sensor.v1_0_0.Sensor",
"Id": "Host_CPU_Core_Utilization",
"Name": "Host CPU Core Utilization",
"Reading": 98.784,
"ReadingRangeMax": 100.0,
"ReadingRangeMin": 0.0,
"ReadingUnits": "Percent",
"Status": {
"Health": "OK",
"State": "Enabled"
}
}
Change-Id: I49a14820e1b72f9776bd24ba1584d81ee0c95cd5
Signed-off-by: Adrian Ambrożewicz <adrian.ambrozewicz@linux.intel.com>
diff --git a/include/IpmbSensor.hpp b/include/IpmbSensor.hpp
index c5548fa..564a070 100644
--- a/include/IpmbSensor.hpp
+++ b/include/IpmbSensor.hpp
@@ -25,7 +25,8 @@
temp,
curr,
power,
- volt
+ volt,
+ util
};
struct IpmbSensor : public Sensor
diff --git a/src/IpmbSensor.cpp b/src/IpmbSensor.cpp
index 87ad632..6354e2c 100644
--- a/src/IpmbSensor.cpp
+++ b/src/IpmbSensor.cpp
@@ -103,8 +103,8 @@
void IpmbSensor::init(void)
{
- setInitialProperties(dbusConnection);
loadDefaults();
+ setInitialProperties(dbusConnection);
if (initCommand)
{
runInitCmd();
@@ -204,6 +204,13 @@
{
throw std::runtime_error("Invalid sensor type");
}
+
+ if (subType == IpmbSubType::util)
+ {
+ // Utilization need to be scaled to percent
+ maxValue = 100;
+ minValue = 0;
+ }
}
void IpmbSensor::checkThresholds(void)
@@ -320,6 +327,7 @@
break;
case IpmbSubType::power:
case IpmbSubType::volt:
+ case IpmbSubType::util:
value = data[0];
break;
}
@@ -451,7 +459,8 @@
{
sensor->type = IpmbType::mpsVR;
}
- else if (sensorClass == "METemp")
+ else if (sensorClass == "METemp" ||
+ sensorClass == "MESensor")
{
sensor->type = IpmbType::meSensor;
}
@@ -473,6 +482,10 @@
{
sensor->subType = IpmbSubType::curr;
}
+ else if (sensorTypeName == "utilization")
+ {
+ sensor->subType = IpmbSubType::util;
+ }
else
{
sensor->subType = IpmbSubType::temp;