Module: check_mk
Branch: master
Commit: c3c245149525f757ec2f51c1c907ef3cc1f671a7
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c3c245149525f7…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Fri Jun 1 17:08:00 2012 +0200
Added hwg_temp check
---
checks/hwg_temp | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 90 insertions(+), 0 deletions(-)
diff --git a/checks/hwg_temp b/checks/hwg_temp
new file mode 100644
index 0000000..3447ee4
--- /dev/null
+++ b/checks/hwg_temp
@@ -0,0 +1,90 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2010 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.
+
+hwg_temp_defaultlevels = (23, 25)
+
+def check_hwg_temp(item, params, info):
+ warn, crit = params
+ status_text = {
+ "0" : "Invalid",
+ "1" : "Normal",
+ "2" : "Out Of Range Low",
+ "3" : "Out Of Range High",
+ "4" : "Alarm Low",
+ "5" : "Alarm High",
+ }
+ unit_text = {
+ "0" : "unknown",
+ "1" : "°C",
+ "2" : "°F",
+ "3" : "°K",
+ "4" : "%",
+ }
+ for line in info:
+ if line[0] == item:
+ descr, status, current, current_m, unit = line[1:]
+ current_state = saveint(current_m)/10
+
+ state = 0
+ if current_state >= crit:
+ state = 2
+ elif current_state >= warn:
+ state = 1
+ elif status in (4, 2):
+ state = 1
+ elif status == 3:
+ state = 2
+
+ perfdata = [ ("temp", current, warn, crit, 0 ) ]
+ unit = unit_text.get(unit)
+ status = status_text.get(status, "UNKOWN")
+ return(state, nagios_state_names[state] + " - %s at %s%s (warn/crit at %s%s/%s%s), Status is %s" % \
+ (descr, current, unit, warn, unit, crit, unit, status), perfdata)
+
+ return (3, "UNKNOWN - Sensor %s not found in SNMP data %s" % (item) )
+
+check_info['hwg_temp'] = {
+ "check_function" : check_hwg_temp,
+ "inventory_function" : lambda info: [ (line[0], hwg_temp_defaultlevels ) for line in info if int(line[2]) != 0] ,
+ "service_description" : "Temperature %s",
+ "has_perfdata" : True,
+ "snmp_info" : (".1.3.6.1.4.1.21796.4.1.3", [# sensors index (1-2)
+ "1.1",
+ # sensor name string
+ "1.2",
+ # unit state: 0=Invalid, 1=Normal, 2=OutOfRangeLo, 3=OutOfRangeHi, 4=AlarmLo, 5=AlarmHi
+ "1.3",
+ # current value string
+ "1.4",
+ # current value*10 integer
+ "1.5",
+ # sensor unit integer 0=unknown, 1=°C, 2=°F, 3=°K, 4=%
+ "1.7",
+ ]),
+ "snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.1.0") == '"HWg-STE"',
+ "group" : "hw_temperature",
+}
+
Module: check_mk
Branch: master
Commit: d1b17422be622adba14713c06689babd526e7d11
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d1b17422be622a…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Fri Jun 1 14:56:15 2012 +0200
WATO: visiblity fixes for hidden attributes and topics
---
web/htdocs/js/wato.js | 29 ++++++++++++++++++++---------
web/htdocs/wato.py | 10 ++++++++--
2 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/web/htdocs/js/wato.js b/web/htdocs/js/wato.js
index c02c830..5bf8df0 100644
--- a/web/htdocs/js/wato.js
+++ b/web/htdocs/js/wato.js
@@ -112,12 +112,20 @@ function wato_fix_visibility() {
/* Now loop over all attributes that have conditions. Those are
stored in the global variable wato_depends_on_tags, which is filled
during the creation of the web page. */
+
for (var i in wato_check_attributes) {
- var attrname = wato_check_attributes[i]
+ var attrname = wato_check_attributes[i];
/* Now comes the tricky part: decide whether that attribute should
be visible or not: */
var display = "";
- if(attrname in wato_depends_on_roles){
+
+ // Always invisible
+ if( hide_attributes.indexOf(attrname) > -1 ){
+ display = "none";
+ }
+
+ // Visibility depends on roles
+ if( display == "" && attrname in wato_depends_on_roles){
for (var i in wato_depends_on_roles[attrname]) {
var role = wato_depends_on_roles[attrname][i];
var negate = role[0] == '!';
@@ -130,6 +138,7 @@ function wato_fix_visibility() {
}
}
+ // Visibility depends on tags
if( display == "" && attrname in wato_depends_on_tags){
for (var i in wato_depends_on_tags[attrname]) {
var tag = wato_depends_on_tags[attrname][i];
@@ -143,6 +152,7 @@ function wato_fix_visibility() {
}
}
+
var oTr = document.getElementById("attr_" + attrname);
if(oTr) {
oTr.style.display = display;
@@ -167,7 +177,7 @@ function wato_fix_visibility() {
oAttrDisp = null;
// There is at least one item in this topic -> show it
- var topic = oTr.parentNode.parentNode.parentNode.id.substr(21);
+ var topic = oTr.parentNode.childNodes[0].textContent;
if( display == "" ){
var index = hide_topics.indexOf(topic);
if( index != -1 )
@@ -175,15 +185,16 @@ function wato_fix_visibility() {
}
}
}
- for (var item in volatile_topics){
- var name = volatile_topics[item];
- var oTr = document.getElementById("topic_" + name);
- if(oTr) {
- if(hide_topics.indexOf(name) > -1 )
+
+ var form_edithost = document.getElementById("form_edithost");
+ for (var child in form_edithost.childNodes){
+ oTr = form_edithost.childNodes[child];
+ if (oTr.className == "nform"){
+ if( hide_topics.indexOf(oTr.childNodes[0].childNodes[0].textContent) > -1 )
oTr.style.display = "none";
else
oTr.style.display = "";
- }
+ }
}
}
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 567e75c..cefdac8 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -4595,6 +4595,7 @@ def configure_attributes(hosts, for_what, parent, myself=None, without_attribute
inherited_tags = {}
volatile_topics = []
+ hide_attributes = []
for topic in topics:
topic_is_volatile = True # assume topic is sometimes hidden due to dependencies
if len(topics) > 1:
@@ -4638,6 +4639,8 @@ def configure_attributes(hosts, for_what, parent, myself=None, without_attribute
if not depends_on_tags and not depends_on_roles:
# One attribute is always shown -> topic is always visible
topic_is_volatile = False
+ else:
+ hide_attributes.append(attr.name())
# "bulk": determine, if this attribute has the same setting for all hosts.
values = []
@@ -4797,6 +4800,7 @@ def configure_attributes(hosts, for_what, parent, myself=None, without_attribute
def dump_json(obj):
return repr(obj).replace('None', 'null')
+ forms.end()
# Provide Javascript world with the tag dependency information
# of all attributes.
html.javascript("var inherited_tags = %s;\n"\
@@ -4805,13 +4809,15 @@ def configure_attributes(hosts, for_what, parent, myself=None, without_attribute
"var wato_depends_on_roles = %s;\n"\
"var volatile_topics = %s;\n"\
"var user_roles = %s;\n"\
+ "var hide_attributes = %s;\n"\
"wato_fix_visibility();\n" % (
dump_json(inherited_tags),
- dump_json(list(set(dependency_mapping_tags.keys()+dependency_mapping_roles.keys()))),
+ dump_json(list(set(dependency_mapping_tags.keys()+dependency_mapping_roles.keys()+hide_attributes))),
dump_json(dependency_mapping_tags),
dump_json(dependency_mapping_roles),
dump_json(volatile_topics),
- dump_json(config.user_role_ids)))
+ dump_json(config.user_role_ids),
+ dump_json(hide_attributes)))
# Check if at least one host in a folder (or its subfolders)
Module: check_mk
Branch: master
Commit: 6a9da332ff26d6b4d8367c41e2674d48512e12b0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6a9da332ff26d6…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jun 1 09:16:55 2012 +0200
WATO view editor: Made new strip_bad_chars function work with unicode strings
---
web/htdocs/forms.py | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/web/htdocs/forms.py b/web/htdocs/forms.py
index 8151ea9..26b3f5d 100644
--- a/web/htdocs/forms.py
+++ b/web/htdocs/forms.py
@@ -98,7 +98,19 @@ def edit_dictionary(entries, value, focus=None, hover_help=True, validate=None,
# New functions for painting forms
def strip_bad_chars(x):
- return "".join([c for c in x if c > ' ' and c < 'z']).translate(None, "'&;<>\"")
+ s = "".join([c for c in x if c > ' ' and c < 'z'])
+
+ if type(s) == unicode:
+ return s.translate({
+ ord(u"'"): None,
+ ord(u"&"): None,
+ ord(u";"): None,
+ ord(u"<"): None,
+ ord(u">"): None,
+ ord(u"\""): None,
+ })
+ else:
+ return s.translate(None, u"'&;<>\"")
def header(title, isopen = True, table_id = ""):
global g_header_open