Module: check_mk
Branch: master
Commit: 6f3e9f310233aaa012dc3ccd52da20ec164cfa27
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6f3e9f310233aa…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Aug 9 15:15:57 2013 +0200
Saving last seen time in own userfile
---
web/htdocs/userdb.py | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index 3cd01c0..d66c75c 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -294,10 +294,11 @@ def load_users(lock = False):
if d[0] != '.':
id = d
- # read failed login counts
- failed_file = dir + d + '/num_failed.mk'
- if id in result and os.path.exists(failed_file):
- result[id]['num_failed'] = int(file(failed_file).read().strip())
+ # read special values from own files
+ for val, conv_func in [ ('num_failed', int), ('last_seen',
float) ]:
+ path = dir + d + '/' + val + '.mk'
+ if id in result and os.path.exists(path):
+ result[id][val] = conv_func(file(path).read().strip())
# read automation secrets and add them to existing
# users or create new users automatically
@@ -342,7 +343,6 @@ def save_users(profiles):
"alias",
"language",
"connector",
- "last_seen",
] + custom_values
# Remove multisite keys in contacts.
@@ -405,6 +405,11 @@ def save_users(profiles):
failed_file = user_dir + '/num_failed.mk'
create_user_file(failed_file, 'w').write('%d\n' %
user.get('num_failed', 0))
+ # Write out the last seent time
+ if 'last_seen' in user:
+ last_seen_file = user_dir + '/last_seen.mk'
+ create_user_file(last_seen_file,
'w').write(repr(user['last_seen']) + '\n')
+
# Remove settings directories of non-existant users.
# Beware: we removed this since it leads to violent destructions
# if the user database is out of the scope of Check_MK. This is