Module: check_mk
Branch: master
Commit: acf970ba2ef742cd12f0a7f089fb2cc7c3cf11f3
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=acf970ba2ef742…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Dec 18 12:35:05 2012 +0100
Output better error message in case of old inventory function
---
ChangeLog | 1 +
modules/check_mk.py | 16 ++++++----------
2 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0964dc2..5c79d77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
exception to status output and traceback to long output now.
* Added HOSTTAGS to notification macros which contains all Check_MK-Tags
separated by spaces
+ * Output better error message in case of old inventory function
Notifications:
* Fix flexible notifications on non-OMD systems
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 8eeb594..4429a6c 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -27,7 +27,7 @@
# This file is also read in by check_mk's web pages. In that case,
# the variable check_mk_web is set to True
-import os, sys, socket, time, getopt, glob, re, stat, py_compile, urllib
+import os, sys, socket, time, getopt, glob, re, stat, py_compile, urllib, inspect
# These variable will be substituted at 'make dist' time
check_mk_version = '(inofficial)'
@@ -2275,16 +2275,12 @@ def make_inventory(checkname, hostnamelist, check_only=False, include_state=Fals
if info == None: # No data for this check type
continue
try:
- # New preferred style since 1.1.11i3: only one argument: info
- try:
+ # Check number of arguments of inventory function
+ if len(inspect.getargspec(inventory_function)[0]) == 2:
+ inventory = inventory_function(checkname, info) # inventory is a list of pairs (item, current_value)
+ else:
+ # New preferred style since 1.1.11i3: only one argument: info
inventory = inventory_function(info)
- except Exception, e:
- # failed? Lets try pre-1.1.11i3 style inventory function
- try:
- inventory = inventory_function(checkname, info) # inventory is a list of pairs (item, current_value)
- except Exception, ee:
- # Let the first exception happen again
- inventory_function(info)
if inventory == None: # tolerate if function does no explicit return
inventory = []
Module: check_mk
Branch: master
Commit: bffd95d061f3e43447c7cc66338f6c6e49356797
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bffd95d061f3e4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Dec 14 14:11:35 2012 +0100
ldap: Fixed locking problem in page sync hook
---
checkman/uptime | 2 +-
web/htdocs/userdb.py | 2 ++
web/plugins/userdb/ldap.py | 10 ++++++----
3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/checkman/uptime b/checkman/uptime
index 914133f..2fa4d95 100644
--- a/checkman/uptime
+++ b/checkman/uptime
@@ -12,5 +12,5 @@ perfdata:
The uptime in seconds.
inventory:
- One check per system is created if the agent has a action {<<<uptime>>>}.
+ One check per system is created if the agent has a section {<<<uptime>>>}.
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index 51ca6b6..3533ff5 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -264,6 +264,8 @@ def split_dict(d, keylist, positive):
def save_users(profiles):
custom_values = user_attributes.keys()
+ file('/tmp/a', 'a').write('%d saving users (%s %r)\n' % (time.time(), html.req.myfile, html.req.vars))
+
# Keys not to put into contact definitions for Check_MK
non_contact_keys = [
"roles",
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index cf44790..44d8b6b 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -524,6 +524,10 @@ def ldap_login(username, password):
return result
def ldap_sync(add_to_changelog, only_username):
+ # Store time of the last sync. Don't store after sync since parallel
+ # requests to e.g. the page hook would cause duplicate calculations
+ file(g_ldap_sync_time_file, 'w').write('%s\n' % time.time())
+
ldap_connect()
# Unused at the moment, always sync all users
@@ -572,7 +576,8 @@ def ldap_sync(add_to_changelog, only_username):
users[user_id] = user # Update the user record
if mode_create:
- wato.log_pending(wato.SYNCRESTART, None, "edit-users", _("LDAP Connector: Created user %s" % user_id))
+ wato.log_pending(wato.SYNCRESTART, None, "edit-users",
+ _("LDAP Connector: Created user %s" % user_id))
else:
wato.log_pending(wato.SYNCRESTART, None, "edit-users",
_("LDAP Connector: Modified user %s (Added: %s, Removed: %s, Changed: %s)" %
@@ -580,9 +585,6 @@ def ldap_sync(add_to_changelog, only_username):
save_users(users)
- # Store time of the last sync
- file(g_ldap_sync_time_file, 'w').write('%s\n' % time.time())
-
# Calculates the attributes of the users which are locked for users managed
# by this connector
def ldap_locked_attributes():