Module: check_mk
Branch: master
Commit: 7104f183a1ed46d5822e9ee781c1959fd08678d9
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7104f183a1ed46…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Feb 17 10:29:25 2014 +0100
logwatch.ec: Optionally monitor the list of forwarded logfiles
You can now have the check <tt>logwatch.ec</tt> - Event Console forwarding of
logfiles - monitor the list of forwarded logfiles. This is enabled by setting
<tt>"monitoring_logfilelist"</tt> to <tt>True</tt> in the checks parameter
dictionary. WATO shows this as a new check box <i>Warn if list of forwarded
logfiles changes</i> in the rule set <i>Logwatch Event Console Forwarding</i>.
During inventory the check remembers the list of currently present logfiles
that should be forwarded to the Event Console. If that list changes at any
time later then the check goes to WARN and displays the missing/exceeding
logfiles. Re-inventorize the check in order to acknowledge the new list.
---
.werks/718 | 17 ++++++++
ChangeLog | 1 +
checkman/logwatch.ec | 3 ++
checks/logwatch | 78 ++++++++++++++++++++++++----------
web/plugins/wato/check_parameters.py | 10 +++++
5 files changed, 87 insertions(+), 22 deletions(-)
diff --git a/.werks/718 b/.werks/718
new file mode 100644
index 0000000..c7027b6
--- /dev/null
+++ b/.werks/718
@@ -0,0 +1,17 @@
+Title: logwatch.ec: Optionally monitor the list of forwarded logfiles
+Level: 1
+Component: checks
+Version: 1.2.5i1
+Date: 1392629160
+Class: feature
+
+You can now have the check <tt>logwatch.ec</tt> - Event Console forwarding of
+logfiles - monitor the list of forwarded logfiles. This is enabled by setting
+<tt>"monitoring_logfilelist"</tt> to <tt>True</tt> in the checks parameter
+dictionary. WATO shows this as a new check box <i>Warn if list of forwarded
+logfiles changes</i> in the rule set <i>Logwatch Event Console Forwarding</i>.
+
+During inventory the check remembers the list of currently present logfiles
+that should be forwarded to the Event Console. If that list changes at any
+time later then the check goes to WARN and displays the missing/exceeding
+logfiles. Re-inventorize the check in order to acknowledge the new list.
diff --git a/ChangeLog b/ChangeLog
index 03b0ba7..b66d930 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -89,6 +89,7 @@
* 0135 apc_inputs: New Check for APC Input Contacts
* 0701 emc_isilon_diskstatus: new check for Status of Disks in EMC Isilon Storage Systems
* 0581 emc_datadomain_disks emc_datadomain_fs: new checks to monitor disks and filesystems of EMC Datadomain
+ * 0718 logwatch.ec: Optionally monitor the list of forwarded logfiles...
* 0103 FIX: services: Fixed bug with service inventory defined in main.mk...
* 0299 FIX: borcade_mlx_fan: Prettified output, handling "other" state now
* 0300 FIX: cisco_fru_power: Trying not to inventorize not plugged in FRUs...
diff --git a/checkman/logwatch.ec b/checkman/logwatch.ec
index 7497da2..2e9b120 100644
--- a/checkman/logwatch.ec
+++ b/checkman/logwatch.ec
@@ -22,3 +22,6 @@ parameters (dict): This check works with the following keys:
be configured to use the spooling mechanism of the event console. To configure this, either
configure {"socket:"} to detect the spooling directory of the local event console or
{"socket:/path/to/spool/directory"} to configure the path explicit to the local spool directory.
+
+ {"monitor_logfilelist"}: Set this to {True} if you want to get warned if the list of logfiles
+ has changed since the last inventory if this check.
diff --git a/checks/logwatch b/checks/logwatch
index 07c8091..d57316e 100644
--- a/checks/logwatch
+++ b/checks/logwatch
@@ -45,9 +45,12 @@ def logwatch_ec_forwarding_enabled(params, item):
return False
-def inventory_logwatch(info, is_logwatch_ec = False):
- inventory = []
- forward_logs = []
+# Splits the number of existing logfiles into
+# forwarded (to ec) and not forwarded. Returns a
+# pair of forwarded and not forwarded logs.
+def logwatch_select_forwarded(info):
+ forwarded_logs = []
+ not_forwarded_logs = []
forward_settings = host_extra_conf(g_hostname, checkgroup_parameters.get('logwatch_ec', []))
@@ -55,23 +58,24 @@ def inventory_logwatch(info, is_logwatch_ec = False):
line = " ".join(l)
if len(line) > 6 and line[0:3] == "[[[" and line[-3:] == "]]]" \
and ':missing' not in line and ':cannotopen' not in line:
- item = line[3:-3]
+ logfile_name = line[3:-3]
- if not forward_settings or forward_settings[0] is None:
- if not is_logwatch_ec:
- inventory.append((item, "", '""'))
- continue
+ # Is forwarding enabled in general?
+ if forward_settings and forward_settings[0] != None:
+ if logwatch_ec_forwarding_enabled(forward_settings[0], logfile_name):
+ forwarded_logs.append(logfile_name)
+ else:
+ not_forwarded_logs.append(logfile_name)
- forward = logwatch_ec_forwarding_enabled(forward_settings[0], item)
- if not is_logwatch_ec and not forward:
- inventory.append((item, "", '""'))
- elif is_logwatch_ec and forward:
- forward_logs.append(item)
+ # No forwarding rule configured
+ else:
+ not_forwarded_logs.append(logfile_name)
- if forward_logs:
- return [(None, '{}')]
+ return forwarded_logs, not_forwarded_logs
- return inventory
+def inventory_logwatch(info):
+ forwarded_logs, not_forwarded_logs = logwatch_select_forwarded(info)
+ return [ (n, None) for n in not_forwarded_logs ]
#logwatch_patterns = {
# 'System': [
@@ -393,9 +397,8 @@ def check_logwatch(item, params, info):
check_info['logwatch'] = {
'check_function': check_logwatch,
+ 'inventory_function': inventory_logwatch,
'service_description': "LOG %s",
- 'has_perfdata': 0,
- 'inventory_function': lambda info: inventory_logwatch(info, False),
'group': 'logwatch',
}
@@ -434,6 +437,11 @@ def syslog_time():
value = time.strftime("%b %%d %H:%M:%S", localtime)
return value % day
+def inventory_logwatch_ec(info):
+ forwarded_logs, not_forwarded_logs = logwatch_select_forwarded(info)
+ if forwarded_logs:
+ return [ (None, { "expected_logfiles": forwarded_logs } ) ]
+
def check_logwatch_ec(item, params, info):
if len(info) == 1:
line = " ".join(info[0])
@@ -461,6 +469,31 @@ def check_logwatch_ec(item, params, info):
if not logwatch_ec_forwarding_enabled(params, logfile):
del logs[logfile]
+ # Check if the number of expected files matches the actual one
+ status = 0
+ infotexts = []
+ if params.get('monitor_logfilelist'):
+ if 'expected_logfiles' not in params:
+ infotexts.append("You enabled monitoring the list of forwarded logfiles. You need to re-inventorize the check once.")
+ status = 1
+ else:
+ expected = params['expected_logfiles']
+ missing = []
+ for f in expected:
+ if f not in logs:
+ missing.append(f)
+ if missing:
+ infotexts.append("Missing logfiles: %s" % (", ".join(missing)))
+ status = 1
+
+ exceeding = []
+ for f in logs:
+ if f not in expected:
+ exceeding.append(f)
+ if exceeding:
+ infotexts.append("Newly appeared logfiles: %s" % (", ".join(exceeding)))
+ status = 1
+
# 3. create syslog message of each line
# <128> Oct 24 10:44:27 Klappspaten /var/log/syslog: Oct 24 10:44:27 Klappspaten logger: asdasdad as
# <facility+priority> timestamp hostname logfile: message
@@ -526,16 +559,17 @@ def check_logwatch_ec(item, params, info):
logfile_info = " from " + ",".join(list(forwarded_logfiles))
else:
logfile_info = ""
- return (0, 'Forwarded %d messages%s to event console' % (
- num_messages, logfile_info ), [('messages', num_messages)])
+
+ infotexts.append('Forwarded %d messages%s to event console' % (num_messages, logfile_info))
+ return (status, ", ".join(infotexts), [('messages', num_messages)])
+
except Exception, e:
return (2, 'Unable to forward messages to event console (%s). Lost %d messages.' %
(e, num_messages))
check_info['logwatch.ec'] = {
'check_function': check_logwatch_ec,
+ 'inventory_function': inventory_logwatch_ec,
'service_description': "Log Forwarding",
- 'has_perfdata': 0,
- 'inventory_function': lambda info: inventory_logwatch(info, True),
'group': 'logwatch_ec',
}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index a58bcb1..01f766a 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -4445,6 +4445,16 @@ register_check_parameters(subgroup_applications,
choices = syslog_facilities,
default_value = 17, # local1
)),
+ ('monitor_logfilelist',
+ Checkbox(
+ title = _("Monitoring of forwarded logfiles"),
+ label = _("Warn if list of forwarded logfiles changes"),
+ help = _("If this option is enabled then the check monitors the list of forwarded "
+ "logfiles and will warn you if at any time a logfile is missing or exceeding "
+ "when compared to the initial list that was snapshotted during service detection. "
+ "Reinventorize this check in order to make it OK again."),
+ )
+ ),
],
optional_keys = ['restrict_logfiles'],
),
Module: check_mk
Branch: master
Commit: 88eedca3e374e66fb2f75f56309d7bb7c368fe5b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=88eedca3e374e6…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Feb 17 09:26:55 2014 +0100
FIX LDAP: Fixed sync when non lower case attributes are configured
The LDAP sync converts all configured ldap attributes to lower case
for easier handling internally. When custom LDAP source attributes
are configured by using non lower case, the sync did not process
those vars in some cases.
---
.werks/670 | 12 ++++++++++++
ChangeLog | 1 +
web/plugins/userdb/ldap.py | 20 +++++++++++---------
3 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/.werks/670 b/.werks/670
new file mode 100644
index 0000000..6dc19f5
--- /dev/null
+++ b/.werks/670
@@ -0,0 +1,12 @@
+Title: LDAP: Fixed sync when non lower case attributes are configured
+Level: 1
+Component: multisite
+Class: fix
+State: unknown
+Version: 1.2.5i1
+Date: 1392625538
+
+The LDAP sync converts all configured ldap attributes to lower case
+for easier handling internally. When custom LDAP source attributes
+are configured by using non lower case, the sync did not process
+those vars in some cases.
diff --git a/ChangeLog b/ChangeLog
index 9e0bdd3..3a17581 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -218,6 +218,7 @@
* 0273 FIX: Fixed exceptions when modifying / cloning views...
* 0274 FIX: Fixed exception when view title or description was missing
* 0278 FIX: Fixed bookmark icon images for non-english user languages...
+ * 0670 FIX: LDAP: Fixed sync when non lower case attributes are configured...
WATO:
* 0308 Multisite can now set rotation view permissions for NagVis...
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index 416902e..31809b3 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -687,8 +687,10 @@ def ldap_convert_simple(user_id, ldap_user, user, user_attr, attr):
def ldap_convert_mail(plugin, params, user_id, ldap_user, user):
mail = ''
- if ldap_user.get(params.get('attr', ldap_attr('mail'))):
- mail = ldap_user[params.get('attr', ldap_attr('mail'))][0].lower()
+ mail_attr = params.get('attr', ldap_attr('mail')).lower()
+ if ldap_user.get(mail_attr):
+ mail = ldap_user[mail_attr][0].lower()
+
if mail:
return {'email': mail}
else:
@@ -698,7 +700,7 @@ ldap_attribute_plugins['email'] = {
'title': _('Email address'),
'help': _('Synchronizes the email of the LDAP user account into Check_MK.'),
# Attributes which must be fetched from ldap
- 'needed_attributes': lambda params: [ params.get('attr', ldap_attr('mail')) ],
+ 'needed_attributes': lambda params: [ params.get('attr', ldap_attr('mail')).lower() ],
# Calculating the value of the attribute based on the configuration and the values
# gathered from ldap
'convert': ldap_convert_mail,
@@ -717,10 +719,10 @@ ldap_attribute_plugins['alias'] = {
'title': _('Alias'),
'help': _('Populates the alias attribute of the WATO user by syncrhonizing an attribute '
'from the LDAP user account. By default the LDAP attribute <tt>cn</tt> is used.'),
- 'needed_attributes': lambda params: [ params.get('attr', ldap_attr('cn')) ],
+ 'needed_attributes': lambda params: [ params.get('attr', ldap_attr('cn')).lower() ],
'convert': lambda plugin, params, user_id, ldap_user, user: \
ldap_convert_simple(user_id, ldap_user, user, 'alias',
- params.get('attr', ldap_attr('cn'))),
+ params.get('attr', ldap_attr('cn')).lower()),
'lock_attributes': [ 'alias' ],
'parameters': [
("attr", TextAscii(
@@ -744,7 +746,7 @@ def ldap_convert_auth_expire(plugin, params, user_id, ldap_user, user):
'serial': user.get('serial', 0) + 1,
}
- changed_attr = params.get('attr', ldap_attr('pw_changed'))
+ changed_attr = params.get('attr', ldap_attr('pw_changed')).lower()
if not changed_attr in ldap_user:
raise MKLDAPException(_('The "Authentication Expiration" attribute (%s) could not be fetched '
'from the LDAP server for user %s.') % (changed_attr, ldap_user))
@@ -766,7 +768,7 @@ def ldap_convert_auth_expire(plugin, params, user_id, ldap_user, user):
return {}
def ldap_attrs_auth_expire(params):
- attrs = [ params.get('attr', ldap_attr('pw_changed')) ]
+ attrs = [ params.get('attr', ldap_attr('pw_changed')).lower() ]
# Fetch user account flags to check locking
if config.ldap_connection['type'] == 'ad':
@@ -803,10 +805,10 @@ ldap_attribute_plugins['pager'] = {
'help': _('This plugin synchronizes a field of the users LDAP account to the pager attribute '
'of the WATO user accounts, which is then forwarded to the monitoring core and can be used'
'for notifications. By default the LDAP attribute <tt>mobile</tt> is used.'),
- 'needed_attributes': lambda params: [ params.get('attr', ldap_attr('mobile')) ],
+ 'needed_attributes': lambda params: [ params.get('attr', ldap_attr('mobile')).lower() ],
'convert': lambda plugin, params, user_id, ldap_user, user: \
ldap_convert_simple(user_id, ldap_user, user, 'pager',
- params.get('attr', ldap_attr('mobile'))),
+ params.get('attr', ldap_attr('mobile')).lower()),
'lock_attributes': ['pager'],
'parameters': [
('attr', TextAscii(
Module: check_mk
Branch: master
Commit: ff0ede5d22d1be59df575683d75882e6f4bfbf5f
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ff0ede5d22d1be…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Feb 17 08:44:03 2014 +0100
FIX Fixed regex matching in BI when using character groups [...]
Regexes were not applied correctly when only using character groups as regex
syntax without any other regex things. The option was not treated correctly
since it was not detected as being a regex.
---
.werks/669 | 11 +++++++++++
ChangeLog | 4 +++-
web/htdocs/bi.py | 6 ++++--
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/.werks/669 b/.werks/669
new file mode 100644
index 0000000..5a39810
--- /dev/null
+++ b/.werks/669
@@ -0,0 +1,11 @@
+Title: Fixed regex matching in BI when using character groups [...]
+Level: 1
+Component: bi
+Class: fix
+State: unknown
+Version: 1.2.5i1
+Date: 1392622961
+
+Regexes were not applied correctly when only using character groups as regex
+syntax without any other regex things. The option was not treated correctly
+since it was not detected as being a regex.
diff --git a/ChangeLog b/ChangeLog
index f404483..9e0bdd3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -218,7 +218,6 @@
* 0273 FIX: Fixed exceptions when modifying / cloning views...
* 0274 FIX: Fixed exception when view title or description was missing
* 0278 FIX: Fixed bookmark icon images for non-english user languages...
- * 0668 FIX: Allowing upload of files without loading the whole file into memory
WATO:
* 0308 Multisite can now set rotation view permissions for NagVis...
@@ -285,6 +284,9 @@
* 0058 FIX: Fix email notifications containing non-ASCII characters in some situtations...
* 0133 FIX: Fixed mkeventd notification plugin...
+ BI:
+ * 0669 FIX: Fixed regex matching in BI when using character groups [...]...
+
Reporting & Availability:
* 0018 New option for displaying a legend for the colors used in the timeline...
* 0405 Add CSV export to availability views...
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index 8b186f2..563fb51 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -523,7 +523,8 @@ def find_matching_services(aggr_type, what, calllist):
if middle in g_services_by_hostname:
entries = [ ((e[0], host_re), e[1]) for e in g_services_by_hostname[middle] ]
host_re = "(.*)"
- elif not honor_site and not '*' in host_re and not '$' in host_re and not '|' in host_re:
+ elif not honor_site and not '*' in host_re and not '$' in host_re \
+ and not '|' in host_re and not '[' in host_re:
# Exact host match
entries = [ ((e[0], host_re), e[1]) for e in g_services_by_hostname.get(host_re, []) ]
@@ -887,7 +888,8 @@ def match_host_tags(have_tags, required_tags):
def compile_leaf_node(host_re, service_re = config.HOST_STATE):
found = []
honor_site = SITE_SEP in host_re
- if not honor_site and not '*' in host_re and not '$' in host_re and not '|' in host_re:
+ if not honor_site and not '*' in host_re and not '$' in host_re \
+ and not '|' in host_re and '[' not in host_re:
entries = [ ((e[0], host_re), e[1]) for e in g_services_by_hostname.get(host_re, []) ]
else:
Module: check_mk
Branch: master
Commit: 2a598f5cc6ef52f1dadeef88cc6b4d3aae73d474
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2a598f5cc6ef52…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Feb 13 17:13:27 2014 +0100
cisco_fru_power: Cleaned up implementation
---
checkman/cisco_fru_power | 14 +++---
checks/cisco_fru_power | 125 +++++++++++++++++++++-------------------------
2 files changed, 63 insertions(+), 76 deletions(-)
diff --git a/checkman/cisco_fru_power b/checkman/cisco_fru_power
index 6218210..e10f686 100644
--- a/checkman/cisco_fru_power
+++ b/checkman/cisco_fru_power
@@ -6,15 +6,15 @@ distribution: check_mk
description:
This check monitors the administrative and operational status of field
replaceable unit (FRU) power supplies of Cisco switches. The check is
- {OK} when the administrative and operational state is {on}. The check is
- {CRIT} when the administrative state is {off} or the operational state
- is {offDenied}, {offEnvPower}, {offEnvTemp}, {offEnvFan}. {failed},
- {onButInlinePowerFail}. The check is {WARN} otherwise.
+ OK when the administrative and operational state is {on}. The check is
+ CRIT when the administrative state is {off} or the operational state
+ is {offDenied}, {offEnvPower}, {offEnvTemp}, {offEnvFan}, {failed},
+ or {onButInlinePowerFail}. The check is WARN otherwise.
item:
- The index of the power supply from the list of OIDs for the device.
+ The index of the power supply from the list of OIDs for the device, usually
+ starting with {1}.
inventory:
One check is created for each FRU power supply unit. Units are only included
- if they are not in the operational state {offEnvOther} and {offEnvPower}
-
+ if they are not in the operational state {offEnvOther} and {offEnvPower}.
diff --git a/checks/cisco_fru_power b/checks/cisco_fru_power
index f8188f0..2eba333 100644
--- a/checks/cisco_fru_power
+++ b/checks/cisco_fru_power
@@ -24,82 +24,69 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-# .1.3.6.1.4.1.9.9.13.1.5.1.2.1 "removed"
-# .1.3.6.1.4.1.9.9.13.1.5.1.2.2 "AC Power Supply"
-# .1.3.6.1.4.1.9.9.13.1.5.1.3.1 5
-# .1.3.6.1.4.1.9.9.13.1.5.1.3.2 1
-# .1.3.6.1.4.1.9.9.13.1.5.1.4.1 1
-# .1.3.6.1.4.1.9.9.13.1.5.1.4.2 2
-
# FRU = Field Replacable Unit
-# OID 1.3.6.1.4.1.9.9.117.1.1.2.1.2
-# Type PowerOperType
-# 1:offEnvOther
-# 2:on
-# 3:offAdmin
-# 4:offDenied
-# 5:offEnvPower
-# 6:offEnvTemp
-# 7:offEnvFan
-# 8:failed
-# 9:onButFanFail
-# 10:offCooling
-# 11:offConnectorRating
-# 12:onButInlinePowerFail
-#
-# OID 1.3.6.1.4.1.9.9.117.1.1.2.1.1
-# Type PowerAdminType
-# 1:on
-# 2:off
-# 3:inlineAuto
-# 4:inlineOn
-# 5:powerCycle
-#
+cisco_fru_poweradmin_types = {
+ '1': ( 'on', 0 ),
+ '2': ( 'off', 2 ),
+ '3': ( 'inlineAuto', 1 ),
+ '4': ( 'inlineOn', 1 ),
+ '5': ( 'powerCycle', 1 ),
+}
+
+cisco_fru_poweroper_types = {
+ '1' : ('offEnvOther', 1 ),
+ '2' : ('on', 0 ),
+ '3' : ('offAdmin', 1 ),
+ '4' : ('offDenied', 2 ),
+ '5' : ('offEnvPower', 2 ),
+ '6' : ('offEnvTemp', 2 ),
+ '7' : ('offEnvFan', 2 ),
+ '8' : ('failed', 2 ),
+ '9' : ('onButFanFail', 1 ),
+ '10': ('offCooling', 1 ),
+ '11': ('offConnectorRating', 1 ),
+ '12': ('onButInlinePowerFail', 2 ),
+}
+
+
+def inventory_cisco_fru_power(info):
+ # Monitor all devices that are not
+ # - with incomplete SNMP data
+ # - in state 1:offEnvOther
+ # - in state 5:offEnvPower
+ return [ (line[0], None)
+ for line in info
+ if line[2] not in ('', '1', '5') ]
+
+
+def check_cisco_fru_power(item, _no_params, info):
+ for oid_end, admin_state, oper_state in info:
+ if oid_end == item:
+ worst_state = 0
+ infotexts = []
+ for (name, state), title in [
+ ( cisco_fru_poweroper_types[oper_state], "Operational state" ),
+ ( cisco_fru_poweradmin_types[admin_state], "Administrative state" )]:
-def inventory_cisco_fru_power(info):
- return [ (line[0], None ) for line in info if saveint(line[2]) not in [ 0, 1, 5 ] ]
+ text = title + ": " + name
+ worst_state = max(state, worst_state)
+ if state == 1:
+ text += '(!)'
+ elif state == 2:
+ text += '(!!)'
+ infotexts.append(text)
-def check_cisco_fru_power(item, params, info):
- for line in info:
- if line[0] == item:
- power_oper_type = ('', 'offEnvOther', 'on', 'offAdmin', 'offDenied',
- 'offEnvPower', 'offEnvTemp', 'offEnvFan', 'failed',
- 'onButFanFail', 'offCooling', 'offConnectorRating',
- 'onButInlinePowerFail' )
- power_admin_type = ( '', 'on', 'off', 'inlineAuto', 'inlineOn', 'powercycle')
+ return worst_state, ", ".join(infotexts)
- admin_state, oper_state = map(saveint, line[1:3])
- admin_state_txt = power_admin_type[admin_state]
- oper_state_txt = power_oper_type[oper_state]
- admin_sym = ""
- oper_sym = ""
- if admin_state == 1 and oper_state == 2:
- state = 0
- elif admin_state == 2 or oper_state in ( 4,5,6,7,8,12):
- state = 2
- if admin_state == 2:
- admin_sym = "(!!)"
- if oper_state in ( 4,5,6,7,8,12):
- oper_sym = "(!!)"
- else:
- state = 1
- if admin_state not in (1,2):
- admin_sym = "(!)"
- if oper_state not in (2,4,5,6,7,8,12):
- oper_sym = "(!)"
- infotext = "Admin-State: %s%s, Oper-State: %s%s" % \
- (admin_state_txt, admin_sym, oper_state_txt, oper_sym)
- return (state, infotext)
+ return 3, "No FRU with this id found"
- return (3, "item not found in SNMP data")
check_info["cisco_fru_power"] = {
- 'check_function': check_cisco_fru_power,
- 'inventory_function': inventory_cisco_fru_power,
- 'service_description': 'FRU Power %s',
- 'snmp_info': ('.1.3.6.1.4.1.9.9.117.1.1.2.1', [ OID_END, '1', '2'] ),
- 'snmp_scan_function': \
- lambda oid: "cisco" in oid(".1.3.6.1.2.1.1.1.0").lower(),
+ 'check_function' : check_cisco_fru_power,
+ 'inventory_function' : inventory_cisco_fru_power,
+ 'service_description' : 'FRU Power %s',
+ 'snmp_info' : ('.1.3.6.1.4.1.9.9.117.1.1.2.1', [ OID_END, 1, 2 ] ),
+ 'snmp_scan_function' : lambda oid: "cisco" in oid(".1.3.6.1.2.1.1.1.0").lower(),
}
Module: check_mk
Branch: master
Commit: 90469813f9ad22a453b032066584e39f1d0a8053
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=90469813f9ad22…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Feb 13 16:17:53 2014 +0100
FIX Allowing upload of files without loading the whole file into memory
---
.werks/668 | 8 ++++++++
ChangeLog | 1 +
web/htdocs/htmllib.py | 15 +++++++++------
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/.werks/668 b/.werks/668
new file mode 100644
index 0000000..0ddd17f
--- /dev/null
+++ b/.werks/668
@@ -0,0 +1,8 @@
+Title: Allowing upload of files without loading the whole file into memory
+Level: 1
+Component: multisite
+Version: 1.2.5i1
+Date: 1392304629
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 5751d00..ceb207d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -217,6 +217,7 @@
* 0273 FIX: Fixed exceptions when modifying / cloning views...
* 0274 FIX: Fixed exception when view title or description was missing
* 0278 FIX: Fixed bookmark icon images for non-english user languages...
+ * 0668 FIX: Allowing upload of files without loading the whole file into memory
WATO:
* 0308 Multisite can now set rotation view permissions for NagVis...
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index c6985ed..b4802ae 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -1251,14 +1251,13 @@ class html:
self.load_tree_states()
self.treestates[tree] = val
- def parse_field_storage(self, fields):
+ def parse_field_storage(self, fields, handle_uploads_as_file_obj = False):
self.vars = {}
self.listvars = {} # for variables with more than one occurrance
self.uploads = {}
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
@@ -1267,19 +1266,23 @@ class html:
# put uploaded file infos into separate storage
if field.filename is not None:
- self.uploads[varname] = (field.filename, field.type, field.value)
+ if handle_uploads_as_file_obj:
+ value = field.file
+ else:
+ value = field.value
+ self.uploads[varname] = (field.filename, field.type, value)
else: # normal variable
# Multiple occurrance of a variable? Store in extra list dict
if varname in self.vars:
if varname in self.listvars:
- self.listvars[varname].append(value)
+ self.listvars[varname].append(field.value)
else:
- self.listvars[varname] = [ self.vars[varname], value ]
+ self.listvars[varname] = [ self.vars[varname], field.value ]
# In the single-value-store the last occurrance of a variable
# has precedence. That makes appending variables to the current
# URL simpler.
- self.vars[varname] = value
+ self.vars[varname] = field.value
def uploaded_file(self, varname, default = None):
return self.uploads.get(varname, default)