Commit 59c4ae03 authored by Michael Ott's avatar Michael Ott
Browse files

Add connected hosts to statistics

parent 09ef42d7
......@@ -843,22 +843,22 @@ int main(int argc, char* const argv[]) {
* Run (hopefully) forever...
*/
keepRunning = 1;
timeval start, end;
uint64_t start, end;
double elapsed;
msgCtr = 0;
pmsgCtr = 0;
readingCtr = 0;
gettimeofday(&start, NULL);
uint64_t lastCleanup = start.tv_sec;
start = getTimestamp();
uint64_t lastCleanup = start;
uint64_t sleepInterval = (settings.statisticsInterval > 0) ? settings.statisticsInterval : 60;
LOG(info) << "Collect Agent running...";
while(keepRunning) {
gettimeofday(&start, NULL);
if(start.tv_sec - lastCleanup > settings.cleaningInterval) {
uint64_t purged = mySensorCache.clean(settings.cleaningInterval * 1000000000);
lastCleanup = start.tv_sec;
start = getTimestamp();
if(NS_TO_S(start - lastCleanup) > settings.cleaningInterval) {
uint64_t purged = mySensorCache.clean(S_TO_NS(settings.cleaningInterval));
lastCleanup = start;
if(purged > 0)
LOG(info) << "Cache: purged " << purged << " obsolete entries";
}
......@@ -867,12 +867,19 @@ int main(int argc, char* const argv[]) {
if((settings.statisticsInterval > 0) && keepRunning) {
/* not really thread safe but will do the job */
gettimeofday(&end, NULL);
elapsed = (end.tv_sec - start.tv_sec) * 1000.0;
elapsed += (end.tv_usec - start.tv_usec) / 1000.0;
end = getTimestamp();
elapsed = NS_TO_S(((double) end - (double) start));
float publish = msgCtr?(pmsgCtr*100.0)/msgCtr:0;
LOG(info) << "Performance: " << (readingCtr/elapsed)*1000.0 << " inserts/s, " << (msgCtr/elapsed)*1000.0 << " messages/s (" << publish << "% PUBLISH)";
LOG(info) << "Analytics Performance: " << (analyticsController->getReadingCtr()/elapsed)*1000.0 << " inserts/s ";
std::map<std::string, hostInfo_t> lastSeen = ms.collectLastSeen();
uint64_t connectedHosts = 0;
for (auto h: lastSeen) {
if (h.second.lastSeen >= end - S_TO_NS(settings.statisticsInterval)) {
connectedHosts++;
}
}
LOG(info) << "Connected hosts: " << connectedHosts;
msgCtr = 0;
pmsgCtr = 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