From 1f380f050417c247e40f2f29d14d6c1fbd80360e Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Wed, 17 Nov 2010 13:52:32 +0200 Subject: [PATCH] web-services: new "get_sqlcount" call Useful for automated statistics, returns the global SQL counter of queries. It does not affect any counters, and will print a warning if debug_sql is not enabled (counter would be zero, then). bzr revid: p_christ@hol.gr-20101117115232-olq747j4vmauqgy8 --- bin/service/web_services.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/service/web_services.py b/bin/service/web_services.py index 7054be9597e..0af15691bea 100644 --- a/bin/service/web_services.py +++ b/bin/service/web_services.py @@ -36,6 +36,7 @@ import release import sql_db import tools import locale +import logging from cStringIO import StringIO class db(netsvc.ExportService): @@ -385,7 +386,7 @@ class common(_ObjectService): 'login_message','get_stats', 'check_connectivity', 'list_http_services']: pass - elif method in ['get_available_updates', 'get_migration_scripts', 'set_loglevel', 'get_os_time']: + elif method in ['get_available_updates', 'get_migration_scripts', 'set_loglevel', 'get_os_time', 'get_sqlcount']: passwd = params[0] params = params[1:] security.check_super(passwd) @@ -571,6 +572,12 @@ GNU Public Licence. def exp_get_os_time(self): return os.times() + def exp_get_sqlcount(self): + logger = logging.getLogger('db.cursor') + if not logger.isEnabledFor(logging.DEBUG_SQL): + logger.warning("Counters of SQL will not be reliable unless DEBUG_SQL is set at the server's config.") + return sql_db.sql_counter + common() class objects_proxy(netsvc.ExportService):