mirror of
https://github.com/tnodir/fort
synced 2024-11-15 07:45:22 +00:00
UI: StatManager: Fix stats for Traffic Graph when "Collect Traffic Statistics" is turned off
This commit is contained in:
parent
27c7935ed4
commit
60997a1f9a
@ -242,11 +242,11 @@ bool StatManager::logProcNew(const LogEntryProcNew &entry, qint64 unixTime)
|
|||||||
|
|
||||||
bool StatManager::logStatTraf(const LogEntryStatTraf &entry, qint64 unixTime)
|
bool StatManager::logStatTraf(const LogEntryStatTraf &entry, qint64 unixTime)
|
||||||
{
|
{
|
||||||
const bool logStat = conf() && conf()->logStat();
|
|
||||||
|
|
||||||
// Active period
|
// Active period
|
||||||
updateActivePeriod();
|
updateActivePeriod();
|
||||||
|
|
||||||
|
const bool logStat = conf() && conf()->logStat() && m_isActivePeriod;
|
||||||
|
|
||||||
const bool isNewDay = updateTrafDay(unixTime);
|
const bool isNewDay = updateTrafDay(unixTime);
|
||||||
|
|
||||||
sqliteDb()->beginTransaction();
|
sqliteDb()->beginTransaction();
|
||||||
@ -284,10 +284,8 @@ bool StatManager::logStatTraf(const LogEntryStatTraf &entry, qint64 unixTime)
|
|||||||
const bool inactive = (pidFlag & 1) != 0;
|
const bool inactive = (pidFlag & 1) != 0;
|
||||||
const quint32 pid = pidFlag & ~quint32(1);
|
const quint32 pid = pidFlag & ~quint32(1);
|
||||||
|
|
||||||
if (logStat) {
|
logTrafBytes(insertTrafAppStmts, updateTrafAppStmts, sumInBytes, sumOutBytes, pid,
|
||||||
logTrafBytes(insertTrafAppStmts, updateTrafAppStmts, sumInBytes, sumOutBytes, pid,
|
inBytes, outBytes, unixTime, logStat);
|
||||||
inBytes, outBytes, unixTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inactive) {
|
if (inactive) {
|
||||||
logClearApp(pid);
|
logClearApp(pid);
|
||||||
@ -295,7 +293,7 @@ bool StatManager::logStatTraf(const LogEntryStatTraf &entry, qint64 unixTime)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_isActivePeriod && logStat) {
|
if (logStat) {
|
||||||
const SqliteStmtList insertTrafStmts = SqliteStmtList()
|
const SqliteStmtList insertTrafStmts = SqliteStmtList()
|
||||||
<< getTrafficStmt(StatSql::sqlInsertTrafHour, m_trafHour)
|
<< getTrafficStmt(StatSql::sqlInsertTrafHour, m_trafHour)
|
||||||
<< getTrafficStmt(StatSql::sqlInsertTrafDay, m_trafDay)
|
<< getTrafficStmt(StatSql::sqlInsertTrafDay, m_trafDay)
|
||||||
@ -474,7 +472,7 @@ void StatManager::getStatAppList(QStringList &list, QVector<qint64> &appIds)
|
|||||||
|
|
||||||
void StatManager::logTrafBytes(const SqliteStmtList &insertStmtList,
|
void StatManager::logTrafBytes(const SqliteStmtList &insertStmtList,
|
||||||
const SqliteStmtList &updateStmtList, quint32 &sumInBytes, quint32 &sumOutBytes,
|
const SqliteStmtList &updateStmtList, quint32 &sumInBytes, quint32 &sumOutBytes,
|
||||||
quint32 pid, quint32 inBytes, quint32 outBytes, qint64 unixTime)
|
quint32 pid, quint32 inBytes, quint32 outBytes, qint64 unixTime, bool logStat)
|
||||||
{
|
{
|
||||||
const QString appPath = m_appPidPathMap.value(pid);
|
const QString appPath = m_appPidPathMap.value(pid);
|
||||||
|
|
||||||
@ -490,7 +488,7 @@ void StatManager::logTrafBytes(const SqliteStmtList &insertStmtList,
|
|||||||
const qint64 appId = getOrCreateAppId(appPath, unixTime);
|
const qint64 appId = getOrCreateAppId(appPath, unixTime);
|
||||||
Q_ASSERT(appId != INVALID_APP_ID);
|
Q_ASSERT(appId != INVALID_APP_ID);
|
||||||
|
|
||||||
if (m_isActivePeriod) {
|
if (logStat) {
|
||||||
if (!hasAppTraf(appId)) {
|
if (!hasAppTraf(appId)) {
|
||||||
emit appCreated(appId, appPath);
|
emit appCreated(appId, appPath);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ private:
|
|||||||
|
|
||||||
void logTrafBytes(const SqliteStmtList &insertStmtList, const SqliteStmtList &updateStmtList,
|
void logTrafBytes(const SqliteStmtList &insertStmtList, const SqliteStmtList &updateStmtList,
|
||||||
quint32 &sumInBytes, quint32 &sumOutBytes, quint32 pid, quint32 inBytes,
|
quint32 &sumInBytes, quint32 &sumOutBytes, quint32 pid, quint32 inBytes,
|
||||||
quint32 outBytes, qint64 unixTime);
|
quint32 outBytes, qint64 unixTime, bool logStat);
|
||||||
|
|
||||||
void updateTrafficList(const SqliteStmtList &insertStmtList,
|
void updateTrafficList(const SqliteStmtList &insertStmtList,
|
||||||
const SqliteStmtList &updateStmtList, quint32 inBytes, quint32 outBytes,
|
const SqliteStmtList &updateStmtList, quint32 inBytes, quint32 outBytes,
|
||||||
|
Loading…
Reference in New Issue
Block a user