|
@@ -7,7 +7,6 @@
|
|
|
#include <algorithm>
|
|
|
#include "fileutil.h"
|
|
|
#include <ctime>
|
|
|
-#include "CommEntityUtil.hpp"
|
|
|
#include "SpUtility.h"
|
|
|
#include "RestfulFunc.h"
|
|
|
#include <stdio.h>
|
|
@@ -91,6 +90,14 @@ const char* CMB_LINK_FILE_NAME = "招商银行可视柜台.lnk";
|
|
|
#endif
|
|
|
const char* STRATUP_FILENAME_FROM_SCRIPTS = "spexplorerauto.lnk";
|
|
|
|
|
|
+bool cmp(const pair<int, double>& a, const pair<int, double>& b) {
|
|
|
+ return a.second > b.second;
|
|
|
+}
|
|
|
+
|
|
|
+bool cmpPid(const pair<int, CSimpleStringA>& a, const pair<int, CSimpleStringA>& b) {
|
|
|
+ return a.first < b.first;
|
|
|
+}
|
|
|
+
|
|
|
#if defined(RVC_OS_WIN)
|
|
|
//https://blog.csdn.net/aflyeaglenku/article/details/51742820
|
|
|
typedef struct _dmi_header
|
|
@@ -256,9 +263,9 @@ bool ResourceWatcherFSM::GetSysActiveStatus(CSimpleStringA& outInfo)
|
|
|
//首页状态变化时触发的功能
|
|
|
void ResourceWatcherFSM::TriggerAtStatusChanged(bool bMStatus)
|
|
|
{
|
|
|
- if (firstMpage)//首次进入首页
|
|
|
+ if (neverMainPage)//首次进入首页
|
|
|
{
|
|
|
- firstMpage = false;
|
|
|
+ neverMainPage = false;
|
|
|
|
|
|
CSmartPointer<IConfigInfo> spRunConfig;
|
|
|
CSmartPointer<IConfigInfo> spCtSettingConfig;
|
|
@@ -311,9 +318,21 @@ void ResourceWatcherFSM::TriggerAtStatusChanged(bool bMStatus)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void ResourceWatcherFSM::TriggerProccessUpload()
|
|
|
+{
|
|
|
+ CSmartPointer<IConfigInfo> spCtSettingConfig;
|
|
|
+ GetEntityBase()->GetFunction()->OpenConfig(Config_CenterSetting, spCtSettingConfig);
|
|
|
+ int CloseUploadSysProcFlag = 0; //关闭进程信息上送标志
|
|
|
+ spCtSettingConfig->ReadConfigValueInt(m_pEntity->GetEntityName(), "CloseUploadSysProcFlag", CloseUploadSysProcFlag);
|
|
|
+ if (CloseUploadSysProcFlag != 1) {
|
|
|
+ UploadSysProcInfoTask* uploadProcInfo = new UploadSysProcInfoTask(this);
|
|
|
+ GetEntityBase()->GetFunction()->PostThreadPoolTask(uploadProcInfo);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
ErrorCodeEnum ResourceWatcherFSM::OnInit()
|
|
|
{
|
|
|
- firstMpage = true; //是否首次进入首页
|
|
|
+ neverMainPage = true; //是否未进入过首页
|
|
|
|
|
|
ErrorCodeEnum erroCode = Error_Succeed;
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Complied at: %s %s", __DATE__, __TIME__);
|
|
@@ -324,9 +343,8 @@ ErrorCodeEnum ResourceWatcherFSM::OnInit()
|
|
|
erroCode = GetEntityBase()->GetFunction()->GetSystemStaticInfo(m_RvcSysinfo);
|
|
|
m_bFirstRunAfterBoot = DetectIsFirstRunAtBoot();
|
|
|
if (m_bFirstRunAfterBoot) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("First time to run after system boot.");
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("First time to run after system boot.");
|
|
|
}
|
|
|
-
|
|
|
spCtSettingConfig->ReadConfigValueInt(m_pEntity->GetEntityName(), "DisplayCnt", m_iNonSignedDisplay);
|
|
|
if (m_iNonSignedDisplay <= 0)
|
|
|
m_iNonSignedDisplay = 10;
|
|
@@ -341,6 +359,7 @@ ErrorCodeEnum ResourceWatcherFSM::OnInit()
|
|
|
m_skipDesktopDetect = TRUE;
|
|
|
}
|
|
|
spRunConfig->ReadConfigValueInt("WarnRecord", "disk", m_diskLastWarnHour);
|
|
|
+
|
|
|
return Error_Succeed;
|
|
|
}
|
|
|
|
|
@@ -2006,94 +2025,6 @@ void ResourceWatcherFSM::DetectVersionHasChangedAndWarn()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void ResourceWatcherFSM::DetectDestopFileAndWarn(bool bClear, CSimpleStringA& strFileSaveList)
|
|
|
-{
|
|
|
- CSimpleStringA filelist(true);
|
|
|
- int dirCount(0), fileCount(0);
|
|
|
- CSimpleStringA desktopFullPath(true);
|
|
|
- CSimpleStringA desktopPublicPath(true);
|
|
|
- GetUserDesktopDirectory(desktopFullPath);
|
|
|
- GetCommDesktopDirectory(desktopPublicPath);
|
|
|
- if (desktopFullPath.IsNullOrEmpty() || desktopPublicPath.IsNullOrEmpty()) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("get desktop directory path failed: pub:%d,user:%d", desktopPublicPath.GetLength(), desktopFullPath.GetLength());
|
|
|
- }
|
|
|
- else {
|
|
|
- CAutoArray<CSimpleStringA> desktopPaths;
|
|
|
- desktopPaths.Init(2);
|
|
|
- desktopPaths[0] = desktopFullPath;
|
|
|
- desktopPaths[1] = desktopPublicPath;
|
|
|
- for (int k = 0; k < desktopPaths.GetCount(); ++k) {
|
|
|
- CSimpleStringA& curPath = desktopPaths[k];
|
|
|
- auto arr = fileutil_get_sub_files(curPath);
|
|
|
- if (arr != NULL) {
|
|
|
- for (int i = 0; i < arr->nelts; ++i) {
|
|
|
- char* file = ARRAY_IDX(arr, i, char*);
|
|
|
- char* filename = strrchr(file, '\\');
|
|
|
- if (filename != NULL) { filename += 1; }
|
|
|
- else { filename = file; }
|
|
|
- bool toRecord = true;
|
|
|
- if (bClear) {
|
|
|
- std::string strLowFileName = SP::Utility::ToLower(std::string(filename));
|
|
|
- if (strFileSaveList.IsNullOrEmpty() || strFileSaveList.IndexOf(strLowFileName.c_str()) == -1) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("delete desktop file:%s", filename);
|
|
|
- RemoveFileA(file);
|
|
|
- if (!ExistsFileA(file)) {
|
|
|
- toRecord = false;
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("skip to delete: %s", filename);
|
|
|
- }
|
|
|
- }
|
|
|
- if (toRecord) {
|
|
|
- fileCount++;
|
|
|
- if (!filelist.IsNullOrEmpty()) {
|
|
|
- filelist += "|";
|
|
|
- }
|
|
|
- filelist += filename;
|
|
|
- }
|
|
|
- }
|
|
|
- if (arr->nelts > 0) {
|
|
|
- filelist += ";";
|
|
|
- }
|
|
|
- toolkit_array_free2(arr);
|
|
|
- }
|
|
|
-
|
|
|
- arr = fileutil_get_sub_dirs(curPath);
|
|
|
- if (arr != NULL) {
|
|
|
- for (int i = 0; i < arr->nelts; ++i) {
|
|
|
- char* dir = ARRAY_IDX(arr, i, char*);
|
|
|
- char* dirname = strrchr(dir, '\\');
|
|
|
- if (dirname != NULL) { dirname += 1; }
|
|
|
- else { dirname = dir; }
|
|
|
- bool toRecord = true;
|
|
|
- if (bClear) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("remove desktop dir:%s", dirname);
|
|
|
- RemoveDirRecursiveA(dir);
|
|
|
- if (!ExistsDirA(dir)) {
|
|
|
- toRecord = false;
|
|
|
- }
|
|
|
- }
|
|
|
- if (toRecord) {
|
|
|
- dirCount++;
|
|
|
- if (!filelist.IsNullOrEmpty() && i != 0) {
|
|
|
- filelist += "|";
|
|
|
- }
|
|
|
- filelist += dirname;
|
|
|
- }
|
|
|
- }
|
|
|
- if (arr->nelts > 0) {
|
|
|
- filelist += ";";
|
|
|
- }
|
|
|
- toolkit_array_free2(arr);
|
|
|
- }
|
|
|
- }
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_INFO_DESKTOP_FILESTATUS
|
|
|
- , CSimpleStringA::Format("{\"subject\":\"desktop_file\",\"clear_flag\":\"%d\",\"desktop\":\"%s\",\"file_count\":%d,\"dir_count\":%d,\"content\":\"%s\"}"
|
|
|
- , bClear ? 1 : 0, desktopFullPath.GetData(), fileCount, dirCount, filelist.GetLength() < 950 ? filelist.GetData() : (filelist.SubString(0, 950) + "....").GetData()));
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
bool ResourceWatcherFSM::SetDesktopSysIcon2Registry(const std::string& key, bool toDisplay)
|
|
|
{
|
|
|
bool result(true);
|
|
@@ -2225,144 +2156,6 @@ void ResourceWatcherFSM::MakeSureWin8IntoDesktopPageAtLogon()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void ResourceWatcherFSM::DetectAutoStartFileAndWarn()
|
|
|
-{
|
|
|
- std::vector<std::string> userlist;
|
|
|
- std::vector<std::string> publist;
|
|
|
- std::string r1, r2;
|
|
|
- GetAutoStartFile(r1, userlist, r2, publist);
|
|
|
- std::string strUserList = "";
|
|
|
- std::string strPubList = "";
|
|
|
-
|
|
|
- std::string strUserAutoList = "";
|
|
|
- std::string strPubAutoList = "";
|
|
|
- int userAutoCnt = 0, pubAutoCnt = 0;
|
|
|
- int userAutoPureCnt = 0, pubAutoPureCnt = 0;
|
|
|
- int catchLegitCnt = 0;
|
|
|
- std::vector<std::string> autolist;
|
|
|
- autolist.push_back(CMB_LINK_FILE_NAME);
|
|
|
- autolist.push_back(STRATUP_FILENAME_FROM_SCRIPTS);
|
|
|
-
|
|
|
- for (auto it = userlist.cbegin(); it != userlist.cend(); ++it) {
|
|
|
- if (!strUserList.empty()) { strUserList += "|"; }
|
|
|
- strUserList += it->c_str();
|
|
|
-
|
|
|
- for (auto kt = keyUserlist.cbegin(); kt != keyUserlist.cend(); ++kt) {
|
|
|
- if (it->compare(*kt) == 0) {
|
|
|
- if (!strUserAutoList.empty()) { strUserAutoList += "|"; }
|
|
|
- strUserAutoList += it->c_str();
|
|
|
- userAutoCnt++;
|
|
|
- userAutoPureCnt++;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- for (auto kt = autolist.cbegin(); kt != autolist.cend(); ++kt) {
|
|
|
- if (it->compare(*kt) == 0) {
|
|
|
- if (!strUserAutoList.empty()) { strUserAutoList += "|"; }
|
|
|
- strUserAutoList += it->c_str();
|
|
|
- userAutoCnt++;
|
|
|
- catchLegitCnt++;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- for (auto it = publist.cbegin(); it != publist.cend(); ++it) {
|
|
|
- if (!strPubList.empty()) { strPubList += "|"; }
|
|
|
- strPubList += it->c_str();
|
|
|
-
|
|
|
- for (auto kt = keyPublist.cbegin(); kt != keyPublist.cend(); ++kt) {
|
|
|
- if (it->compare(*kt) == 0) {
|
|
|
- if (!strPubAutoList.empty()) { strPubAutoList += "|"; }
|
|
|
- strPubAutoList += it->c_str();
|
|
|
- pubAutoCnt++;
|
|
|
- pubAutoPureCnt++;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- for (auto kt = autolist.cbegin(); kt != autolist.cend(); ++kt) {
|
|
|
- if (it->compare(*kt) == 0) {
|
|
|
- if (!strPubAutoList.empty()) { strPubAutoList += "|"; }
|
|
|
- strPubAutoList += it->c_str();
|
|
|
- pubAutoCnt++;
|
|
|
- catchLegitCnt++;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_INFO_AUTOSTART_FILESTATUS
|
|
|
- , CSimpleStringA::Format("{\"subject\":\"autostart_file\", \"file_count\":%d, \"user\":\"%s\",\"public\":\"%s\"}"
|
|
|
- , userlist.size() + publist.size(), strUserList.c_str(), strPubList.c_str()));
|
|
|
-
|
|
|
- if (pubAutoCnt + userAutoCnt > 1) {
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_INFO_AUTOSTART_INTEREST_FILESTATUS
|
|
|
- , CSimpleStringA::Format("{\"subject\":\"duplicate_vtm_autostart_file\", \"user_count\":%d, \"pub_count\":%d, \"user\":\"%s\",\"public\":\"%s\", \"legal_count\":%d, \"delete_flag\":%d}"
|
|
|
- , userAutoCnt, pubAutoCnt, strUserAutoList.c_str(), strPubAutoList.c_str(), catchLegitCnt, flag4DeleteKeyAutoStartFile));
|
|
|
- }
|
|
|
-
|
|
|
- if (catchLegitCnt > 0 && flag4DeleteKeyAutoStartFile && (pubAutoPureCnt > 0 || userAutoPureCnt > 0)) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("to delete duplicate auto start file.");
|
|
|
- DeleteDuplicateAutoStartFile();
|
|
|
- }
|
|
|
- //////////////////////////////////////////////////////////////////////////
|
|
|
-
|
|
|
- struct fileStruc {
|
|
|
- std::string username;
|
|
|
- std::vector<std::string> filenames;
|
|
|
- //JSONCONVERT2OBJECT_MEMEBER_REGISTER(username, filenames)
|
|
|
- };
|
|
|
-
|
|
|
- struct fileVec
|
|
|
- {
|
|
|
- std::vector<fileStruc> startupfiles;
|
|
|
- //JSONCONVERT2OBJECT_MEMEBER_REGISTER(startupfiles)
|
|
|
- } curStartupFileInfo, keyStartFileInfo;
|
|
|
-
|
|
|
- CSimpleStringA desktopParentPath = "C:\\Users";
|
|
|
- auto arr = fileutil_get_sub_dirs(desktopParentPath);
|
|
|
- if (arr != NULL) {
|
|
|
- for (int i = 0; i < arr->nelts; ++i) {
|
|
|
- char* dir = ARRAY_IDX(arr, i, char*);
|
|
|
- char* dirname = strrchr(dir, '\\');
|
|
|
- if (dirname != NULL) { dirname += 1; }
|
|
|
- else { dirname = dir; }
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("dir name:%s", dirname);
|
|
|
- fileStruc curset;
|
|
|
- fileStruc keyset;
|
|
|
- curset.username = keyset.username = dirname;
|
|
|
- ToListCurrentUserStartupFile(dir, curset.filenames, keyset.filenames);
|
|
|
- curStartupFileInfo.startupfiles.push_back(curset);
|
|
|
- keyStartFileInfo.startupfiles.push_back(keyset);
|
|
|
- }
|
|
|
- toolkit_array_free2(arr);
|
|
|
- }
|
|
|
- std::string curset_str(""), keyset_str("");
|
|
|
- for (auto it = curStartupFileInfo.startupfiles.begin(); it != curStartupFileInfo.startupfiles.end(); ++it) {
|
|
|
- if (!curset_str.empty()) curset_str += ";";
|
|
|
- curset_str += it->username;
|
|
|
- curset_str += ":";
|
|
|
- std::string content("");
|
|
|
- for (auto ik = it->filenames.begin(); ik != it->filenames.end(); ik++) {
|
|
|
- if (!content.empty()) content += "|";
|
|
|
- content += ik->c_str();
|
|
|
- }
|
|
|
- curset_str += content;
|
|
|
- }
|
|
|
-
|
|
|
- for (auto it = keyStartFileInfo.startupfiles.begin(); it != keyStartFileInfo.startupfiles.end(); ++it) {
|
|
|
- if (!keyset_str.empty()) keyset_str += ";";
|
|
|
- keyset_str += it->username;
|
|
|
- keyset_str += ":";
|
|
|
- std::string content("");
|
|
|
- for (auto ik = it->filenames.begin(); ik != it->filenames.end(); ik++) {
|
|
|
- if (!content.empty()) content += "|";
|
|
|
- content += ik->c_str();
|
|
|
- }
|
|
|
- keyset_str += content;
|
|
|
- }
|
|
|
- //LogWarn(Severity_Low, Error_Debug, LOG_RESOURCEWATCHER_DEBUG_STARTUPFILES, curset_str.c_str());
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_RESOURCEWATCHER_DEBUG_KEY_STARTUPFILES, keyset_str.c_str());
|
|
|
-}
|
|
|
-
|
|
|
bool ResourceWatcherFSM::RegRdVtmVersion(CSimpleStringA& VTMpath, CSimpleStringA& vtmVersion, CSimpleStringA& verPath)
|
|
|
{
|
|
|
bool bRet = false;
|
|
@@ -2651,34 +2444,6 @@ void ResourceWatcherFSM::VerifySignature(const CSimpleStringA& filePath)
|
|
|
FindClose(hFind);
|
|
|
}
|
|
|
|
|
|
-void ResourceWatcherFSM::DetectAndClearDesktopFile()
|
|
|
-{
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- CSmartPointer<IConfigInfo> spCtSettingConfig;
|
|
|
- GetEntityBase()->GetFunction()->OpenConfig(Config_CenterSetting, spCtSettingConfig);
|
|
|
-
|
|
|
- int clearDesktopFlag(0);
|
|
|
- CSimpleStringA strFileWhiteSheet(true);
|
|
|
- spCtSettingConfig->ReadConfigValueInt(GetEntityBase()->GetEntityName(), "ClearDesktopSwitch", clearDesktopFlag);
|
|
|
- if (!!clearDesktopFlag) {
|
|
|
- spCtSettingConfig->ReadConfigValue(GetEntityBase()->GetEntityName(), "DesktopWhiteSheet", strFileWhiteSheet);
|
|
|
- if (!strFileWhiteSheet.IsNullOrEmpty()) {
|
|
|
- std::string strLowFileName = SP::Utility::ToLower(std::string(strFileWhiteSheet.GetData()));
|
|
|
- strFileWhiteSheet = strLowFileName.c_str();
|
|
|
- }
|
|
|
- }
|
|
|
- DetectDestopFileAndWarn(!!clearDesktopFlag, strFileWhiteSheet);
|
|
|
- /** 如果白名单中有{SysIcon}则不清理桌面系统图标 [Gifur@2024830]*/
|
|
|
- if (!!clearDesktopFlag && (strFileWhiteSheet.IsNullOrEmpty() || strFileWhiteSheet.IndexOf("{sysicon}") == -1)) {
|
|
|
- SetDesktopSysIcon2Registry("{20D04FE0-3AEA-1069-A2D8-08002B30309D}", false); //此电脑 图标
|
|
|
- SetDesktopSysIcon2Registry("{645FF040-5081-101B-9F08-00AA002F954E}", false); //回收站 图标
|
|
|
- SetDesktopSysIcon2Registry("{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}", false); //网络 图标
|
|
|
- SetDesktopSysIcon2Registry("{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}", false); //控制面板 图标
|
|
|
- SetDesktopSysIcon2Registry("{59031a47-3f72-44a7-89c5-5595fe6b30ee}", false); //用户的文件 图标
|
|
|
- }
|
|
|
-#endif //RVC_OS_WIN
|
|
|
-}
|
|
|
-
|
|
|
CSimpleStringA ResourceWatcherFSM::GetFileName(const CSimpleStringA& filePath)
|
|
|
{
|
|
|
CSimpleStringA tmp = filePath;
|
|
@@ -3340,16 +3105,6 @@ long long CompareFileTime2(const FILETIME& preTime, const FILETIME& nowTime)
|
|
|
return Filetime2Int64(nowTime) - Filetime2Int64(preTime);
|
|
|
}
|
|
|
|
|
|
-unordered_map<int, long long> oldProcessTime;
|
|
|
-unordered_map<int, long long> newProcessTime;
|
|
|
-unordered_map<int, CSimpleStringA> processName;
|
|
|
-unordered_map<int, double> processCpu;
|
|
|
-string sysProcName = "[System Process]|System|Registry|smss.exe|csrss.exe|services.exe|wininit.exe";
|
|
|
-
|
|
|
-bool cmp(const pair<int, double>& a, const pair<int, double>& b) {
|
|
|
- return a.second > b.second;
|
|
|
-}
|
|
|
-
|
|
|
void ResourceWatcherFSM::GetSystemCPUStatus()
|
|
|
{
|
|
|
oldProcessTime.clear();
|
|
@@ -3697,11 +3452,19 @@ void ResourceWatcherFSM::GetSystemMemoryStatus()
|
|
|
|
|
|
void ResourceWatcherFSM::DetectWallpaperAndWarn()
|
|
|
{
|
|
|
+ //////////////////////////////////////////////////////////////////////////
|
|
|
+ CSmartPointer<IConfigInfo> spCtSettingConfig;
|
|
|
+ GetEntityBase()->GetFunction()->OpenConfig(Config_CenterSetting, spCtSettingConfig);
|
|
|
+ int value(0);
|
|
|
+ spCtSettingConfig->ReadConfigValueInt(GetEntityBase()->GetEntityName(), "MakeSureCMBWallPaper", value);
|
|
|
+ if (!value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ bool wallpapaerSetCMD = true;
|
|
|
DWORD dwFlag = KEY_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS;
|
|
|
if (Is32R64Platform() != 0) {
|
|
|
dwFlag |= KEY_WOW64_64KEY;
|
|
|
}
|
|
|
- bool wallpapaerSetCMD = false;
|
|
|
bool wellDone = false;
|
|
|
CSimpleStringA regeditValue(true);
|
|
|
HKEY hKey;
|
|
@@ -3713,8 +3476,8 @@ void ResourceWatcherFSM::DetectWallpaperAndWarn()
|
|
|
memset(szValue, '\0', MAX_PATH + 1);
|
|
|
lResult = RegQueryValueEx(hKey, "Wallpaper", NULL, &dwType, (LPBYTE)szValue, &dwSize);
|
|
|
if (lResult == ERROR_SUCCESS) {
|
|
|
- CSimpleStringA strMsg = CSimpleStringA::Format("{\"subject\":\"wallpaper_path\",\"value\":\"%s\"}", szValue);
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_INFO_DESKTOP_WALLPAPER_PATH, strMsg);
|
|
|
+ //CSimpleStringA strMsg = CSimpleStringA::Format("{\"subject\":\"wallpaper_path\",\"value\":\"%s\"}", szValue);
|
|
|
+ //LogWarn(Severity_Low, Error_Debug, LOG_INFO_DESKTOP_WALLPAPER_PATH, strMsg);
|
|
|
regeditValue = szValue;
|
|
|
wellDone = true;
|
|
|
}
|
|
@@ -3728,14 +3491,7 @@ void ResourceWatcherFSM::DetectWallpaperAndWarn()
|
|
|
LogWarn(Severity_Low, Error_Unexpect, LOG_WARN_DESKTOP_WALLPAPER_PATH_FETCHFAILE, strMsg);
|
|
|
}
|
|
|
RegCloseKey(hKey);
|
|
|
- //////////////////////////////////////////////////////////////////////////
|
|
|
- CSmartPointer<IConfigInfo> spCtSettingConfig;
|
|
|
- GetEntityBase()->GetFunction()->OpenConfig(Config_CenterSetting, spCtSettingConfig);
|
|
|
- int value(0);
|
|
|
- spCtSettingConfig->ReadConfigValueInt(GetEntityBase()->GetEntityName(), "MakeSureCMBWallPaper", value);
|
|
|
- if (!!value) {
|
|
|
- wallpapaerSetCMD = true;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
CSimpleStringA RVCWallpaperName("WallPaper1920.png");
|
|
|
if (wellDone && !regeditValue.IsNullOrEmpty() && regeditValue.IndexOf(RVCWallpaperName) != -1 && ExistsFileA(regeditValue)) {
|
|
@@ -3835,25 +3591,12 @@ void ResourceWatcherFSM::InitCustomAutoStartFileSheet()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- int value(0);
|
|
|
- spCtSettingConfig->ReadConfigValueInt(GetEntityBase()->GetEntityName(), "DeleteCustomAutoStartFile", value);
|
|
|
- if (!!value) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Get DeleteCustomAutoStartFile execute flag from CenterSettings");
|
|
|
- flag4DeleteKeyAutoStartFile = !!value;
|
|
|
- }
|
|
|
- // if (flag4DeleteKeyAutoStartFile) {
|
|
|
- //strFileInterestSheet.Clear();
|
|
|
- //spCtSettingConfig->ReadConfigValue(GetEntityBase()->GetEntityName(), "DeleteAutoStartFileSheet", strFileInterestSheet);
|
|
|
- //if (!strFileInterestSheet.IsNullOrEmpty()) {
|
|
|
- // auto fileNames = strFileInterestSheet.Split('|');
|
|
|
- // if (fileNames.GetCount() > 0) {
|
|
|
- // for (int i = 0; i < fileNames.GetCount(); ++i) {
|
|
|
- // DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("DeleteAutoStartFileSheet[%s]", fileNames[i].GetData());
|
|
|
- // delKeylist.push_back(fileNames[i].GetData());
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
- // }
|
|
|
+ //int value(0);
|
|
|
+ // spCtSettingConfig->ReadConfigValueInt(GetEntityBase()->GetEntityName(), "DeleteCustomAutoStartFile", value);
|
|
|
+ //if (!!value) {
|
|
|
+ // DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Get DeleteCustomAutoStartFile execute flag from CenterSettings");
|
|
|
+ // flag4DeleteKeyAutoStartFile = !!value;
|
|
|
+ //}
|
|
|
}
|
|
|
|
|
|
void ResourceWatcherFSM::InitUserInfo()
|
|
@@ -4367,7 +4110,7 @@ void ResourceWatcherFSM::AlarmSystemBasicInfo()
|
|
|
strResult += CSimpleStringA::Format("\"Serial Number\":\"%s\"", info.strSerialNumber.GetData());
|
|
|
}
|
|
|
strResult += "}";
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_INFO_DEVICE_SMBIOS_GET, strResult);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("InfoAboutManufacturer")(strResult.GetData());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -4416,7 +4159,7 @@ void ResourceWatcherFSM::DetectSoftwareInstallStatus()
|
|
|
{
|
|
|
strSoftwaresNames[i] = value;
|
|
|
}
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Detect SoftDetect from CentralSetting, %d: [%s],[%s],[%s]"
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Detect SoftDetect from CentralSetting, %d: [%s],[%s],[%s]"
|
|
|
, i, item.GetData(), strSoftwaresNames[i].GetData(), strSoftwaresVers[i].GetData());
|
|
|
nNameCounts++;
|
|
|
}
|
|
@@ -4427,14 +4170,11 @@ void ResourceWatcherFSM::DetectSoftwareInstallStatus()
|
|
|
vector<SetupSoftInfo> stupInfo;
|
|
|
DWORD dwInitFlag(0);
|
|
|
FetchSoftewareInstall(stupInfo, dwInitFlag);
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("1software size:%d", stupInfo.size());
|
|
|
if (dwInitFlag == 1) {
|
|
|
FetchSoftewareInstall(stupInfo, dwInitFlag);
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("2software size:%d", stupInfo.size());
|
|
|
}
|
|
|
dwInitFlag = 2;
|
|
|
FetchSoftewareInstall(stupInfo, dwInitFlag);
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("3software size:%d", stupInfo.size());
|
|
|
for (int i = 0; i < nNameCounts; ++i) {
|
|
|
bool found(false);
|
|
|
for (int j = 0; j < stupInfo.size(); j++) {
|
|
@@ -4566,7 +4306,7 @@ void ResourceWatcherFSM::UploadSysVersionInfo(UINT& ver)
|
|
|
srcData.insert(std::make_pair("cpu-type", sucContent));
|
|
|
} while (false);
|
|
|
auto ret = generateJsonStr(srcData);
|
|
|
- LogWarn(Severity_Low, Error_Hardware, LOG_RESOURCEWATCHER_SYSTEMINFO, ret.second.c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("SystemBaseInfo")(ret.second.c_str());
|
|
|
}
|
|
|
|
|
|
void ResourceWatcherFSM::UploadSysActivationStatus()
|
|
@@ -4621,7 +4361,7 @@ void ResourceWatcherFSM::UploadSysActivationStatus()
|
|
|
else {
|
|
|
warnMsg = CSimpleStringA::Format("{\"subject\":\"system_activation\", \"fetch_status\":\"failed\"}");
|
|
|
}
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_INFO_SYSTEM_ACTIVATION_INFO, value);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("SystemActivationStatus")(value);
|
|
|
}
|
|
|
|
|
|
string ResourceWatcherFSM::MemoryProcessStatus()
|
|
@@ -4755,10 +4495,6 @@ const char* ResourceWatcherFSM::GetItems(const char* buffer, unsigned int item)
|
|
|
return p;
|
|
|
}
|
|
|
|
|
|
-bool cmp(const pair<DWORD, DOUBLE>& a, const pair<DWORD, DOUBLE>& b) {
|
|
|
- return a.second > b.second;
|
|
|
-}
|
|
|
-
|
|
|
/* -----------------------
|
|
|
根据先后两个时间的CPU信息,
|
|
|
计算CPU的总占用量和各个进程的占用量
|
|
@@ -4767,12 +4503,15 @@ void ResourceWatcherFSM::GetSystemCPUStatus()
|
|
|
{
|
|
|
//int cpu_num = sysconf(_SC_NPROCESSORS_CONF); //CPU核数
|
|
|
|
|
|
+ oldProcessTime.clear();
|
|
|
+ newProcessTime.clear();
|
|
|
+ processName.clear();
|
|
|
+ processCpu.clear();
|
|
|
+
|
|
|
CPUInfo* cpuOld = new CPUInfo;
|
|
|
CPUInfo* cpuNew = new CPUInfo;
|
|
|
|
|
|
const char* tPath = "/proc";
|
|
|
- map<DWORD, string> nameProcess; // <pid, 进程名>
|
|
|
- map<DWORD, DOUBLE> usageProcess; // <pid, CPU占用率>
|
|
|
|
|
|
long oldTotalTime = GetCPURunTime(cpuOld); //旧CPU运行总时间
|
|
|
if (oldTotalTime == -1)
|
|
@@ -4780,7 +4519,6 @@ void ResourceWatcherFSM::GetSystemCPUStatus()
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- map<DWORD, long> oldProcCPUTime; // <pid, 旧时刻进程的CPU占用时间>
|
|
|
struct dirent* oldDirp;
|
|
|
DIR* oldDp = opendir(tPath);
|
|
|
if (oldDp != NULL) {
|
|
@@ -4807,8 +4545,8 @@ void ResourceWatcherFSM::GetSystemCPUStatus()
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- oldProcCPUTime[pid] = oldTime;
|
|
|
- nameProcess[pid] = oldProcCPU->pname;
|
|
|
+ oldProcessTime[pid] = oldTime;
|
|
|
+ processName[pid] = oldProcCPU->pname;
|
|
|
|
|
|
delete oldProcCPU;
|
|
|
}
|
|
@@ -4823,7 +4561,6 @@ void ResourceWatcherFSM::GetSystemCPUStatus()
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- map<DWORD, long> newProcCPUTime; // <pid, 新时刻进程的CPU占用时间>
|
|
|
struct dirent* newDirp;
|
|
|
DIR* newDp = opendir(tPath);
|
|
|
if (newDp != NULL) {
|
|
@@ -4851,52 +4588,26 @@ void ResourceWatcherFSM::GetSystemCPUStatus()
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- newProcCPUTime[pid] = newTime;
|
|
|
+ newProcessTime[pid] = newTime;
|
|
|
|
|
|
string tName = newProcCPU->pname;
|
|
|
tName.erase(tName.begin());
|
|
|
tName.erase(tName.begin() + (tName.length() - 1));
|
|
|
|
|
|
- nameProcess[pid] = tName;
|
|
|
+ processName[pid] = tName.c_str();
|
|
|
|
|
|
delete newProcCPU;
|
|
|
}
|
|
|
closedir(newDp);
|
|
|
}
|
|
|
|
|
|
- map<DWORD, long>::iterator it;
|
|
|
- for (it = newProcCPUTime.begin(); it != newProcCPUTime.end(); ++it)
|
|
|
+ unordered_map<int, long long>::iterator it;
|
|
|
+ for (it = newProcessTime.begin(); it != newProcessTime.end(); ++it)
|
|
|
{
|
|
|
DWORD tPid = it->first;
|
|
|
//进程的占用率 = 单位时间间隔里进程的CPU时间片占用 / 单位时间间隔里CPU的整体时间片
|
|
|
- DOUBLE tRatio = 100.0 * (newProcCPUTime[tPid] - oldProcCPUTime[tPid]) / (newTotalTime - oldTotalTime);
|
|
|
- usageProcess[tPid] = tRatio;
|
|
|
- }
|
|
|
-
|
|
|
- CSystemRunInfo runInfo = { 0 };
|
|
|
- GetEntityBase()->GetFunction()->GetSystemRunInfo(runInfo);
|
|
|
-
|
|
|
- for (int i = 0; i < runInfo.strRunningEntityNames.GetCount(); i++) //实体进程的名称默认全为sphost,需转换为对应实体名
|
|
|
- {
|
|
|
- string entityName = runInfo.strRunningEntityNames[i].GetData();
|
|
|
- CEntityRunInfo entityInfo = { 0 };
|
|
|
- GetEntityBase()->GetFunction()->GetEntityRunInfo(entityName.c_str(), entityInfo);
|
|
|
- nameProcess[entityInfo.dwProcessID] = entityName;
|
|
|
- }
|
|
|
-
|
|
|
- vector<pair<DWORD, DOUBLE>> vec(usageProcess.begin(), usageProcess.end());
|
|
|
- sort(vec.begin(), vec.end(), cmp); //根据CPU使用率从大到小进行排序
|
|
|
-
|
|
|
- int cpuTop = 10;
|
|
|
- int len = MIN(cpuTop, vec.size()); //确认要展示的进程数量
|
|
|
- string procWarn = "";
|
|
|
- for (int i = 0; i < len; ++i) //构建进程的CPU使用告警信息
|
|
|
- {
|
|
|
- char* tUsage = new char[20];
|
|
|
- sprintf(tUsage, "%.2lf", vec[i].second);
|
|
|
- procWarn = procWarn + ",\"" + nameProcess[vec[i].first] + "\":\"" + string(tUsage) + "%\"";
|
|
|
-
|
|
|
- delete tUsage;
|
|
|
+ double tRatio = 100.0 * (newProcessTime[tPid] - oldProcessTime[tPid]) / (newTotalTime - oldTotalTime);
|
|
|
+ processCpu[tPid] = tRatio;
|
|
|
}
|
|
|
|
|
|
unsigned long oldInfo, newInfo;
|
|
@@ -4925,12 +4636,39 @@ void ResourceWatcherFSM::GetSystemCPUStatus()
|
|
|
cpuWarnTime = cpuWarnTime % cpuWarnThreshold;
|
|
|
if (cpuWarnTime == 0) //每达到一次阈值告警一次
|
|
|
{
|
|
|
+ CSystemRunInfo runInfo = { 0 };
|
|
|
+ GetEntityBase()->GetFunction()->GetSystemRunInfo(runInfo);
|
|
|
+
|
|
|
+ for (int i = 0; i < runInfo.strRunningEntityNames.GetCount(); i++) //实体进程的名称默认全为sphost,需转换为对应实体名
|
|
|
+ {
|
|
|
+ CSimpleStringA entityName = runInfo.strRunningEntityNames[i].GetData();
|
|
|
+ CEntityRunInfo entityInfo = { 0 };
|
|
|
+ GetEntityBase()->GetFunction()->GetEntityRunInfo(entityName.GetData(), entityInfo);
|
|
|
+ processName[entityInfo.dwProcessID] = entityName;
|
|
|
+ }
|
|
|
+
|
|
|
+ vector<pair<int, double>> vec(processCpu.begin(), processCpu.end());
|
|
|
+ sort(vec.begin(), vec.end(), cmp); //根据CPU使用率从大到小进行排序
|
|
|
+
|
|
|
+ int cpuTop = 10;
|
|
|
+ int len = MIN(cpuTop, vec.size()); //确认要展示的进程数量
|
|
|
+ CSimpleStringA procWarn = "";
|
|
|
+ for (int i = 0; i < len; ++i) //构建进程的CPU使用告警信息
|
|
|
+ {
|
|
|
+ char* tUsage = new char[20];
|
|
|
+ sprintf(tUsage, "%.2lf", vec[i].second);
|
|
|
+ procWarn = procWarn + ",\"" + processName[vec[i].first] + "\":\"" + tUsage + "%\"";
|
|
|
+
|
|
|
+ delete tUsage;
|
|
|
+ }
|
|
|
+
|
|
|
stringstream tss;
|
|
|
tss << std::setiosflags(std::ios::fixed) << std::setprecision(2) << cUsedRate * 100;
|
|
|
|
|
|
- string warn = "{\"type\":\"cpu\", \"total_used\":\"" + tss.str() + "%\"" + procWarn + "}";
|
|
|
- LogWarn(Severity_Middle, Error_Resource, LOG_EVT_RESOURCE_CPU_TOO_HIGH, CSimpleStringA::Format("%s", warn.c_str()));
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5A03").setAPI("CpuUsedCheck")(warn.c_str());
|
|
|
+ CSimpleStringA warn = "";
|
|
|
+ warn = warn + "{\"type\":\"cpu\", \"total_used\":\"" + tss.str().c_str() + "%\"" + procWarn + "}";
|
|
|
+ LogWarn(Severity_Middle, Error_Resource, LOG_EVT_RESOURCE_CPU_TOO_HIGH, CSimpleStringA::Format("%s", warn.GetData()));
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5A03").setAPI("CpuUsedCheck")(warn.GetData());
|
|
|
}
|
|
|
cpuWarnTime++;
|
|
|
}
|
|
@@ -5152,3 +4890,47 @@ void ResourceWatcherFSM::ConfirmWindowEffectHasBeenOpen()
|
|
|
}
|
|
|
#endif // RVC_OS_LINUX
|
|
|
|
|
|
+void ResourceWatcherFSM::GetSystemProccess()
|
|
|
+{
|
|
|
+ if(processName.empty())
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Get Sys Process error, it's empty!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ int len = 0;
|
|
|
+ CSimpleStringA curProcStr = "";
|
|
|
+ CSimpleStringA endStr = ",";
|
|
|
+ CSimpleStringA totalProcStr = "{";
|
|
|
+
|
|
|
+ vector<pair<int, CSimpleStringA>> vec(processName.begin(), processName.end());
|
|
|
+ sort(vec.begin(), vec.end(), cmpPid);
|
|
|
+
|
|
|
+ for (int i = 0; i < vec.size(); i++)
|
|
|
+ {
|
|
|
+ curProcStr = CSimpleStringA("\"") + to_string(vec[i].first).c_str() + "\":\"" + vec[i].second + "\"";
|
|
|
+ len = totalProcStr.GetLength() + curProcStr.GetLength();
|
|
|
+ if (len > 1000 || i == (vec.size()-1))
|
|
|
+ {
|
|
|
+ endStr = "}";
|
|
|
+ if (i == (vec.size() - 1)) //最后一个
|
|
|
+ {
|
|
|
+ totalProcStr = totalProcStr + curProcStr + endStr;
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetSystemProccess")(totalProcStr.GetData());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else //长度超限
|
|
|
+ {
|
|
|
+ totalProcStr[totalProcStr.GetLength() - 1] = '}';
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetSystemProccess")(totalProcStr.GetData());
|
|
|
+ totalProcStr = CSimpleStringA("{") + curProcStr + ","; //超过长度则从当前进程开始重新搭建日志
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ endStr = ",";
|
|
|
+ totalProcStr = totalProcStr + curProcStr + endStr;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|