|
@@ -7,7 +7,6 @@
|
|
|
#include <algorithm>
|
|
|
#include "fileutil.h"
|
|
|
#include <ctime>
|
|
|
-#include "CommEntityUtil.hpp"
|
|
|
#include "SpUtility.h"
|
|
|
#include "RestfulFunc.h"
|
|
|
#include <stdio.h>
|
|
@@ -95,6 +94,10 @@ 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
|
|
@@ -260,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;
|
|
@@ -315,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__);
|
|
@@ -346,13 +361,6 @@ ErrorCodeEnum ResourceWatcherFSM::OnInit()
|
|
|
}
|
|
|
spRunConfig->ReadConfigValueInt("WarnRecord", "disk", m_diskLastWarnHour);
|
|
|
|
|
|
- int CloseUploadSysProcFlag = 0; //关闭进程信息上送标志
|
|
|
- spCtSettingConfig->ReadConfigValueInt(m_pEntity->GetEntityName(), "CloseUploadSysProcFlag", CloseUploadSysProcFlag);
|
|
|
- if (!CloseUploadSysProcFlag) {
|
|
|
- UploadSysProcInfoTask* uploadProcInfo = new UploadSysProcInfoTask(this);
|
|
|
- GetEntityBase()->GetFunction()->PostThreadPoolTask(uploadProcInfo);
|
|
|
- }
|
|
|
-
|
|
|
return Error_Succeed;
|
|
|
}
|
|
|
|
|
@@ -3426,17 +3434,6 @@ void ResourceWatcherFSM::GetSystemCPUStatus()
|
|
|
}
|
|
|
CloseHandle(hProcessSnapNew);
|
|
|
|
|
|
- //终端进程名称转换
|
|
|
- CSystemRunInfo runInfo = { 0 };
|
|
|
- GetEntityBase()->GetFunction()->GetSystemRunInfo(runInfo);
|
|
|
- for (int i = 0; i < runInfo.strRunningEntityNames.GetCount(); i++) //实体进程的名称默认全为sphost,需转换为对应实体名
|
|
|
- {
|
|
|
- runInfo.strRunningEntityNames[i];
|
|
|
- CEntityRunInfo entityInfo = { 0 };
|
|
|
- GetEntityBase()->GetFunction()->GetEntityRunInfo(runInfo.strRunningEntityNames[i].GetData(), entityInfo);
|
|
|
- processName[entityInfo.dwProcessID] = runInfo.strRunningEntityNames[i];
|
|
|
- }
|
|
|
-
|
|
|
long long idle = CompareFileTime2(preIdleTime, idleTime);
|
|
|
long long kernel = CompareFileTime2(preKernelTime, kernelTime);
|
|
|
long long user = CompareFileTime2(preUserTime, userTime);
|
|
@@ -3461,6 +3458,17 @@ void ResourceWatcherFSM::GetSystemCPUStatus()
|
|
|
cpuWarnTime = cpuWarnTime % cpuWarnThreshold;
|
|
|
if (cpuWarnTime == 0) //CPU使用率过高达到一定次数告警一次
|
|
|
{
|
|
|
+ //终端进程名称转换
|
|
|
+ CSystemRunInfo runInfo = { 0 };
|
|
|
+ GetEntityBase()->GetFunction()->GetSystemRunInfo(runInfo);
|
|
|
+ for (int i = 0; i < runInfo.strRunningEntityNames.GetCount(); i++) //实体进程的名称默认全为sphost,需转换为对应实体名
|
|
|
+ {
|
|
|
+ runInfo.strRunningEntityNames[i];
|
|
|
+ CEntityRunInfo entityInfo = { 0 };
|
|
|
+ GetEntityBase()->GetFunction()->GetEntityRunInfo(runInfo.strRunningEntityNames[i].GetData(), entityInfo);
|
|
|
+ processName[entityInfo.dwProcessID] = runInfo.strRunningEntityNames[i];
|
|
|
+ }
|
|
|
+
|
|
|
//进程占用率计算
|
|
|
unordered_map<int, long long>::iterator it;
|
|
|
for (it = newProcessTime.begin(); it != newProcessTime.end(); ++it)
|
|
@@ -4872,32 +4880,6 @@ void ResourceWatcherFSM::GetSystemCPUStatus()
|
|
|
processCpu[tPid] = tRatio;
|
|
|
}
|
|
|
|
|
|
- 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;
|
|
|
- }
|
|
|
-
|
|
|
unsigned long oldInfo, newInfo;
|
|
|
double cUsedRate = 0;
|
|
|
|
|
@@ -4924,6 +4906,32 @@ 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;
|
|
|
|
|
@@ -5152,11 +5160,6 @@ void ResourceWatcherFSM::ConfirmWindowEffectHasBeenOpen()
|
|
|
}
|
|
|
#endif // RVC_OS_LINUX
|
|
|
|
|
|
-
|
|
|
-bool cmpPid(const pair<int, CSimpleStringA>& a, const pair<int, CSimpleStringA>& b) {
|
|
|
- return a.first < b.first;
|
|
|
-}
|
|
|
-
|
|
|
void ResourceWatcherFSM::GetSystemProccess()
|
|
|
{
|
|
|
if(processName.empty())
|