|
@@ -945,7 +945,7 @@ void ResourceWatcherFSM::AfterInit()
|
|
|
GetEntityBase()->GetFunction()->PostThreadPoolTask(new UploadMonitorInfoTask(this));
|
|
|
}
|
|
|
///**TODO(Gifur@8/10/2023): 联调完成后把它挪到开机时第一次启动时才执行 */
|
|
|
- CatchSystemBasicInfo();
|
|
|
+ AlarmSystemBasicInfo();
|
|
|
}
|
|
|
#else
|
|
|
int ResourceWatcherFSM::NetProbe() {
|
|
@@ -8317,11 +8317,11 @@ int ResourceWatcherFSM::IsWifiConnected()
|
|
|
|
|
|
#endif // _MSC_VER end硬件资源监控相关系统功能 CPU、内存、硬盘、网络wifi
|
|
|
|
|
|
-void ResourceWatcherFSM::CatchSystemBasicInfo()
|
|
|
+ErrorCodeEnum ResourceWatcherFSM::CatchSystemBasicInfo(SystemBasicInfo& info)
|
|
|
{
|
|
|
CSimpleStringA runCfgPath;
|
|
|
ErrorCodeEnum errCode = GetEntityBase()->GetFunction()->GetPath("RunCfg", runCfgPath);
|
|
|
- if (runCfgPath.IsNullOrEmpty()) return;
|
|
|
+ if (runCfgPath.IsNullOrEmpty()) return Error_Null;
|
|
|
CSimpleStringA storeFilePath = runCfgPath + SPLIT_SLASH_STR + "SMBIOSData.txt";
|
|
|
|
|
|
if (!ExistsFileA(storeFilePath)) {
|
|
@@ -8331,28 +8331,25 @@ void ResourceWatcherFSM::CatchSystemBasicInfo()
|
|
|
std::string succStr, errStr;
|
|
|
std::string runStr("dmidecode -t system > ");
|
|
|
runStr += storeFilePath.GetData();
|
|
|
- if (SP::Module::Util::ShellExecute(runStr, succStr, errStr)) {
|
|
|
-
|
|
|
- } else {
|
|
|
+ if (!SP::Module::Util::ShellExecute(runStr, succStr, errStr)) {
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("execute '%s' failed!", runStr.c_str());
|
|
|
+ if (!ExistsFileA(storeFilePath)) {
|
|
|
+ RemoveFileA(storeFilePath);
|
|
|
+ }
|
|
|
+ return Error_Unexpect;
|
|
|
}
|
|
|
|
|
|
- CSimpleStringA strResult("{");
|
|
|
do
|
|
|
{
|
|
|
std::string succStr, errStr;
|
|
|
std::string runStr("awk -F ':' '(NR>=7)&&(NR<=14)&&($0~\"Manufacturer\"){print$2}' ");
|
|
|
runStr += storeFilePath.GetData();
|
|
|
if (SP::Module::Util::ShellExecute(runStr, succStr, errStr)) {
|
|
|
- SP::Utility::ToTrim(succStr);
|
|
|
+ info.strManufacturer = SP::Utility::ToTrim(succStr).c_str();
|
|
|
} else {
|
|
|
succStr = "";
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("fetch 'Manufacturer' failed!");
|
|
|
}
|
|
|
- if (strResult.GetLength() > 1) {
|
|
|
- strResult += ", ";
|
|
|
- }
|
|
|
- strResult += CSimpleStringA::Format("\"Manufacturer\":\"%s\"", succStr.c_str());
|
|
|
} while (false);
|
|
|
|
|
|
do {
|
|
@@ -8360,15 +8357,11 @@ void ResourceWatcherFSM::CatchSystemBasicInfo()
|
|
|
std::string runStr("awk -F ':' '(NR>=7)&&(NR<=14)&&($0~\"Product Name\"){print$2}' ");
|
|
|
runStr += storeFilePath.GetData();
|
|
|
if (SP::Module::Util::ShellExecute(runStr, succStr, errStr)) {
|
|
|
- SP::Utility::ToTrim(succStr);
|
|
|
+ info.strProductName = SP::Utility::ToTrim(succStr).c_str();
|
|
|
} else {
|
|
|
succStr = "";
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("fetch 'Product Name' failed!");
|
|
|
}
|
|
|
- if (strResult.GetLength() > 1) {
|
|
|
- strResult += ", ";
|
|
|
- }
|
|
|
- strResult += CSimpleStringA::Format("\"Product Name\":\"%s\"", succStr.c_str());
|
|
|
} while (false);
|
|
|
|
|
|
do {
|
|
@@ -8376,19 +8369,43 @@ void ResourceWatcherFSM::CatchSystemBasicInfo()
|
|
|
std::string runStr("awk -F ':' '(NR>=7)&&(NR<=14)&&($0~\"Serial Number\"){print$2}' ");
|
|
|
runStr += storeFilePath.GetData();
|
|
|
if (SP::Module::Util::ShellExecute(runStr, succStr, errStr)) {
|
|
|
- SP::Utility::ToTrim(succStr);
|
|
|
+ info.strSerialNumber = SP::Utility::ToTrim(succStr).c_str();
|
|
|
} else {
|
|
|
succStr = "";
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("fetch 'Serial Number' failed!");
|
|
|
}
|
|
|
- if (strResult.GetLength() > 1) {
|
|
|
- strResult += ", ";
|
|
|
- }
|
|
|
- strResult += CSimpleStringA::Format("\"Serial Number\":\"%s\"", succStr.c_str());
|
|
|
} while (false);
|
|
|
|
|
|
- strResult += "}";
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_INFO_DEVICE_SMBIOS_GET, strResult);
|
|
|
+ if (!ExistsFileA(storeFilePath)) {
|
|
|
+ RemoveFileA(storeFilePath);
|
|
|
+ }
|
|
|
+ return Error_Succeed;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void ResourceWatcherFSM::AlarmSystemBasicInfo()
|
|
|
+{
|
|
|
+ SystemBasicInfo info;
|
|
|
+ if (Error_Succeed == CatchSystemBasicInfo(info)) {
|
|
|
+ CSimpleStringA strResult("{");
|
|
|
+ if (!info.strManufacturer.IsNullOrEmpty()) {
|
|
|
+ strResult += CSimpleStringA::Format("\"Manufacturer\":\"%s\"", info.strManufacturer.GetData());
|
|
|
+ }
|
|
|
+ if (!info.strProductName.IsNullOrEmpty()) {
|
|
|
+ if (strResult.GetLength() > 1) {
|
|
|
+ strResult += ", ";
|
|
|
+ }
|
|
|
+ strResult += CSimpleStringA::Format("\"Product Name\":\"%s\"", info.strProductName.GetData());
|
|
|
+ }
|
|
|
+ if (!info.strSerialNumber.IsNullOrEmpty()) {
|
|
|
+ if (strResult.GetLength() > 1) {
|
|
|
+ strResult += ", ";
|
|
|
+ }
|
|
|
+ strResult += CSimpleStringA::Format("\"Serial Number\":\"%s\"", info.strSerialNumber.GetData());
|
|
|
+ }
|
|
|
+ strResult += "}";
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_INFO_DEVICE_SMBIOS_GET, strResult);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
#ifdef RVC_OS_LINUX
|