Module: check_mk
Branch: master
Commit: 7533650a965436b45b3d500ee7e3dfddccae9c76
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7533650a965436…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Aug 9 15:03:39 2013 +0200
Updating user access times on snapin reloads
---
web/htdocs/sidebar.py | 5 ++++-
web/htdocs/userdb.py | 8 ++++++++
web/plugins/config/builtin.py | 2 +-
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/web/htdocs/sidebar.py b/web/htdocs/sidebar.py
index 7710031..670c16d 100644
--- a/web/htdocs/sidebar.py
+++ b/web/htdocs/sidebar.py
@@ -24,7 +24,7 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-import config, defaults, livestatus, views, pprint, os, copy
+import config, defaults, livestatus, views, pprint, os, copy, userdb
from lib import *
# Constants to be used in snapins
@@ -280,6 +280,9 @@ def ajax_openclose():
save_user_config(new_config)
def ajax_snapin():
+ # Update online state of the user (if enabled)
+ userdb.update_user_access_time()
+
snapname = html.var("name")
if snapname:
snapnames = [ snapname ]
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index 965dbc7..3cd01c0 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -121,6 +121,14 @@ def user_locked(username):
users = load_users()
return users[username].get('locked', False)
+def update_user_access_time():
+ if not config.save_user_access_times:
+ return
+
+ users = load_users(lock = True)
+ users[html.user]['last_seen'] = time.time()
+ save_users(users)
+
def on_succeeded_login(username):
users = load_users(lock = True)
changed = False
diff --git a/web/plugins/config/builtin.py b/web/plugins/config/builtin.py
index 7c836f6..8e55c24 100644
--- a/web/plugins/config/builtin.py
+++ b/web/plugins/config/builtin.py
@@ -40,7 +40,7 @@ admin_users = []
guest_users = []
default_user_role = "user"
save_user_access_times = False
-user_online_maxage = 10 # seconds
+user_online_maxage = 30 # seconds
# New style, used by WATO
multisite_users = {}