diff --git a/subscriptionstore.cpp b/subscriptionstore.cpp index 1e7f676..6f62d4b 100644 --- a/subscriptionstore.cpp +++ b/subscriptionstore.cpp @@ -523,6 +523,11 @@ int64_t SubscriptionStore::getRetainedMessageCount() const return retainedMessageCount; } +uint64_t SubscriptionStore::getSessionCount() const +{ + return sessionsByIdConst.size(); +} + void SubscriptionStore::getRetainedMessages(RetainedMessageNode *this_node, std::vector &outputList) const { for(const RetainedMessage &rm : this_node->retainedMessages) diff --git a/subscriptionstore.h b/subscriptionstore.h index 078aad5..aa5e63f 100644 --- a/subscriptionstore.h +++ b/subscriptionstore.h @@ -121,6 +121,7 @@ public: void removeExpiredSessionsClients(int expireSessionsAfterSeconds); int64_t getRetainedMessageCount() const; + uint64_t getSessionCount() const; void saveRetainedMessages(const std::string &filePath); void loadRetainedMessages(const std::string &filePath); diff --git a/threaddata.cpp b/threaddata.cpp index db615de..d380b58 100644 --- a/threaddata.cpp +++ b/threaddata.cpp @@ -117,6 +117,8 @@ void ThreadData::publishStatsOnDollarTopic(std::vectorgetRetainedMessageCount()); + + publishStat("$SYS/broker/sessions/total", subscriptionStore->getSessionCount()); } void ThreadData::publishStat(const std::string &topic, uint64_t n)