From 30aee385442d8ec0b691b16b5229692cbf0df0a5 Mon Sep 17 00:00:00 2001
From: wangjue <jue.wang2@luxshare-ict.com>
Date: Thu, 19 Dec 2024 19:31:08 +0800
Subject: [PATCH] Ensure CPU sensor names match those in the IPMI SDR list

Signed-off-by: wangjue <jue.wang2@luxshare-ict.com>
---
 src/IntelCPUSensorMain.cpp | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/src/IntelCPUSensorMain.cpp b/src/IntelCPUSensorMain.cpp
index 7bdd9f9..b6dc544 100644
--- a/src/IntelCPUSensorMain.cpp
+++ b/src/IntelCPUSensorMain.cpp
@@ -106,12 +106,33 @@ void detectCpuAsync(
 std::string createSensorName(const std::string& label, const std::string& item,
                              const int& cpuId)
 {
-    std::string sensorName = label;
-    if (item != "input")
+    std::string sensorName{};
+
+    if (label == "DTS")
+    {
+        sensorName = "CPU" + std::to_string(cpuId) + " Temp";
+    }
+    else if (item == "average" && label == "dimm power")
     {
-        sensorName += " " + item;
+        sensorName = label + " CPU" + std::to_string(cpuId);
+    }
+    else if (label == "cpu power")
+    {
+        if(item == "average")
+            sensorName = "CPU" + std::to_string(cpuId) + " power " + "avg";
+        else
+            sensorName = "CPU" + std::to_string(cpuId) + " power " + item;
     }
-    sensorName += " CPU" + std::to_string(cpuId);
+    else
+    {
+        sensorName = label;
+        if (item != "input")
+        {
+            sensorName += " " + item;
+        }
+        sensorName += " CPU" + std::to_string(cpuId);
+    }
+
     // converting to Upper Camel case whole name
     bool isWordEnd = true;
     std::transform(sensorName.begin(), sensorName.end(), sensorName.begin(),
-- 
2.34.1

