Commit 99d31977 authored by Alessio Netti's avatar Alessio Netti
Browse files

Changes to statistics MQTT suffixes

parent b9a68de8
......@@ -953,10 +953,10 @@ int main(int argc, char* const argv[]) {
if (settings.statisticsMqttPart.size() > 0) {
std::string statisticsMqttTopic = pluginSettings.mqttPrefix + settings.statisticsMqttPart;
std::list<SensorDataStoreReading> stats;
stats.push_back(SensorDataStoreReading(SensorId(statisticsMqttTopic+"/msgs"), end, msgCtr));
stats.push_back(SensorDataStoreReading(SensorId(statisticsMqttTopic+"/msgsRcvd"), end, msgCtr));
stats.push_back(SensorDataStoreReading(SensorId(statisticsMqttTopic+"/cachedQueries"), end, cachedQueryCtr));
stats.push_back(SensorDataStoreReading(SensorId(statisticsMqttTopic+"/dbQueries"), end, dbQueryCtr));
stats.push_back(SensorDataStoreReading(SensorId(statisticsMqttTopic+"/readings"), end, readingCtr));
stats.push_back(SensorDataStoreReading(SensorId(statisticsMqttTopic+"/readingsRcvd"), end, readingCtr));
stats.push_back(SensorDataStoreReading(SensorId(statisticsMqttTopic+"/hosts"), end, connectedHosts));
for (auto s: stats) {
mySensorDataStore->insert(s);
......
......@@ -211,9 +211,9 @@ void MQTTPusher::push() {
if (_statisticsMqttTopic.size() != 0) {
reading_t r = { (int64_t) msgCtr, ts };
int rc = MOSQ_ERR_SUCCESS;
rc+= mosquitto_publish(_mosq, NULL, std::string(_statisticsMqttTopic+"/msgs").c_str(), sizeof(reading_t), &r, _qosLevel, false);
rc+= mosquitto_publish(_mosq, NULL, std::string(_statisticsMqttTopic+"/msgsSent").c_str(), sizeof(reading_t), &r, _qosLevel, false);
r = { (int64_t) readingCtr, ts };
rc+= mosquitto_publish(_mosq, NULL, std::string(_statisticsMqttTopic+"/readings").c_str(), sizeof(reading_t), &r, _qosLevel, false);
rc+= mosquitto_publish(_mosq, NULL, std::string(_statisticsMqttTopic+"/readingsSent").c_str(), sizeof(reading_t), &r, _qosLevel, false);
if (rc != MOSQ_ERR_SUCCESS) {
LOGM(info) << "Error sending statistics via MQTT: " << mosquitto_strerror(rc);
_connected = false;
......
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