Now writing duration of queries to log)
Message-ID: <5113ccb8.YRCwIdXQCtWItYQa%lm(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 81b19134b79b40c46dc2aa68fa55d4d0099793bb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=81b19134b79b40…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Feb 7 15:36:02 2013 +0100
Improved debug logging of ldap syncs (Now writing duration of queries to log)
---
ChangeLog | 1 +
web/plugins/userdb/ldap.py | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f136a48..3cdd4a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -43,6 +43,7 @@
* FIX: Preventing autocomplete in password fields of "edit profile" dialog
* The ldap member attribute of groups is now configruable via WATO
* Added option to enforce lower User-IDs during LDAP sync
+ * Improved debug logging of ldap syncs (Now writing duration of queries to log)
BI:
* Use Ajax to delay rendering of invisible parts of the tree (this
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index bb8f4cc..75834d2 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -187,6 +187,7 @@ def ldap_search(base, filt = '(objectclass=*)', columns = [],
scope = None):
scope = ldap.SCOPE_ONELEVEL
ldap_log('LDAP_SEARCH "%s" "%s" "%s"
"%r"' % (base, scope, filt, columns))
+ start_time = time.time()
# Convert all keys to lower case!
result = []
@@ -210,7 +211,8 @@ def ldap_search(base, filt = '(objectclass=*)', columns = [],
scope = None):
'incomplete results. You should change the scope of
operation '
'within the ldap or adapt the limit settings of the
LDAP server.'))
- ldap_log(' RESULT length: %d' % len(result))
+ duration = time.time() - start_time
+ ldap_log(' RESULT length: %d, duration: %0.3f' % (len(result), duration))
return result
#return ldap_connection.search_s(base, scope, filter, columns)
#for dn, obj in ldap_connection.search_s(base, scope, filter, columns):
@@ -596,6 +598,8 @@ def ldap_sync(add_to_changelog, only_username):
g_ldap_user_cache = {}
g_ldap_group_cache = {}
+ start_time = time.time()
+
ldap_connect()
# Unused at the moment, always sync all users
@@ -651,6 +655,9 @@ def ldap_sync(add_to_changelog, only_username):
_("LDAP Connector: Modified user %s (Added: %s, Removed: %s,
Changed: %s)" %
(user_id, ', '.join(added), ', '.join(removed),
', '.join(changed))))
+ duration = time.time() - start_time
+ ldap_log('SYNC FINISHED - Duration: %0.3f sec' % duration)
+
save_users(users)
# Calculates the attributes of the users which are locked for users managed