Commit cd429cb76b0824ce33ea6e4470c4742dfb2619f3
1 parent
ff7c078a
Publish session count on $SYS
Showing
3 changed files
with
8 additions
and
0 deletions
subscriptionstore.cpp
| @@ -523,6 +523,11 @@ int64_t SubscriptionStore::getRetainedMessageCount() const | @@ -523,6 +523,11 @@ int64_t SubscriptionStore::getRetainedMessageCount() const | ||
| 523 | return retainedMessageCount; | 523 | return retainedMessageCount; |
| 524 | } | 524 | } |
| 525 | 525 | ||
| 526 | +uint64_t SubscriptionStore::getSessionCount() const | ||
| 527 | +{ | ||
| 528 | + return sessionsByIdConst.size(); | ||
| 529 | +} | ||
| 530 | + | ||
| 526 | void SubscriptionStore::getRetainedMessages(RetainedMessageNode *this_node, std::vector<RetainedMessage> &outputList) const | 531 | void SubscriptionStore::getRetainedMessages(RetainedMessageNode *this_node, std::vector<RetainedMessage> &outputList) const |
| 527 | { | 532 | { |
| 528 | for(const RetainedMessage &rm : this_node->retainedMessages) | 533 | for(const RetainedMessage &rm : this_node->retainedMessages) |
subscriptionstore.h
| @@ -121,6 +121,7 @@ public: | @@ -121,6 +121,7 @@ public: | ||
| 121 | void removeExpiredSessionsClients(int expireSessionsAfterSeconds); | 121 | void removeExpiredSessionsClients(int expireSessionsAfterSeconds); |
| 122 | 122 | ||
| 123 | int64_t getRetainedMessageCount() const; | 123 | int64_t getRetainedMessageCount() const; |
| 124 | + uint64_t getSessionCount() const; | ||
| 124 | 125 | ||
| 125 | void saveRetainedMessages(const std::string &filePath); | 126 | void saveRetainedMessages(const std::string &filePath); |
| 126 | void loadRetainedMessages(const std::string &filePath); | 127 | void loadRetainedMessages(const std::string &filePath); |
threaddata.cpp
| @@ -117,6 +117,8 @@ void ThreadData::publishStatsOnDollarTopic(std::vector<std::shared_ptr<ThreadDat | @@ -117,6 +117,8 @@ void ThreadData::publishStatsOnDollarTopic(std::vector<std::shared_ptr<ThreadDat | ||
| 117 | publishStat("$SYS/broker/load/messages/sent/persecond", sentMessageCountPerSecond); | 117 | publishStat("$SYS/broker/load/messages/sent/persecond", sentMessageCountPerSecond); |
| 118 | 118 | ||
| 119 | publishStat("$SYS/broker/retained messages/count", subscriptionStore->getRetainedMessageCount()); | 119 | publishStat("$SYS/broker/retained messages/count", subscriptionStore->getRetainedMessageCount()); |
| 120 | + | ||
| 121 | + publishStat("$SYS/broker/sessions/total", subscriptionStore->getSessionCount()); | ||
| 120 | } | 122 | } |
| 121 | 123 | ||
| 122 | void ThreadData::publishStat(const std::string &topic, uint64_t n) | 124 | void ThreadData::publishStat(const std::string &topic, uint64_t n) |