More stats
This commit is contained in:
parent
6ec566375c
commit
d4769080ca
5 changed files with 35 additions and 3 deletions
|
@ -71,6 +71,10 @@ class NetworkPluginServer {
|
|||
return m_clients;
|
||||
}
|
||||
|
||||
const std::vector<std::string> &getCrashedBackends() {
|
||||
return m_crashedBackends;
|
||||
}
|
||||
|
||||
void collectBackend();
|
||||
|
||||
bool moveToLongRunBackend(User *user);
|
||||
|
@ -138,6 +142,7 @@ class NetworkPluginServer {
|
|||
bool m_isNextLongRun;
|
||||
std::map<unsigned long, FileTransferManager::Transfer> m_filetransfers;
|
||||
FileTransferManager *m_ftManager;
|
||||
std::vector<std::string> m_crashedBackends;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -116,6 +116,13 @@ class UserManager : public Swift::EntityCapsProvider {
|
|||
/// \param user JID of user.
|
||||
void disconnectUser(const Swift::JID &user);
|
||||
|
||||
void messageToXMPPSent() { m_sentToXMPP++; }
|
||||
void messageToBackendSent() { m_sentToBackend++; }
|
||||
|
||||
unsigned long getMessagesToXMPP() { return m_sentToXMPP; }
|
||||
unsigned long getMessagesToBackend() { return m_sentToBackend; }
|
||||
|
||||
|
||||
private:
|
||||
void handlePresence(Swift::Presence::ref presence);
|
||||
void handleMessageReceived(Swift::Message::ref message);
|
||||
|
@ -134,6 +141,8 @@ class UserManager : public Swift::EntityCapsProvider {
|
|||
StorageResponder *m_storageResponder;
|
||||
UserRegistry *m_userRegistry;
|
||||
Swift::Timer::ref m_removeTimer;
|
||||
unsigned long m_sentToXMPP;
|
||||
unsigned long m_sentToBackend;
|
||||
friend class RosterResponder;
|
||||
};
|
||||
|
||||
|
|
|
@ -351,6 +351,10 @@ void NetworkPluginServer::handleSessionFinished(Backend *c) {
|
|||
|
||||
// If there are users associated with this backend, it must have crashed, so print error output
|
||||
// and disconnect users
|
||||
if (!c->users.empty()) {
|
||||
m_crashedBackends.push_back(c->id);
|
||||
}
|
||||
|
||||
for (std::list<User *>::const_iterator it = c->users.begin(); it != c->users.end(); it++) {
|
||||
LOG4CXX_ERROR(logger, "Backend " << c << " disconnected (probably crashed) with active user " << (*it)->getJID().toString());
|
||||
(*it)->setData(NULL);
|
||||
|
|
|
@ -81,7 +81,10 @@ bool StatsResponder::handleGetRequest(const Swift::JID& from, const Swift::JID&
|
|||
response->addItem(StatsPayload::Item("users/online"));
|
||||
response->addItem(StatsPayload::Item("contacts/online"));
|
||||
response->addItem(StatsPayload::Item("contacts/total"));
|
||||
response->addItem(StatsPayload::Item("backends"));
|
||||
response->addItem(StatsPayload::Item("messages/from-xmpp"));
|
||||
response->addItem(StatsPayload::Item("messages/to-xmpp"));
|
||||
response->addItem(StatsPayload::Item("backends/running"));
|
||||
response->addItem(StatsPayload::Item("backends/crashed"));
|
||||
response->addItem(StatsPayload::Item("memory-usage"));
|
||||
}
|
||||
else {
|
||||
|
@ -115,8 +118,11 @@ bool StatsResponder::handleGetRequest(const Swift::JID& from, const Swift::JID&
|
|||
else if (item.getName() == "users/online") {
|
||||
response->addItem(StatsPayload::Item("users/online", "users", boost::lexical_cast<std::string>(m_userManager->getUserCount())));
|
||||
}
|
||||
else if (item.getName() == "backends") {
|
||||
response->addItem(StatsPayload::Item("backends", "backends", boost::lexical_cast<std::string>(m_server->getBackendCount())));
|
||||
else if (item.getName() == "backends/running") {
|
||||
response->addItem(StatsPayload::Item("backends/running", "backends", boost::lexical_cast<std::string>(m_server->getBackendCount())));
|
||||
}
|
||||
else if (item.getName() == "backends/crashed") {
|
||||
response->addItem(StatsPayload::Item("backends/crashed", "backends", boost::lexical_cast<std::string>(m_server->getCrashedBackends().size())));
|
||||
}
|
||||
else if (item.getName() == "memory-usage") {
|
||||
response->addItem(StatsPayload::Item("memory-usage", "KB", boost::lexical_cast<std::string>(usedMemory())));
|
||||
|
@ -127,6 +133,12 @@ bool StatsResponder::handleGetRequest(const Swift::JID& from, const Swift::JID&
|
|||
else if (item.getName() == "contacts/total") {
|
||||
response->addItem(StatsPayload::Item("contacts/total", "contacts", boost::lexical_cast<std::string>(contactsTotal)));
|
||||
}
|
||||
else if (item.getName() == "messages/from-xmpp") {
|
||||
response->addItem(StatsPayload::Item("messages/from-xmpp", "messages", boost::lexical_cast<std::string>(m_userManager->getMessagesToBackend())));
|
||||
}
|
||||
else if (item.getName() == "messages/to-xmpp") {
|
||||
response->addItem(StatsPayload::Item("messages/to-xmpp", "messages", boost::lexical_cast<std::string>(m_userManager->getMessagesToXMPP())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,8 @@ static LoggerPtr logger = Logger::getLogger("UserManager");
|
|||
UserManager::UserManager(Component *component, UserRegistry *userRegistry, StorageBackend *storageBackend) {
|
||||
m_cachedUser = NULL;
|
||||
m_onlineBuddies = 0;
|
||||
m_sentToXMPP = 0;
|
||||
m_sentToBackend = 0;
|
||||
m_component = component;
|
||||
m_storageBackend = storageBackend;
|
||||
m_storageResponder = NULL;
|
||||
|
|
Loading…
Add table
Reference in a new issue