Module: check_mk
Branch: master
Commit: e880eb02fcf2461fe04311ffc6abf46442bf8bfb
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e880eb02fcf246…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Tue Oct 22 17:16:40 2013 +0200
Allow another enterprise ids introduced as a bug some genuscreen versions
---
checkman/genua_carp | 4 +++-
checks/genua_carp | 37 ++++++++++++++++++++-----------------
2 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/checkman/genua_carp b/checkman/genua_carp
index 38f418f..3407638 100644
--- a/checkman/genua_carp
+++ b/checkman/genua_carp
@@ -14,7 +14,9 @@ description:
For a cluster the check determines the number of carp interfaces on the cluster with
the state master. If it is either {0} or {>1} the check is critical.
- The check is known to run with genuscreen version 3.0, others may also work.
+ The check is known to run with genuscreen version 3.0 and supports genuas regular
+ enterprise id 3717 as well as the id 3137 which was introduced in a bug in some
+ versions of genuscreen.
perfdata:
None
diff --git a/checks/genua_carp b/checks/genua_carp
index f84faa4..800da49 100644
--- a/checks/genua_carp
+++ b/checks/genua_carp
@@ -42,6 +42,9 @@
def inventory_genua_carp(info):
inventory = []
+ # remove empty elements due to two alternative enterprise ids in snmp_info
+ info = filter(None, info)
+
if info[0]:
for ifIndex, ifName, ifType, ifLinkState, ifCarpState in info[0]:
if ifCarpState in [ "0", "1", "2" ]:
@@ -84,11 +87,15 @@ def genua_carpstate(st):
def check_genua_carp(item, _no_params, info):
+ # remove empty elements due to two alternative enterprise ids in snmp_info
+ info = filter(None, info)
+
if not info[0]:
return(3, "Invalid Output from Agent")
state = 0
nodes = len(info)
masters = 0
+ output = ""
if nodes > 1:
prefix = "Cluster test: "
else:
@@ -102,13 +109,14 @@ def check_genua_carp(item, _no_params, info):
ifLinkStateStr = genua_linkstate(str(ifLinkState))
ifCarpStateStr = genua_carpstate(str(ifCarpState))
# is inventorized interface in state carp master ?
- if ifName == item:
- output = "node in carp state %s with IfLinkState %s" \
- % (ifCarpStateStr,ifLinkStateStr)
if ifName == item and ifCarpState == "2":
# is master
masters += 1
if masters == 1:
+ if nodes > 1:
+ output = "one "
+ output += "node in carp state %s with IfLinkState %s" \
+ % (ifCarpStateStr,ifLinkStateStr)
# first master
if ifLinkState == "2":
state = 0
@@ -120,10 +128,12 @@ def check_genua_carp(item, _no_params, info):
state = 3
else:
state = 2
- output = "%d masters found on cluster with %d nodes" \
- % (masters,nodes)
+ output = "%d nodes in carp state %s on cluster with %d nodes" \
+ % (masters,ifCarpStateStr,nodes)
# look for non-masters, only interesting if no cluster
elif ifName == item and nodes == 1:
+ output = "node in carp state %s with IfLinkState %s" \
+ % (ifCarpStateStr,ifLinkStateStr)
# carp backup
if ifCarpState == "1" and ifLinkState == "1":
state = 0
@@ -143,27 +153,20 @@ check_info['genua_carp'] = {
"check_function" : check_genua_carp,
"service_description": "Carp Interface %s",
"has_perfdata" : False,
- "snmp_info" : [( ".1.3.6.1.4.1.3717.2.1.2",[
+ "snmp_info" : [( ".1.3.6.1.4.1.3137.2.1.2",[
"1.1", # "ifIndex"
"1.2", # "ifName"
"1.3", # "ifType"
"1.4", # "ifLinkState"
"1.7", # "ifCarpState"
- ])],
- "snmp_scan_function" : lambda oid: "genuscreen" in oid(".1.3.6.1.2.1.1.1.0").lower()
-}
-
-check_info['genua_carp_bad_eoid'] = {
- "inventory_function" : inventory_genua_carp,
- "check_function" : check_genua_carp,
- "service_description": "Carp Interface %s",
- "has_perfdata" : False,
- "snmp_info" : [( ".1.3.6.1.4.1.3137.2.1.2",[
+ ]),
+ ( ".1.3.6.1.4.1.3717.2.1.2",[
"1.1", # "ifIndex"
"1.2", # "ifName"
"1.3", # "ifType"
"1.4", # "ifLinkState"
"1.7", # "ifCarpState"
- ])],
+ ]),
+ ],
"snmp_scan_function" : lambda oid: "genuscreen" in oid(".1.3.6.1.2.1.1.1.0").lower()
}
Module: check_mk
Branch: master
Commit: f530c885025f574da6972b07b82041145fad5199
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f530c885025f57…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Tue Oct 22 17:18:32 2013 +0200
New check to test for correlation of carp interface states on genuscreen devices
---
checkman/genua_state_correlation | 20 +++++++
checks/genua_state_correlation | 112 ++++++++++++++++++++++++++++++++++++++
2 files changed, 132 insertions(+)
diff --git a/checkman/genua_state_correlation b/checkman/genua_state_correlation
new file mode 100644
index 0000000..c459cf1
--- /dev/null
+++ b/checkman/genua_state_correlation
@@ -0,0 +1,20 @@
+title: Correlation of the state of carp interfaces on genuscreen devices
+agents: snmp
+catalog: hw/network/genua
+license: GPL
+distribution: check_mk
+description:
+ This check monitors if the two carp interfaces found on genuscreen devices
+ have the same carp state. If not, the check is critical.
+
+ The check is known to run with genuscreen version 3.0 and supports genuas regular
+ enterprise id 3717 as well as the id 3137 which was introduced in a bug in some
+ versions of genuscreen.
+
+perfdata:
+ None
+
+inventory:
+ The inventory process checks if the device has a system description OIDs (.1.3.6.1.2.1.1.2.0)
+ and if the name of this OID contains "genuscreen" (case insensitive).
+ If this is true the system is inventorized.
diff --git a/checks/genua_state_correlation b/checks/genua_state_correlation
new file mode 100644
index 0000000..482db93
--- /dev/null
+++ b/checks/genua_state_correlation
@@ -0,0 +1,112 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+# Example Agent Output:
+# GENUA-MIB:
+
+#.1.3.6.1.4.1.3137.2.1.2.1.1.9 = INTEGER: 9
+#.1.3.6.1.4.1.3137.2.1.2.1.1.10 = INTEGER: 10
+#.1.3.6.1.4.1.3137.2.1.2.1.2.9 = STRING: "carp0"
+#.1.3.6.1.4.1.3137.2.1.2.1.2.10 = STRING: "carp1"
+#.1.3.6.1.4.1.3137.2.1.2.1.3.9 = INTEGER: 5
+#.1.3.6.1.4.1.3137.2.1.2.1.3.10 = INTEGER: 5
+#.1.3.6.1.4.1.3137.2.1.2.1.4.9 = INTEGER: 2
+#.1.3.6.1.4.1.3137.2.1.2.1.4.10 = INTEGER: 2
+#.1.3.6.1.4.1.3137.2.1.2.1.7.9 = INTEGER: 2
+#.1.3.6.1.4.1.3137.2.1.2.1.7.10 = INTEGER: 2
+
+
+def inventory_genua_state(info):
+ # remove empty elements due to two alternative enterprise ids in snmp_info
+ info = filter(None, info)
+ if info[0]:
+ numifs = 0
+ for ifIndex, ifName, ifType, ifLinkState, ifCarpState in info[0]:
+ if ifCarpState in [ "0", "1", "2" ]:
+ numifs += 1
+ # inventorize only if we find at least two carp interfaces
+ if numifs > 1:
+ return [(None, None)]
+ return None
+
+def genua_state_str(st):
+ names = {
+ '0' : 'init',
+ '1' : 'backup',
+ '2' : 'master',
+ }
+ return names.get(st, st)
+
+def check_genua_state(item, _no_params, info):
+
+ # remove empty elements due to two alternative enterprise ids in snmp_info
+ info = filter(None, info)
+ if not info[0]:
+ return(3, "Invalid Output from Agent")
+
+ state = 0
+ output = "Node test:"
+ carp_info = []
+
+ for ifIndex, ifName, ifType, ifLinkState, ifCarpState in info[0]:
+ if ifType == "6":
+ carp_info.append((ifIndex, ifName, ifType, ifLinkState, ifCarpState))
+
+ if len(carp_info) != 2:
+ return(3, "Number of carp interfaces is %d, needs to be 2" % len(carp_info))
+
+ # Output formatieren
+ output += " %s:%s %s:%s" % (carp_info[0][1], genua_state_str(carp_info[0][4])\
+ , carp_info[1][1], genua_state_str(carp_info[1][4]))
+
+ # critical if the two carp interfaces dont have the same state
+ if carp_info[0][4] != carp_info[1][4]:
+ state = 2
+
+ return(state, output)
+
+check_info['genua_state_correlation'] = {
+ "inventory_function" : inventory_genua_state,
+ "check_function" : check_genua_state,
+ "service_description": "Carp Correlation",
+ "has_perfdata" : False,
+ "snmp_info" : [( ".1.3.6.1.4.1.3717.2.1.2",[
+ "1.1", # "ifIndex"
+ "1.2", # "ifName"
+ "1.3", # "ifType"
+ "1.4", # "ifLinkState"
+ "1.7", # "ifCarpState"
+ ]),
+ ( ".1.3.6.1.4.1.3137.2.1.2",[
+ "1.1", # "ifIndex"
+ "1.2", # "ifName"
+ "1.3", # "ifType"
+ "1.4", # "ifLinkState"
+ "1.7", # "ifCarpState"
+ ])],
+ "snmp_scan_function" : lambda oid: "genuscreen" in oid(".1.3.6.1.2.1.1.1.0").lower()
+ #"snmp_scan_function" : lambda oid: oid(".1.3.6.1.4.1.3717.2.1.2.1.7") != None
+}
Module: check_mk
Branch: master
Commit: 9a88392d2b4b5c4d9e35e5aa23e00bb1d1661611
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9a88392d2b4b5c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Oct 22 16:30:36 2013 +0200
FIX: Added code to prevent injection of bogus varnames
---
ChangeLog | 2 ++
web/htdocs/html_mod_python.py | 10 +++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index a91c9ce..c22bec4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -32,6 +32,8 @@
* FIX: Remove duplicate entries from Quicksearch
* FIX: Avoid timed browser reload after execution of exections
* FIX: Hosttag filter now works in service related views
+ * FIX: Added code to prevent injection of bogus varnames
+ (This might break code which uses some uncommon chars for varnames)
BI:
* FIX: Fix exception when showing BI tree in reporting time warp
diff --git a/web/htdocs/html_mod_python.py b/web/htdocs/html_mod_python.py
index a48f313..e794044 100644
--- a/web/htdocs/html_mod_python.py
+++ b/web/htdocs/html_mod_python.py
@@ -1,8 +1,10 @@
from mod_python import Cookie, util, apache
import htmllib
-import os, time, config, weblib
+import os, time, config, weblib, re
import defaults
+varname_regex = re.compile('^[\w\d_-]+$')
+
class html_mod_python(htmllib.html):
def __init__(self, req):
@@ -45,6 +47,12 @@ class html_mod_python(htmllib.html):
for field in fields.list:
varname = field.name
value = field.value
+
+ # To prevent variours injections, we only allow a defined set
+ # of characters to be used in variables
+ if not varname_regex.match(varname):
+ continue
+
# Multiple occurrance of a variable? Store in extra list dict
if varname in self.vars:
if varname in self.listvars:
Module: check_mk
Branch: master
Commit: ac4d50feeaf6732fc2b81b23361a405f82e6906f
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ac4d50feeaf673…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Oct 22 15:16:53 2013 +0200
Fixed invalid function call in latest change
---
web/htdocs/sidebar.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/web/htdocs/sidebar.py b/web/htdocs/sidebar.py
index 672c2af..f8c6ddc 100644
--- a/web/htdocs/sidebar.py
+++ b/web/htdocs/sidebar.py
@@ -565,7 +565,7 @@ def ajax_del_bookmark():
try:
del bookmarks[num]
except IndexError:
- raise MKGeneralException(_("Unknown bookmark id: %d. This is probably a problem with reload or browser history. Please try again.") % htmllib.attrencode(num))
+ raise MKGeneralException(_("Unknown bookmark id: %d. This is probably a problem with reload or browser history. Please try again.") % html.attrencode(num))
save_bookmarks(bookmarks)
render_bookmarks()
@@ -597,7 +597,7 @@ def page_edit_bookmark():
raise MKGeneralException(_("Invalid bookmark id."))
bookmarks = load_bookmarks()
if n >= len(bookmarks):
- raise MKGeneralException(_("Unknown bookmark id: %d. This is probably a problem with reload or browser history. Please try again.") % htmllib.attrencode(n))
+ raise MKGeneralException(_("Unknown bookmark id: %d. This is probably a problem with reload or browser history. Please try again.") % html.attrencode(n))
if html.var("save") and html.check_transaction():
title = html.var("title")