cpusensor: Add thresold offset
Added DTS critical offset parameter to change critical thresold
value of DTS sensors.
Tested by setting value in entity manager and seeing output
reflect in dbus interface.
Change-Id: Ib819d20322b7eca5f6e8690827bf97d49695e995
Signed-off-by: Vijay Khemka <vijaykhemka@fb.com>
diff --git a/src/CPUSensorMain.cpp b/src/CPUSensorMain.cpp
index 44c5178..2f2319d 100644
--- a/src/CPUSensorMain.cpp
+++ b/src/CPUSensorMain.cpp
@@ -289,6 +289,22 @@
}
}
+ /*
+ * Find if there is DtsCritOffset is configured in config file
+ * set it if configured or else set it to 0
+ */
+ double dtsOffset = 0;
+ if (label == "DTS")
+ {
+ auto findThrOffset =
+ baseConfiguration->second.find("DtsCritOffset");
+ if (findThrOffset != baseConfiguration->second.end())
+ {
+ dtsOffset = std::visit(VariantToDoubleVisitor(),
+ findThrOffset->second);
+ }
+ }
+
std::vector<thresholds::Threshold> sensorThresholds;
std::string labelHead = label.substr(0, label.find(" "));
parseThresholdsFromConfig(*sensorData, sensorThresholds,
@@ -296,7 +312,8 @@
if (sensorThresholds.empty())
{
if (!parseThresholdsFromAttr(sensorThresholds, inputPathStr,
- CPUSensor::sensorScaleFactor))
+ CPUSensor::sensorScaleFactor,
+ dtsOffset))
{
std::cerr << "error populating thresholds for "
<< sensorName << "\n";
@@ -305,7 +322,7 @@
gCpuSensors[sensorName] = std::make_unique<CPUSensor>(
inputPathStr, sensorType, objectServer, dbusConnection, io,
sensorName, std::move(sensorThresholds), *interfacePath, cpuId,
- show);
+ show, dtsOffset);
createdSensors.insert(sensorName);
if (DEBUG)
{