mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 02:06:08 +08:00
Watchdog allows to obtain info string about the statistics
This commit is contained in:
@@ -1056,6 +1056,10 @@ namespace BlackCore
|
||||
else
|
||||
{
|
||||
CLogMessage(this).warning("swift DB not accessible");
|
||||
if (m_networkWatchDog)
|
||||
{
|
||||
CLogMessage(this).warning(m_networkWatchDog->getCheckInfo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace BlackCore
|
||||
{
|
||||
m_dbAccessible = accessible;
|
||||
m_internetAccessible = m_internetAccessible && m_networkAccessible;
|
||||
QTimer::singleShot(0, &m_updateTimer, [this] { m_updateTimer.start(); }); // restart
|
||||
QTimer::singleShot(0, &m_updateTimer, [this] { m_updateTimer.start(); }); // restart timer
|
||||
}
|
||||
|
||||
bool CNetworkWatchdog::hasWorkingSharedUrl() const
|
||||
@@ -68,6 +68,14 @@ namespace BlackCore
|
||||
return n; // triggered
|
||||
}
|
||||
|
||||
QString CNetworkWatchdog::getCheckInfo() const
|
||||
{
|
||||
static const QString info("Internet accessible: %1 (good: %2/ bad: %3), swift DB accessible: %4 (good: %5/bad: %6)");
|
||||
return info.
|
||||
arg(boolToYesNo(this->isInternetAccessible())).arg(m_goodCountInternet).arg(m_badCountInternet).
|
||||
arg(boolToYesNo(this->isSwiftDbAccessible())).arg(m_goodCountDb).arg(m_badCountDb);
|
||||
}
|
||||
|
||||
void CNetworkWatchdog::setWorkingSharedUrl(const CUrl &workingUrl)
|
||||
{
|
||||
QWriteLocker l(&m_lockSharedUrl);
|
||||
@@ -153,6 +161,8 @@ namespace BlackCore
|
||||
static const QString testHost2("www.microsoft.com"); // secondary test
|
||||
canConnectInternet = CNetworkUtils::canConnect(testHost2, 80, message); // running in background worker
|
||||
}
|
||||
if (canConnectInternet) { m_goodCountInternet++; }
|
||||
else { m_badCountInternet++; }
|
||||
}
|
||||
m_internetAccessible = networkAccess && canConnectInternet;
|
||||
|
||||
@@ -224,6 +234,8 @@ namespace BlackCore
|
||||
nw->close();
|
||||
if (!sApp || sApp->isShuttingDown()) { return; }
|
||||
m_lastClientPingSuccess = ok;
|
||||
if (ok) { m_goodCountDb++; }
|
||||
else { m_badCountDb++; }
|
||||
this->setDbAccessibility(ok);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,8 +76,13 @@ namespace BlackCore
|
||||
int triggerCheck();
|
||||
|
||||
//! Number of completed checks
|
||||
//! \threadsafe
|
||||
int getCheckCount() const { return m_checkCount; }
|
||||
|
||||
//! Number of completed checks
|
||||
//! \threadsafe
|
||||
QString getCheckInfo() const;
|
||||
|
||||
//! Set working URL from external
|
||||
//! \threadsafe
|
||||
void setWorkingSharedUrl(const BlackMisc::Network::CUrl &workingUrl);
|
||||
@@ -150,6 +155,10 @@ namespace BlackCore
|
||||
std::atomic_bool m_checkSharedUrl { true };
|
||||
std::atomic_bool m_checkInProgress { false }; //!< a check is currently in progress
|
||||
std::atomic_int m_checkCount { 0 }; //!< counting number of checks
|
||||
std::atomic_int m_badCountDb { 0 }; //! Total number of DB failing counts (only real responses when tried)
|
||||
std::atomic_int m_badCountInternet { 0 }; //! Total number of Internet failing count (only when network is accessible)
|
||||
std::atomic_int m_goodCountDb { 0 };
|
||||
std::atomic_int m_goodCountInternet { 0 };
|
||||
BlackMisc::Network::CUrl m_workingSharedUrl;
|
||||
mutable QReadWriteLock m_lockSharedUrl;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user