Changeset - f75c6e8a701c
[Not reviewed]
0 3 0
HanzZ - 13 years ago 2012-07-30 07:31:48
hanzz.k@gmail.com
More spectrum2 stats
3 files changed with 20 insertions and 19 deletions:
0 comments (0 inline, 0 general)
include/transport/admininterface.h
Show inline comments
 
@@ -48,6 +48,7 @@ class AdminInterface {
 
		UserManager *m_userManager;
 
		NetworkPluginServer *m_server;
 
		UserRegistration *m_userRegistration;
 
		time_t m_start;
 
};
 

	
 
}
munin/spectrum2_
Show inline comments
 
@@ -105,47 +105,38 @@ if suffix == 'uptime':
 
	vlabel = "days"
 
	info = ''
 
	transformer = lambda value: float(value)/60.0/60.0/24.0
 
elif suffix == 'registered':
 
	stat = { 'users/registered': None }
 
	title = "Registered users"
 
	vlabel = "users"
 
	info = 'Total users that registerd with spectrum transports.'
 
elif suffix == 'backends_count':
 
	stat = { "backends_count": None }
 
	title = "Backends count"
 
	vlabel = "backends"
 
	info = 'Total number of backends.'
 
elif suffix == 'online':
 
	stat = { 'users/online': None }
 
	stat = { 'online_users_count': None }
 
	title = "Online users"
 
	vlabel = "users"
 
	info = 'Number of users that currently use the spectrum transports.'
 
elif suffix == 'contacts_total':
 
	stat = { 'contacts/total': None }
 
	title = "Buddies in roster (total)"
 
	vlabel = "users"
 
	info = 'Total number of contacts that the users that registered with spectrum have.'
 
elif suffix == 'contacts_online':
 
	stat = { 'contacts/online': None }
 
	title = "Buddies online"
 
	vlabel = "users"
 
	info = 'Total number of contacts that are currently online.'
 
elif suffix == 'messages':
 
	stat = { 'messages/in': 'in', 'messages/out': 'out' }
 
	stat = { 'messages_from_xmpp': 'from_xmpp', 'messages_to_xmpp': 'to_xmpp' }
 
	title = "Messages send over transport"
 
	vlabel = "messages"
 
	info = 'Total messages send over spectrum since the last restart.'
 
elif suffix == 'messages_sec':
 
	stat = { 'messages/in': 'in', 'messages/out': 'out' }
 
	stat = { 'messages_from_xmpp': 'from_xmpp', 'messages_to_xmpp': 'to_xmpp' }
 
	title = "Messages send over transport per second"
 
	vlabel = "messages/sec"
 
	info = 'Messages send per second over spectrum transports.'
 
elif suffix == 'memory':
 
	stat = { 'memory-usage': None }
 
	stat = { 'used_memory': None }
 
	title = "Memory usage of transports"
 
	vlabel = "megabytes"
 
	transformer = lambda value: float(value)/1024.0
 
	info = 'Memory usage of spectrum transports.'
 
elif suffix == 'average_memory_per_user':
 
	stat = { 'average_memory_per_user': None }
 
	title = "Average memory usage per user"
 
	vlabel = "kilobytes"
 
	#transformer = lambda value: float(value)/1024.0
 
	info = 'Memory usage of spectrum transports.'
 

	
 
# handle config
 
if len( sys.argv ) > 1 and sys.argv[1] == 'config':
src/admininterface.cpp
Show inline comments
 
@@ -50,6 +50,7 @@ AdminInterface::AdminInterface(Component *component, UserManager *userManager, N
 
	m_userManager = userManager;
 
	m_server = server;
 
	m_userRegistration = userRegistration;
 
	m_start = time(NULL);
 

	
 
	m_component->getStanzaChannel()->onMessageReceived.connect(bind(&AdminInterface::handleMessageReceived, this, _1));
 
}
 
@@ -67,6 +68,9 @@ void AdminInterface::handleQuery(Swift::Message::ref message) {
 
		int backends = m_server->getBackendCount();
 
		message->setBody("Running (" + boost::lexical_cast<std::string>(users) + " users connected using " + boost::lexical_cast<std::string>(backends) + " backends)");
 
	}
 
	else if (message->getBody() == "uptime") {
 
		message->setBody(boost::lexical_cast<std::string>(time(0) - m_start));
 
	}
 
	else if (message->getBody() == "online_users") {
 
		std::string lst;
 
		const std::map<std::string, User *> &users = m_userManager->getUsers();
 
@@ -246,6 +250,9 @@ void AdminInterface::handleQuery(Swift::Message::ref message) {
 
		}
 
		message->setBody(lst);
 
	}
 
	else if (message->getBody() == "crashed_backends_count") {
 
		message->setBody(boost::lexical_cast<std::string>(m_server->getCrashedBackends().size()));
 
	}
 
	else if (message->getBody() == "messages_from_xmpp") {
 
		int msgCount = m_userManager->getMessagesToBackend();
 
		message->setBody(boost::lexical_cast<std::string>(msgCount));
 
@@ -299,6 +306,7 @@ void AdminInterface::handleQuery(Swift::Message::ref message) {
 
		help += "General:\n";
 
		help += "    status - shows instance status\n";
 
		help += "    reload - Reloads config file\n";
 
		help += "    uptime - returns ptime in seconds\n";
 
		help += "Users:\n";
 
		help += "    online_users - returns list of all online users\n";
 
		help += "    online_users_count - number of online users\n";
 
@@ -314,6 +322,7 @@ void AdminInterface::handleQuery(Swift::Message::ref message) {
 
		help += "Backends:\n";
 
		help += "    backends_count - number of active backends\n";
 
		help += "    crashed_backends - returns IDs of crashed backends\n";
 
		help += "    crashed_backends_count - returns number of crashed backends\n";
 
		help += "Memory:\n";
 
		help += "    res_memory - Total RESident memory spectrum2 and its backends use in KB\n";
 
		help += "    shr_memory - Total SHaRed memory spectrum2 backends share together in KB\n";
0 comments (0 inline, 0 general)