|
|
@@ -290,7 +290,7 @@ void ResourceWatcherFSM::TriggerAtStatusChanged(bool bMStatus)
|
|
|
}
|
|
|
void* pTmpData = NULL;
|
|
|
ITimerListener* pListener = new TimerOutHelper<ResourceWatcherFSM>(this, &ResourceWatcherFSM::HardwareInfoTimer, pTmpData);
|
|
|
- GetEntityBase()->GetFunction()->SetTimer(TIMER_HARDWARE_CHECK, pListener, hardwareCheckTime);
|
|
|
+ GetEntityBase()->GetFunction()->SetTimer(TIMER_HARDWARE_CHECK, pListener, 10 * 1000);
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Set Hardware Timer!");
|
|
|
|
|
|
if (diskCheckFlag > 0) {
|
|
|
@@ -1140,7 +1140,7 @@ void ResourceWatcherFSM::HardwareInfoTimer(void* pData)
|
|
|
GetSystemMemoryStatus();
|
|
|
}
|
|
|
|
|
|
- GetEntityBase()->GetFunction()->ResetTimer(TIMER_HARDWARE_CHECK, hardwareCheckTime);
|
|
|
+ GetEntityBase()->GetFunction()->ResetTimer(TIMER_HARDWARE_CHECK, 10 * 1000);
|
|
|
}
|
|
|
|
|
|
void ResourceWatcherFSM::DiskCheckTimer(void* pData)
|
|
|
@@ -3045,6 +3045,15 @@ void ResourceWatcherFSM::GetSystemCPUStatus()
|
|
|
processName[entityInfo.dwProcessID] = runInfo.strRunningEntityNames[i];
|
|
|
}
|
|
|
|
|
|
+ unordered_map<const char*, int> sysProc;
|
|
|
+ sysProc["[System Process]"] = 1;
|
|
|
+ sysProc["System"] = 2;
|
|
|
+ sysProc["Registry"] = 3;
|
|
|
+ sysProc["smss.exe"] = 4;
|
|
|
+ sysProc["csrss.exe"] = 5;
|
|
|
+ sysProc["services.exe"] = 6;
|
|
|
+ sysProc["wininit.exe"] = 7;
|
|
|
+
|
|
|
unordered_map<int, long long>::iterator it;
|
|
|
for (it = newProcessTime.begin(); it != newProcessTime.end(); ++it)
|
|
|
{
|
|
|
@@ -3055,8 +3064,14 @@ void ResourceWatcherFSM::GetSystemCPUStatus()
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
+ if (sysProc.find(processName[tPid].GetData()) != sysProc.end())
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("进程名:%s. 找到了,系统进程,不纳入统计。", processName[tPid]);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
// 转换为百分比
|
|
|
- double tRatio = 100.0 * (newProcessTime[tPid] - oldProcessTime[tPid]) / deltaTime;
|
|
|
+ double tRatio = 100.0 * (newProcessTime[tPid] - oldProcessTime[tPid]) / (kernel + user);
|
|
|
if (tRatio > 0.0);
|
|
|
{
|
|
|
processCpu[tPid] = tRatio;
|
|
|
@@ -3084,10 +3099,10 @@ void ResourceWatcherFSM::GetSystemCPUStatus()
|
|
|
cpuWarnThreshold = 10; //默认满10次告一次警
|
|
|
}
|
|
|
|
|
|
- if (cpuRatio > (double)m_cpuHighPercent)
|
|
|
+ if (cpuRatio > 50)
|
|
|
{
|
|
|
cpuWarnTime = cpuWarnTime % cpuWarnThreshold;
|
|
|
- if (cpuWarnTime == 0) //每达到一次阈值告警一次
|
|
|
+ if (true) //每达到一次阈值告警一次
|
|
|
{
|
|
|
CSimpleStringA warn = CSimpleStringA::Format("{\"type\":\"cpu\", \"total_used\":\" %.2f", cpuRatio);
|
|
|
warn = warn + "%\"" + procWarn + "}";
|