Commit 8980ca88 authored by Michael Ott's avatar Michael Ott
Browse files

Add insert rate to CollectAgent statistics

parent 26c1eb85
......@@ -56,6 +56,7 @@ int keepRunning;
bool statistics;
uint64_t msgCtr;
uint64_t pmsgCtr;
uint64_t readingCtr;
DCDB::Connection* dcdbConn;
DCDB::SensorDataStore *mySensorDataStore;
DCDB::SensorConfig *mySensorConfig;
......@@ -208,6 +209,7 @@ int mqttCallback(SimpleMQTTMessage *msg)
mySensorCache.storeSensor(sid, payload[i].timestamp, payload[i].value);
}
mySensorDataStore->insertBatch(readings);
readingCtr+= readings.size();
//mySensorCache.dump();
}
......@@ -457,9 +459,11 @@ int main(int argc, char* const argv[]) {
keepRunning = 1;
timeval start, end;
double elapsed;
LOG(info) << "Collect Agent running...";
msgCtr = 0;
pmsgCtr = 0;
readingCtr = 0;
LOG(info) << "Collect Agent running...";
while(keepRunning) {
gettimeofday(&start, NULL);
sleep(60);
......@@ -469,10 +473,11 @@ int main(int argc, char* const argv[]) {
elapsed += (end.tv_usec - start.tv_usec) / 1000.0;
float publish = msgCtr?(pmsgCtr*100.0)/msgCtr:0;
if (settings.statistics) {
LOG(info) << "Message rate: " << (msgCtr/elapsed)*1000.0 << " messages/second (" << publish << "% PUBLISH)";
LOG(info) << "Performance: " << (readingCtr/elapsed)*1000.0 << " inserts/s, " << (msgCtr/elapsed)*1000.0 << " messages/s (" << publish << "% PUBLISH)";
}
msgCtr = 0;
pmsgCtr = 0;
readingCtr = 0;
}
LOG(info) << "Stopping...";
......
Supports Markdown
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