Module: check_mk
Branch: master
Commit: 04c399c1431431b26907191825c30e41a02b29a9
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=04c399c1431431…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jul 29 09:51:39 2011 +0200
WATO: add helper function for checking ip address
---
web/htdocs/wato.py | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index a1ea3ab..be5b457 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -2566,6 +2566,18 @@ class IPAddressAttribute(TextAttribute):
return value.lower().startswith(crit.lower().strip("*"))
+# Helper function for checking if an ip address is valid
+def is_valid_ip_address(ip):
+ try:
+ parts = ip.split('.')
+ if len(parts) != 4:
+ raise Exception()
+ for x in parts:
+ if int(x) < 0 or int(x) > 255:
+ raise Exception()
+ except:
+ return False
+ return True
# A text attribute that is stored in a Nagios custom macro
class NagiosTextAttribute(TextAttribute):
Module: check_mk
Branch: master
Commit: 34d07a9a24586e7993c36a9fed9cdee62c666efe
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=34d07a9a24586e…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Jul 27 18:40:33 2011 +0200
WATO: fix permsissions bug in i18n
---
web/htdocs/config.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/web/htdocs/config.py b/web/htdocs/config.py
index e9a2c83..997c2b4 100644
--- a/web/htdocs/config.py
+++ b/web/htdocs/config.py
@@ -262,7 +262,7 @@ def role_of_user(u):
def may(permname):
# handle case where declare_permission is done after login
# and permname also not contained in save configuration
- if permname not in permissions:
+ if permname not in user_permissions:
perm = permissions_by_name.get(permname)
if not perm: # Object does not exists, e.g. sidesnap.multisite if not is_multisite()
return False
Module: check_mk
Branch: master
Commit: ce28d8b1134fd410ec3294835abb27ca96650f70
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ce28d8b1134fd4…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Jul 27 18:40:10 2011 +0200
Add debug code for Multisite
---
web/htdocs/config.py | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/web/htdocs/config.py b/web/htdocs/config.py
index b65111f..e9a2c83 100644
--- a/web/htdocs/config.py
+++ b/web/htdocs/config.py
@@ -24,6 +24,16 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+# The following debug code can be used to tackle a mod_python
+# problem when using the local hierarchy for plugins that refer
+# to the config module.
+# import time, os
+# fn = "/tmp/config.load.%d" % os.getpid()
+# if os.path.exists(fn):
+# raise Exception("Mist: config zweimal geladen!!")
+#
+# file(fn, "a").write("[%d] Geladen: %s\n" % (os.getpid(), time.time()))
+
import os, pprint, glob
from lib import *
import defaults
Module: check_mk
Branch: master
Commit: 3fbfeaafc0322b646e610411d1e23d3fdcdf26d7
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3fbfeaafc0322b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Jul 26 14:21:18 2011 +0200
WATO API: handle special return code False
---
web/htdocs/wato.py | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 5c446b0..5afddd5 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -114,8 +114,15 @@ def page_handler():
else:
newmode = result
+ # If newmode is False, then we shall immediately abort.
+ # This is e.g. the case, if the page outputted non-HTML
+ # data, such as a tarball (in the export function). We must
+ # be sure not to output *any* further data in that case.
+ if newmode == False:
+ return
+
# if newmode is not None, then the mode has been changed
- if newmode != None:
+ elif newmode != None:
if newmode == "": # no further information: configuration dialog, etc.
if action_message:
html.message(action_message)
Module: check_mk
Branch: master
Commit: 8371d05c551c8fa51111c7b442a7af97a93e381c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8371d05c551c8f…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Jul 26 16:08:02 2011 +0200
WATO: FIX: add host tags to effective attributes
---
web/htdocs/wato.py | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 5afddd5..cd37e8a 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -2645,6 +2645,8 @@ def declare_host_tag_attributes():
if configured_host_tags != config.host_tags:
# Remove host tag attributes from list, if existing
host_attributes = [ attr for attr in host_attributes if not attr.name().startswith("tag_") ]
+
+ # Also remove those attributes from the speed-up dictionary host_attribute
for attr in host_attribute.values():
if attr.name().startswith("tag_"):
del host_attribute[attr.name()]
@@ -2972,13 +2974,15 @@ class API:
# Get all effective data of a host. The_file must be returned by get_file()
def get_host(self, the_file, hostname):
+ declare_host_tag_attributes()
host = the_file["hosts"][hostname]
eff = effective_attributes(host, the_file)
eff["name"] = hostname
return eff
- # Return displayable information about host
+ # Return displayable information about host (call with with result vom get_host())
def get_host_painted(self, host):
+ declare_host_tag_attributes()
result = []
for attr in host_attributes:
attrname = attr.name()
Module: check_mk
Branch: master
Commit: 9a266f88d2a0c7aa742c424bc0c2607245e40876
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9a266f88d2a0c7…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jul 26 09:13:40 2011 +0200
Added some preflight checks to --scan-parents code to prevent strange behaviour
---
.bugs/189 | 16 ++++++++++++++++
.bugs/190 | 16 ++++++++++++++++
.bugs/191 | 12 ++++++++++++
ChangeLog | 1 +
modules/check_mk.py | 21 +++++++++++++++++++--
5 files changed, 64 insertions(+), 2 deletions(-)
diff --git a/.bugs/189 b/.bugs/189
new file mode 100644
index 0000000..dd7b21a
--- /dev/null
+++ b/.bugs/189
@@ -0,0 +1,16 @@
+Title: scan parents overwrites parents.mk which has not been created by scan
+Component: core
+State: done
+Class: nastiness
+Date: 2011-07-25 15:57:55
+Benefit: 3
+Cost: 3
+Fun: 0
+
+Scanparents function should check if the parents.mk has been created by the
+scanparents code and only overwrite the file if it veriified that the
+overwriting the file would not overwrite manually configured parents.mk files
+
+2011-07-26 08:48:27: changed state open -> done
+Checking the first line of the file for the "automatically created by --scan-parents" string
+and terminate when this can not be found.
diff --git a/.bugs/190 b/.bugs/190
new file mode 100644
index 0000000..2370a0f
--- /dev/null
+++ b/.bugs/190
@@ -0,0 +1,16 @@
+Title: scan parent should terminate when no traceroute bin in path
+Component: core
+State: done
+Class: cleanup
+Date: 2011-07-25 15:59:55
+Benefit: 2
+Cost: 2
+Fun: 0
+
+At the moment scanparents executes traceroute for each host and
+shows up an error sh: traceroute: command not found
+
+This should be checked once at the start and show up an error.
+
+2011-07-26 08:49:03: changed state open -> done
+Added preflight check to verify that traceroute is installed
diff --git a/.bugs/191 b/.bugs/191
new file mode 100644
index 0000000..d13d832
--- /dev/null
+++ b/.bugs/191
@@ -0,0 +1,12 @@
+Title: scan parents: documentation about output missing
+Component: doku
+Benefit: 3
+State: open
+Cost: 3
+Date: 2011-07-25 16:08:41
+Class: todo
+
+There is no documentation about the meanings of the output of the scan parents
+feature.
+
+The single chars like o, L, G aare not mentioned in the docs.
diff --git a/ChangeLog b/ChangeLog
index 0fd749d..e9d34c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -29,6 +29,7 @@
* j4p_performance agent plugin: Supports basic/digest auth now
* New checks j4p_performance.threads and j4p_performance.uptime which
track the number of threads and the uptime of a JMX process
+ * Added some preflight checks to --scan-parents code
Multisite:
* FIX: make non-Ascii characters in services names work again
diff --git a/modules/check_mk.py b/modules/check_mk.py
index d023305..3a5b468 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -3369,6 +3369,12 @@ def do_cleanup_autochecks():
sys.stdout.write("Deleting %s\n" % f)
os.remove(f)
+def check_bin_in_path(prog):
+ for path in os.environ['PATH'].split(os.pathsep):
+ f = path + '/' + prog
+ if os.path.exists(f) and os.access(f, os.X_OK):
+ return True
+
def do_scan_parents(hosts):
global max_num_processes
if len(hosts) == 0:
@@ -3383,6 +3389,19 @@ def do_scan_parents(hosts):
if max_num_processes < 1:
max_num_processes = 1
+ outfilename = check_mk_configdir + "/parents.mk"
+
+ if not check_bin_in_path('traceroute'):
+ raise MKGeneralException('The traceroute command can not be found in PATH?')
+
+ if os.path.exists(outfilename):
+ first_line = file(outfilename, "r").readline()
+ if not first_line.startswith('# Automatically created by --scan-parents at'):
+ raise MKGeneralException("conf.d/parents.mk seems to be created manually.\n\n"
+ "The --scan-parents function would overwrite this file.\n"
+ "Please rename it to keep the configuration or delete "
+ "the file and try again.")
+
sys.stdout.write("Scanning for parents (%d processes)..." % max_num_processes)
sys.stdout.flush()
while len(hosts) > 0:
@@ -3416,7 +3435,6 @@ def do_scan_parents(hosts):
parent_rules.append( (monitoring_host, [host]) )
import pprint
- outfilename = check_mk_configdir + "/parents.mk"
out = file(outfilename, "w")
out.write("# Automatically created by --scan-parents at %s\n\n" % time.asctime())
out.write("# Do not edit this file. If you want to convert an\n")
@@ -3433,7 +3451,6 @@ def do_scan_parents(hosts):
out.write("parents += %s\n\n" % pprint.pformat(parent_rules))
sys.stdout.write("\nWrote %s\n" % outfilename)
-
def scan_parents_of(hosts):
nagios_ip = lookup_ipaddress(monitoring_host)
os.putenv("LANG", "")