From cd429cb76b0824ce33ea6e4470c4742dfb2619f3 Mon Sep 17 00:00:00 2001 From: Wiebe Cazemier Date: Sun, 5 Sep 2021 21:22:42 +0200 Subject: [PATCH] Publish session count on $SYS --- subscriptionstore.cpp | 5 +++++ subscriptionstore.h | 1 + threaddata.cpp | 2 ++ 3 files changed, 8 insertions(+), 0 deletions(-) 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) -- libgit2 0.21.4