Module: check_mk
Branch: master
Commit: 066130df18a6f4aa8fb1d5be864e9ae23339805f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=066130df18a6f4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jan 30 12:11:59 2015 +0100
Fixed exception about missing variable "in_timerange" in fileinfo check
---
checks/fileinfo | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/checks/fileinfo b/checks/fileinfo
index a33350a..281f6b9 100644
--- a/checks/fileinfo
+++ b/checks/fileinfo
@@ -107,13 +107,14 @@ def check_fileinfo(item, params, info):
if len(info) == 0:
return (3, "no information sent by agent")
- outof_range = fileinfo_check_timeranges(params)
+ outof_range_txt = fileinfo_check_timeranges(params)
+ in_timerange = outof_range_txt == None
reftime = int(info[0][0])
check_definition = False
for line in info[1:]:
if item == line[0]:
if line[1] == "missing":
- return in_timerange and 3 or 0, "File not found" + outof_range
+ return in_timerange and 3 or 0, "File not found" +
outof_range_txt
state = 0
size = int(line[1])
age = reftime - int(line[2])
@@ -123,8 +124,8 @@ def check_fileinfo(item, params, info):
("age", age, get_age_human_readable) ]
if check_definition == False:
- return in_timerange and 3 or 0, "File not found" + outof_range
- return fileinfo_check_function(check_definition, params, outof_range)
+ return in_timerange and 3 or 0, "File not found" + outof_range_txt
+ return fileinfo_check_function(check_definition, params, outof_range_txt)
# Extracts patterns that are relevant for the current host and item.
# Constructs simple list of patterns and makes them available for the check
@@ -143,7 +144,7 @@ def check_fileinfo_groups(item, params, info):
if not info:
return 3, "No information sent by agent"
- outof_range = fileinfo_check_timeranges(params)
+ outof_range_txt = fileinfo_check_timeranges(params)
import fnmatch
reftime = int(info[0][0])
@@ -207,9 +208,9 @@ def check_fileinfo_groups(item, params, info):
if date_inclusion:
check_definition.append(("date pattern", date_inclusion, str ))
- return fileinfo_check_function(check_definition, params, outof_range)
+ return fileinfo_check_function(check_definition, params, outof_range_txt)
-def fileinfo_check_function(check_definition, params, outof_range):
+def fileinfo_check_function(check_definition, params, outof_range_txt):
import operator
state = 0
infos = []
@@ -230,9 +231,9 @@ def fileinfo_check_function(check_definition, params, outof_range):
infos[-1] += " (%s %s)(!)" % (comp, verbfunc(warn))
perfdata.append((what, val, warn, crit))
infotext = ", ".join(infos)
- if outof_range:
+ if outof_range_txt:
state = 0
- infotext += outof_range
+ infotext += outof_range_txt
return (state, infotext, perfdata)