Module: check_mk
Branch: master
Commit: 1dae3efa68c2cf94689342bb6b2fa317a0007bf0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1dae3efa68c2cf…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Dec 9 14:37:50 2013 +0100
FIX: Increased performance of multisite GUI with a large userbase
---
.werks/307 | 4 +++-
ChangeLog | 2 +-
web/htdocs/login.py | 10 +++++-----
web/htdocs/userdb.py | 6 ++++++
4 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/.werks/307 b/.werks/307
index 3648423..6cb3aa1 100644
--- a/.werks/307
+++ b/.werks/307
@@ -5,4 +5,6 @@ Version: 1.2.3i8
Date: 1386595064
Class: fix
-
+The processing performance of each multisite page might decrease
+when having a large amount of users. This commit tries to reduce
+the time taken by processing the user information.
diff --git a/ChangeLog b/ChangeLog
index 47582d4..baac9e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,7 +8,7 @@
Multisite:
* 0302 FIX: Fixed highlight of choosen elements in foldertee/views snapin in
Chrome/IE
- * 0307 FIX: Increased performance of multisite GUI with a large userbase
+ * 0307 FIX: Increased performance of multisite GUI with a large userbase...
WATO:
* 0057 FIX: Fix exception in WATO host editor on custom tag without topic...
diff --git a/web/htdocs/login.py b/web/htdocs/login.py
index 5f691c3..c3a06e0 100644
--- a/web/htdocs/login.py
+++ b/web/htdocs/login.py
@@ -67,9 +67,10 @@ def load_secret():
# Load the password serial of the user. This serial identifies the current config
# state of the user account. If either the password is changed or the account gets
# locked the serial is increased and all cookies get invalidated.
-def load_serial(user_id):
- users = userdb.load_users()
- return users.get(user_id, {}).get('serial', 0)
+# Better use the value from the "serials.mk" file, instead of loading the
whole
+# user database via load_users() for performance reasons.
+def load_serial(username):
+ return userdb.load_custom_attr(username, 'serial', saveint, 0)
# Generates the hash to be added into the cookie value
def generate_hash(username, now, serial):
@@ -105,8 +106,7 @@ def check_auth_cookie(cookie_name):
# del_auth_cookie()
# return ''
- users = userdb.load_users().keys()
- if not username in users:
+ if not userdb.user_exists(username):
raise MKAuthException(_('Username is unknown'))
# Validate the hash
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index 7808dc9..43ad80b 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -117,6 +117,12 @@ def create_non_existing_user(connector_id, username):
# Call the sync function for this new user
hook_sync(connector_id = connector_id, only_username = username)
+# FIXME: Can we improve this easily? Would be nice not to have to call
"load_users".
+# Maybe a directory listing of profiles or a list of a small file would perform better
+# than having to load the users, contacts etc. during each http request to multisite
+def user_exists(username):
+ return username in load_users().keys()
+
def user_locked(username):
users = load_users()
return users[username].get('locked', False)