Server: get_stats() RPC call for any extended info.

With this call, we can learn about the internals of the OpenObject server
in runtime.
At the moment, designed to give info on the running servers (RPC).

bzr revid: p_christ@hol.gr-20091028003033-b5hzgcjy9kncyc0d
This commit is contained in:
P. Christeas 2009-10-28 02:30:33 +02:00
parent cac0ce70e4
commit 879199c6b7
2 changed files with 24 additions and 1 deletions

View File

@ -312,6 +312,10 @@ class Server:
print "called stub Server.stop"
pass
def stats(self):
""" This function should return statistics about the server """
return "%s: No statistics" % str(self.__class__)
@classmethod
def startAll(cls):
if cls.__is_started:
@ -332,6 +336,19 @@ class Server:
srv.stop()
cls.__is_started = False
@classmethod
def allStats(cls):
res = ''
if cls.__is_started:
res += "Servers started\n"
else:
res += "Servers stopped\n"
for srv in cls.__servers:
try:
res += srv.stats() + "\n"
except:
pass
return res
class OpenERPDispatcherException(Exception):
def __init__(self, exception, traceback):

View File

@ -395,7 +395,7 @@ class common(_ObjectService):
auth.logout(params[1])
logger.notifyChannel("web-service", netsvc.LOG_INFO,'Logout %s from database %s'%(login,db))
return True
elif method in ['about', 'timezone_get', 'get_server_environment', 'login_message']:
elif method in ['about', 'timezone_get', 'get_server_environment', 'login_message', 'get_stats' ]:
pass
elif method in ['get_available_updates', 'get_migration_scripts', 'set_loglevel']:
passwd = params[0]
@ -569,6 +569,12 @@ GNU Public Licence.
l.set_loglevel(int(loglevel))
return True
def exp_get_stats(self):
import threading
res = "OpenERP server: %d threads\n" % threading.active_count()
res += netsvc.Server.allStats()
return res
common()
class objects_proxy(netsvc.ExportService):