Commit 66897b10 authored by Michael Ott's avatar Michael Ott
Browse files

Add statistics for cached queries

parent 547f2ce4
......@@ -89,7 +89,8 @@ int keepRunning;
int retCode = EXIT_SUCCESS;
uint64_t msgCtr;
uint64_t readingCtr;
uint64_t queryCtr;
uint64_t dbQueryCtr;
uint64_t cachedQueryCtr;
SensorCache mySensorCache;
AnalyticsController* analyticsController;
DCDB::Connection* dcdbConn;
......@@ -164,6 +165,10 @@ bool sensorGroupQueryCallback(const std::vector<string>& names, const uint64_t s
mySensorCache.release();
}
}
if (successCtr) {
cachedQueryCtr+= buffer.size();
}
// If we are here then some sensors were not found in the cache - we need to fetch data from Cassandra
if(!topics.empty()) {
try {
......@@ -190,7 +195,7 @@ bool sensorGroupQueryCallback(const std::vector<string>& names, const uint64_t s
if (!results.empty()) {
successCtr++;
reading_t reading;
queryCtr+= results.size();
dbQueryCtr+= results.size();
for (const auto &r : results) {
reading.value = r.value;
reading.timestamp = r.timeStamp.getRaw();
......@@ -872,7 +877,8 @@ int main(int argc, char* const argv[]) {
float elapsed;
msgCtr = 0;
readingCtr = 0;
queryCtr = 0;
dbQueryCtr = 0;
cachedQueryCtr = 0;
start = getTimestamp();
uint64_t lastCleanup = start;
......@@ -895,11 +901,12 @@ int main(int argc, char* const argv[]) {
end = getTimestamp();
elapsed = (float)(NS_TO_S(end) - NS_TO_S(start));
float aIns = ceil(((float)analyticsController->getReadingCtr()) / elapsed);
float aReq = ceil(((float)queryCtr) / elapsed);
float cacheReq = ceil(((float)cachedQueryCtr) / elapsed);
float dbReq = ceil(((float)dbQueryCtr) / elapsed);
float rIns = restAPISettings.enabled ? ceil(((float)httpsServer->getInfluxCounter()) / elapsed) : 0.0f;
float mIns = ceil(((float)readingCtr) / elapsed);
float mMsg = ceil(((float) msgCtr) / elapsed);
LOG(info) << "Performance: MQTT [" << std::fixed << std::setprecision(0) << mIns << " ins/s|" << mMsg << " msg/s] REST [" << rIns << " ins/s] Analytics [" << aIns << " ins/s|" << aReq << " req/s]";
LOG(info) << "Performance: MQTT [" << std::fixed << std::setprecision(0) << mIns << " ins/s|" << mMsg << " msg/s] REST [" << rIns << " ins/s] Analytics [" << aIns << " ins/s] Cache [" << cacheReq << " req/s] DB [" << dbReq << " req/s]";
std::map<std::string, hostInfo_t> lastSeen = ms.collectLastSeen();
uint64_t connectedHosts = 0;
for (auto h: lastSeen) {
......@@ -909,7 +916,8 @@ int main(int argc, char* const argv[]) {
}
LOG(info) << "Connected hosts: " << connectedHosts;
msgCtr = 0;
queryCtr = 0;
cachedQueryCtr = 0;
dbQueryCtr = 0;
readingCtr = 0;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment