Module: check_mk
Branch: master
Commit: 38ea39e5bf66507fe004d2b77b81f658614761d5
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=38ea39e5bf6650…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Nov 20 10:03:31 2013 +0100
Supporting float values as SNMP timeout value now
In some cases it is useful to define a more specific value than
full seconds. So WATO accepts float values for the timeout now.
---
.werks/216 | 9 +++++++++
ChangeLog | 1 +
modules/check_mk.py | 2 +-
web/plugins/wato/check_mk_configuration.py | 5 +++--
4 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/.werks/216 b/.werks/216
new file mode 100644
index 0000000..63e6059
--- /dev/null
+++ b/.werks/216
@@ -0,0 +1,9 @@
+Title: Supporting float values as SNMP timeout value now
+Level: 1
+Component: wato
+Version: 1.2.3i7
+Date: 1384938098
+Class: feature
+
+In some cases it is useful to define a more specific value than
+full seconds. So WATO accepts float values for the timeout now.
diff --git a/ChangeLog b/ChangeLog
index 466a33b..6439fe9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -42,6 +42,7 @@
WATO:
* 0053 New rule for configuring the display_name of a service...
+ * 0216 Supporting float values as SNMP timeout value now...
* 0048 FIX: Fixed locking issue on host diagnose page
* 0033 FIX: WATO forms: incorrect handling of checkbox state
* 0205 FIX: Allowing star chars in variable names to fix role/permission editing...
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 06bca4a..91af074 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -745,7 +745,7 @@ def snmp_base_command(what, hostname):
# Configuration of timing and retries
settings = snmp_timing_of(hostname)
if "timeout" in settings:
- options += " -t %d" % settings["timeout"]
+ options += " -t %0.2f" % settings["timeout"]
if "retries" in settings:
options += " -r %d" % settings["retries"]
diff --git a/web/plugins/wato/check_mk_configuration.py b/web/plugins/wato/check_mk_configuration.py
index d7229e0..48bf6d6 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -2027,13 +2027,14 @@ register_rule(group,
"for the SNMP access to devices."),
elements = [
( "timeout",
- Integer(
+ Float(
title = _("Timeout between retries"),
help = _("A request is sent to the SNMP daemon, than wait up to this "
" number of seconds until retrying."),
default_value = 1,
- minvalue = 1,
+ minvalue = 0.5,
maxvalue = 60,
+ allow_int = True,
unit = _("sec"),
),
),
Module: check_mk
Branch: master
Commit: bdb441639b5609e273fd92b8cf745882c88272c0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bdb441639b5609…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Nov 20 10:30:27 2013 +0100
FIX Improved error handling of SNMP commands
In the past, in normal SNMP mode, the stderr output of all
snmp related commands was completely suppressed. It was hard
to find out the source of problems in some cases, for example
timeouts. The execution of those programs has been changed to
output stderr messages for walks in all cases and for gets only
when -v is given.
---
.werks/217 | 13 +++++++++++++
ChangeLog | 3 +++
modules/check_mk.py | 14 +++++++++++---
modules/snmp.py | 13 +++++++------
web/plugins/wato/check_mk_configuration.py | 2 +-
5 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/.werks/217 b/.werks/217
new file mode 100644
index 0000000..7c397c9
--- /dev/null
+++ b/.werks/217
@@ -0,0 +1,13 @@
+Title: Improved error handling of SNMP commands
+Level: 1
+Component: core
+Version: 1.2.3i7
+Date: 1384939712
+Class: fix
+
+In the past, in normal SNMP mode, the stderr output of all
+snmp related commands was completely suppressed. It was hard
+to find out the source of problems in some cases, for example
+timeouts. The execution of those programs has been changed to
+output stderr messages for walks in all cases and for gets only
+when -v is given.
diff --git a/ChangeLog b/ChangeLog
index 6439fe9..8538a3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
1.2.3i7:
+ Core & Setup:
+ * 0217 FIX: Improved error handling of SNMP commands...
+
Checks & Agents:
* 0060 cisco_fantray: new check for monitoring fan trays of Cisco Nexus switches
* 0061 cisco_cpu: check now recognizes new object cpmCPUTotal5minRev...
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 91af074..a1cefa8 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -25,6 +25,7 @@
# Boston, MA 02110-1301 USA.
import os, sys, socket, time, getopt, glob, re, stat, py_compile, urllib, inspect
+import subprocess
# These variable will be substituted at 'make dist' time
check_mk_version = '(inofficial)'
@@ -761,13 +762,20 @@ def snmp_get_oid(hostname, ipaddress, oid):
portspec = snmp_port_spec(hostname)
command = snmp_base_command(commandtype, hostname) + \
- " -On -OQ -Oe -Ot %s%s %s 2>/dev/null" % (ipaddress, portspec, oid_prefix)
+ " -On -OQ -Oe -Ot %s%s %s" % (ipaddress, portspec, oid_prefix)
if opt_debug:
sys.stdout.write("Running '%s'\n" % command)
- snmp_process = os.popen(command, "r")
- line = snmp_process.readline().strip()
+ snmp_process = subprocess.Popen(command, shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
+ exitstatus = snmp_process.wait()
+ if exitstatus:
+ if opt_verbose:
+ sys.stderr.write(tty_red + tty_bold + "ERROR: " + tty_normal + "SNMP error\n")
+ sys.stderr.write(snmp_process.stderr.read())
+ return None
+
+ line = snmp_process.stdout.readline().strip()
if not line:
if opt_debug:
sys.stdout.write("Error in response to snmpget.\n")
diff --git a/modules/snmp.py b/modules/snmp.py
index d858c35..b46d048 100644
--- a/modules/snmp.py
+++ b/modules/snmp.py
@@ -401,10 +401,11 @@ def snmp_decode_string(text):
def snmpwalk_on_suboid(hostname, ip, oid):
portspec = snmp_port_spec(hostname)
command = snmp_walk_command(hostname) + \
- " -OQ -OU -On -Ot %s%s %s 2>/dev/null" % (ip, portspec, oid)
+ " -OQ -OU -On -Ot %s%s %s" % (ip, portspec, oid)
if opt_debug:
sys.stderr.write(' Running %s\n' % (command,))
- snmp_process = os.popen(command, "r").xreadlines()
+
+ snmp_process = subprocess.Popen(command, shell = True, stdout = subprocess.PIPE)
# Ugly(1): in some cases snmpwalk inserts line feed within one
# dataset. This happens for example on hexdump outputs longer
@@ -414,8 +415,8 @@ def snmpwalk_on_suboid(hostname, ip, oid):
# a continuation line.
rowinfo = []
try:
- while True: # walk through all lines
- line = snmp_process.next().strip()
+ for line in snmp_process.stdout.xreadlines():
+ line = line.strip()
parts = line.split('=', 1)
if len(parts) < 2:
continue # broken line, must contain =
@@ -437,9 +438,9 @@ def snmpwalk_on_suboid(hostname, ip, oid):
except StopIteration:
pass
- exitstatus = snmp_process.close()
+ exitstatus = snmp_process.wait()
if exitstatus:
if opt_verbose:
sys.stderr.write(tty_red + tty_bold + "ERROR: " + tty_normal + "SNMP error\n")
- raise MKSNMPError("SNMP Error on %s" % ip)
+ raise MKSNMPError("SNMP Error on %s (Exit-Code: %d)" % (ip, exitstatus))
return rowinfo
diff --git a/web/plugins/wato/check_mk_configuration.py b/web/plugins/wato/check_mk_configuration.py
index 48bf6d6..c34468b 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -2032,7 +2032,7 @@ register_rule(group,
help = _("A request is sent to the SNMP daemon, than wait up to this "
" number of seconds until retrying."),
default_value = 1,
- minvalue = 0.5,
+ minvalue = 0.1,
maxvalue = 60,
allow_int = True,
unit = _("sec"),
Module: check_mk
Branch: master
Commit: e015a1c4c9946c843adaf9a29810736cfa3d5ef6
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e015a1c4c9946c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Nov 20 09:15:37 2013 +0100
Added option to make HTML escape in plugin outputs configurable
It is now possible to disable the HTML escaping in plugin outputs and
log messages. This is useful if one really wants to use HTML codes
provided by check plugins or log messages. Disabling the escaping
makes it possible to inject HTML / script code into multisite, so
be careful.
---
.werks/215 | 12 ++++++++++++
ChangeLog | 1 +
web/htdocs/lib.py | 13 +++++++++----
web/plugins/config/builtin.py | 3 +++
web/plugins/wato/check_mk_configuration.py | 13 +++++++++++++
5 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/.werks/215 b/.werks/215
new file mode 100644
index 0000000..e499a5f
--- /dev/null
+++ b/.werks/215
@@ -0,0 +1,12 @@
+Title: Added option to make HTML escape in plugin outputs configurable
+Level: 1
+Component: multisite
+Version: 1.2.3i7
+Date: 1384935234
+Class: feature
+
+It is now possible to disable the HTML escaping in plugin outputs and
+log messages. This is useful if one really wants to use HTML codes
+provided by check plugins or log messages. Disabling the escaping
+makes it possible to inject HTML / script code into multisite, so
+be careful.
diff --git a/ChangeLog b/ChangeLog
index 34f8ef8..466a33b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -27,6 +27,7 @@
* 0001 New filters for selecting several host/service-groups at once...
* 0050 New concept of favorite hosts and services plus matching filters and views...
* 0211 GUI Notify: Added notify method "popup" to really create popup windows...
+ * 0215 Added option to make HTML escape in plugin outputs configurable...
* 0043 FIX: LDAP: Improved error reporting during synchronisation...
* 0044 FIX: LDAP: Fixed error with empty groups during non nested group sync...
* 0045 FIX: LDAP: Fixed error when synchronizing non nested groups to roles
diff --git a/web/htdocs/lib.py b/web/htdocs/lib.py
index 12929cb..43d9808 100644
--- a/web/htdocs/lib.py
+++ b/web/htdocs/lib.py
@@ -245,7 +245,11 @@ def paint_host_list(site, hosts):
return "", h
def format_plugin_output(output, row = None):
- output = html.attrencode(output).replace("(!)", warn_marker) \
+ import config
+ if config.escape_plugin_output:
+ output = html.attrencode(output)
+
+ output = output.replace("(!)", warn_marker) \
.replace("(!!)", crit_marker) \
.replace("(?)", unknown_marker)
if row and "[running on" in output:
@@ -255,9 +259,10 @@ def format_plugin_output(output, row = None):
css, h = paint_host_list(row["site"], hosts)
output = output[:a] + "running on " + h + output[e+1:]
- output = re.sub("http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+",
- lambda p: '<a href="%s">%s</a>' %
- (p.group(0), len(p.group(0)) > 40 and p.group(0)[:40] + "..." or p.group(0)), output)
+ if config.escape_plugin_output:
+ output = re.sub("http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+",
+ lambda p: '<a href="%s">%s</a>' %
+ (p.group(0), len(p.group(0)) > 40 and p.group(0)[:40] + "..." or p.group(0)), output)
return output
diff --git a/web/plugins/config/builtin.py b/web/plugins/config/builtin.py
index 6d23c08..c5a3b1a 100644
--- a/web/plugins/config/builtin.py
+++ b/web/plugins/config/builtin.py
@@ -202,6 +202,9 @@ pagetitle_date_format = None
# appear in a stale state
staleness_threshold = 1.5
+# Escape HTML in plugin output / log messages
+escape_plugin_output = True
+
# _ _ ____ ____
# | | | |___ ___ _ __| _ \| __ )
# | | | / __|/ _ \ '__| | | | _ \
diff --git a/web/plugins/wato/check_mk_configuration.py b/web/plugins/wato/check_mk_configuration.py
index a4e2ec0..d7229e0 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -216,6 +216,19 @@ register_configvar(group,
domain = "multisite")
register_configvar(group,
+ "escape_plugin_output",
+ Checkbox(title = _("Escape HTML codes in plugin output"),
+ label = _("Prevent loading HTML from plugin output or log messages"),
+ help = _("By default, for security reasons, Multisite does not interpret any HTML "
+ "code received from external sources, like plugin output or log messages. "
+ "If you are really sure what you are doing and need to have HTML codes, like "
+ "links rendered, disable this option. Be aware, you might open the way "
+ "for several injection attacks."),
+ default_value = True),
+ domain = "multisite")
+
+
+register_configvar(group,
"multisite_draw_ruleicon",
Checkbox(title = _("Show icon for WATO parameter editor"),
label = _("Show WATO icon"),
Module: check_mk
Branch: master
Commit: ca675de60d2e593675f42a6804a53b6fc632f10b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ca675de60d2e59…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Nov 19 13:55:34 2013 +0100
Updated bug entries #0733, #0959
---
.bugs/733 | 7 +++++--
.bugs/959 | 3 +++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/.bugs/733 b/.bugs/733
index 09f290a..67058ff 100644
--- a/.bugs/733
+++ b/.bugs/733
@@ -1,9 +1,12 @@
Title: Turnoff context in logwatch
Component: checks
-State: open
+Class: feature
+State: done
Date: 2012-08-06 16:02:17
Targetversion: future
-Class: feature
It should be possible to turn the saving of context logentries from logwatch off.
In some cases are there hunderts of not needed entries and the 500kb limit are full with only one error line
+
+2013-11-19 13:53:52: changed state open -> done
+Has been implemented as option for windows and linux agent.
diff --git a/.bugs/959 b/.bugs/959
index a408db2..d131cb7 100644
--- a/.bugs/959
+++ b/.bugs/959
@@ -25,3 +25,6 @@ die wir untersuchen, beschränken. Wenn man z.B. sagt max.
5 Mio Zeilen festlegt, dann sind dass etwa 500 MB Dateigröße.
Das ganze könnte konfigurierbar sein, analog zu den schon
vorhandenen Caching-Optionen.
+Wichtig hierbei ist, dem Nutzer den Fehler darzustellen und eventuell
+auch einen Eintrag im Logfile zu erzeugen. Der Nutzer sollte dann darauf
+hingewiesen werden seine Logging-/Rotations-Einstellungen zu aendern.