Module: check_mk
Branch: master
Commit: 6176f9c072b8e339e12ea483ae30db73131fcc67
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6176f9c072b8e3…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Thu Feb 26 12:04:37 2015 +0100
#1891 apc_symmetra: Now supports setting levels on remaining battery time
The WATO rule and check have been extended to allow setting levels on remaining
battery time. Doing so is optional.
---
.werks/1891 | 10 ++++++++++
ChangeLog | 1 +
checkman/apc_symmetra | 2 +-
checks/apc_symmetra | 4 ++--
web/plugins/wato/check_parameters.py | 8 ++++----
5 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/.werks/1891 b/.werks/1891
new file mode 100644
index 0000000..407de02
--- /dev/null
+++ b/.werks/1891
@@ -0,0 +1,10 @@
+Title: apc_symmetra: Now supports setting levels on remaining battery time
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i1
+Date: 1424948572
+Class: feature
+
+The WATO rule and check have been extended to allow setting levels on remaining
+battery time. Doing so is optional.
diff --git a/ChangeLog b/ChangeLog
index 6f9d88e..3bc4700 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -96,6 +96,7 @@
* 2036 docsis_channels_upstream: Add handling for codewords (WATO rule, rate computation, Perf-O-Meter)
* 1947 agent_ucs_bladecenter: Monitors UCS Bladecenter via Web-API...
* 2039 mk_logwatch: new per-logfile-options maxfilesize and maxlinesize...
+ * 1891 apc_symmetra: Now supports setting levels on remaining battery time...
* 1457 FIX: logins: new check renamed from "users" check...
NOTE: Please refer to the migration notes!
* 1762 FIX: lnx_thermal: Now ignoring trip points with level 0...
diff --git a/checkman/apc_symmetra b/checkman/apc_symmetra
index 89d8a44..d8ea32f 100644
--- a/checkman/apc_symmetra
+++ b/checkman/apc_symmetra
@@ -80,7 +80,7 @@ parameters(dict): parameters is a dictionary with the following keys:
critical level for the battery capacity in the post-calibration phase in precent. {"additional_time_span"}
is a time span the post-calibration phase is extended past the day of the calibration in minutes.
- {"battime"}: A tuple (warn(int), crit(int)) of levels for the remaining battery time in minutes.
+ {"battime"}: A tuple (warn(int), crit(int)) of levels for the remaining battery time in seconds.
This key is optional.
parameters(tuple): The old format of a tuple of 4 values is also still supported, containing what
diff --git a/checks/apc_symmetra b/checks/apc_symmetra
index b0d9021..78d3986 100644
--- a/checks/apc_symmetra
+++ b/checks/apc_symmetra
@@ -202,10 +202,10 @@ def check_apc(item, params, info):
label = ""
if params.get('battime'):
battime_warn, battime_crit = params['battime']
- if int(RunTimeRemaining) / 60 <= battime_crit:
+ if int(RunTimeRemaining) <= battime_crit:
battime_state = 2
label = "(!!)"
- elif int(RunTimeRemaining) / 60 <= battime_warn:
+ elif int(RunTimeRemaining) <= battime_warn:
battime_state = 1
label = "(!)"
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 066b889..f3e5f49 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -6159,17 +6159,17 @@ register_check_parameters(
Tuple(
title = _("Time left on battery"),
elements = [
- Integer(
+ Age(
title = _("Warning at"),
help = _("Time left on Battery at and below which a warning state is triggered"),
- unit = _("min"),
default_value = 0,
+ display = [ "hours", "minutes" ]
),
- Integer(
+ Age(
title = _("Critical at"),
help = _("Time Left on Battery at and below which a critical state is triggered"),
- unit = _("min"),
default_value = 0,
+ display = [ "hours", "minutes" ]
),
],
),
Module: check_mk
Branch: master
Commit: 548e4992486dce6d3f6aa70c81e8745a779fcbac
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=548e4992486dce…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Thu Feb 26 11:46:42 2015 +0100
apc_symmetra: Now supports setting levels on remaining battery time
---
checkman/apc_symmetra | 5 ++++-
checks/apc_symmetra | 13 ++++++++++++-
web/plugins/wato/check_parameters.py | 22 ++++++++++++++++++++--
3 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/checkman/apc_symmetra b/checkman/apc_symmetra
index a05c1d6..89d8a44 100644
--- a/checkman/apc_symmetra
+++ b/checkman/apc_symmetra
@@ -71,7 +71,7 @@ inventory:
and if the name of this OID is known to the test. If this is true the system is inventorized.
[parameters]
-parameters(dict): parameters is a dictionary with two keys
+parameters(dict): parameters is a dictionary with the following keys:
{"levels"}: a tuple of critical levels for battery capacity, temperature, current and output
voltage. The numbers are integers.
@@ -80,6 +80,9 @@ parameters(dict): parameters is a dictionary with two keys
critical level for the battery capacity in the post-calibration phase in precent. {"additional_time_span"}
is a time span the post-calibration phase is extended past the day of the calibration in minutes.
+ {"battime"}: A tuple (warn(int), crit(int)) of levels for the remaining battery time in minutes.
+ This key is optional.
+
parameters(tuple): The old format of a tuple of 4 values is also still supported, containing what
is found in the key {"levels"} in the dictionary.
diff --git a/checks/apc_symmetra b/checks/apc_symmetra
index 4efbd42..b0d9021 100644
--- a/checks/apc_symmetra
+++ b/checks/apc_symmetra
@@ -196,9 +196,20 @@ def check_apc(item, params, info):
# 9. run time remaining
# RunTimeRemaining formatiert == "26:00.00"
+ battime_state = 0
hrs = int(RunTimeRemaining) / 3600
mins, secs = divmod(int(RunTimeRemaining) % 3600, 60)
- single_states.append( (0, "run time remaining: %02d:%02d:%02d" % (hrs, mins, secs),
+ label = ""
+ if params.get('battime'):
+ battime_warn, battime_crit = params['battime']
+ if int(RunTimeRemaining) / 60 <= battime_crit:
+ battime_state = 2
+ label = "(!!)"
+ elif int(RunTimeRemaining) / 60 <= battime_warn:
+ battime_state = 1
+ label = "(!)"
+
+ single_states.append( (battime_state, "run time remaining: %02d:%02d:%02d%s" % (hrs, mins, secs, label),
("runtime", RunTimeRemaining/60)) )
# 10. Adv Output load (load in percent)
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 8dfa121..1e895f2 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -6155,8 +6155,26 @@ register_check_parameters(
],
optional_keys = False,
)),
- ],
- optional_keys = ['post_calibration_levels', 'output_load'],
+ ("battime",
+ Tuple(
+ title = _("Time left on battery"),
+ elements = [
+ Integer(
+ title = _("Warning at"),
+ help = _("Time left on Battery at and below which a warning state is triggered"),
+ unit = _("min"),
+ default_value = 0,
+ ),
+ Integer(
+ title = _("Critical at"),
+ help = _("Time Left on Battery at and below which a critical state is triggered"),
+ unit = _("min"),
+ default_value = 0,
+ ),
+ ],
+ ),
+ )],
+ optional_keys = ['post_calibration_levels', 'output_load', 'battime'],
),
forth = apc_convert_from_tuple
),
Module: check_mk
Branch: master
Commit: 0c27c50386c91ecb11de9d0a74762067f0dc468d
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0c27c50386c91e…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Feb 26 10:51:24 2015 +0100
#2039 mk_logwatch: new per-logfile-options maxfilesize and maxlinesize
These options allow you to truncated too long lines (in order to save space
and processing time for excessivly long lines) and to get a warning if the
size of a logfile is too large. Please refer to the online documentation
for details.
---
.werks/2039 | 13 +++++++++++++
ChangeLog | 1 +
agents/plugins/.f12 | 2 +-
agents/plugins/mk_logwatch | 41 ++++++++++++++++++++++++++++-------------
4 files changed, 43 insertions(+), 14 deletions(-)
diff --git a/.werks/2039 b/.werks/2039
new file mode 100644
index 0000000..8ed32bb
--- /dev/null
+++ b/.werks/2039
@@ -0,0 +1,13 @@
+Title: mk_logwatch: new per-logfile-options maxfilesize and maxlinesize
+Level: 1
+Component: checks
+Class: feature
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1424944221
+
+These options allow you to truncated too long lines (in order to save space
+and processing time for excessivly long lines) and to get a warning if the
+size of a logfile is too large. Please refer to the online documentation
+for details.
diff --git a/ChangeLog b/ChangeLog
index 287f6fe..95f40b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -95,6 +95,7 @@
* 1862 netscaler_vserver: new check to monitor VServers on Citrix Netscaler Appliance
* 2036 docsis_channels_upstream: Add handling for codewords (WATO rule, rate computation, Perf-O-Meter)
* 1947 agent_ucs_bladecenter: Monitors UCS Bladecenter via Web-API...
+ * 2039 mk_logwatch: new per-logfile-options maxfilesize and maxlinesize...
* 1457 FIX: logins: new check renamed from "users" check...
NOTE: Please refer to the migration notes!
* 1762 FIX: lnx_thermal: Now ignoring trip points with level 0...
diff --git a/agents/plugins/.f12 b/agents/plugins/.f12
index 5d08296..184bd99 100755
--- a/agents/plugins/.f12
+++ b/agents/plugins/.f12
@@ -3,4 +3,4 @@ SITE=${SITE:-$(cat ../../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
# sudo mkdir -p /usr/lib/check_mk_agent/plugins
# sudo install -m 755 * /usr/lib/check_mk_agent/plugins || true
-sudo install -m 755 * /omd/sites/$SITE/share/check_mk/agents/plugins
+sudo rsync --delete -va ./ /omd/sites/$SITE/share/check_mk/agents/plugins/
diff --git a/agents/plugins/mk_logwatch b/agents/plugins/mk_logwatch
index d4ec518..ff77b5a 100755
--- a/agents/plugins/mk_logwatch
+++ b/agents/plugins/mk_logwatch
@@ -157,7 +157,7 @@ def save_status(status):
f.write("%s|%d|%d\n" % (filename, offset, inode))
pushed_back_line = None
-def next_line(f):
+def next_line(file_handle):
global pushed_back_line
if pushed_back_line != None:
line = pushed_back_line
@@ -165,7 +165,7 @@ def next_line(f):
return line
else:
try:
- line = f.next()
+ line = file_handle.next()
return line
except:
return None
@@ -179,8 +179,8 @@ def process_logfile(logfile, patterns):
# before, we set the offset to -1
offset, prev_inode = status.get(logfile, (-1, -1))
try:
- fl = os.open(logfile, os.O_RDONLY)
- inode = os.fstat(fl)[1] # 1 = st_ino
+ file_desc = os.open(logfile, os.O_RDONLY)
+ inode = os.fstat(file_desc)[1] # 1 = st_ino
except:
if debug:
raise
@@ -190,7 +190,7 @@ def process_logfile(logfile, patterns):
print "[[[%s]]]" % logfile
# Seek to the current end in order to determine file size
- current_end = os.lseek(fl, 0, 2) # os.SEEK_END not available in Python 2.4
+ current_end = os.lseek(file_desc, 0, 2) # os.SEEK_END not available in Python 2.4
status[logfile] = current_end, inode
# If we have never seen this file before, we just set the
@@ -223,25 +223,29 @@ def process_logfile(logfile, patterns):
offset = 0
# now seek to offset where interesting data begins
- os.lseek(fl, offset, 0) # os.SEEK_SET not available in Python 2.4
- f = os.fdopen(fl)
+ os.lseek(file_desc, offset, 0) # os.SEEK_SET not available in Python 2.4
+ file_handle = os.fdopen(file_desc)
worst = -1
outputtxt = ""
lines_parsed = 0
start_time = time.time()
while True:
- line = next_line(f)
+ line = next_line(file_handle)
if line == None:
break # End of file
+ # Handle option maxlinesize
+ if opt_maxlinesize != None and len(line) > opt_maxlinesize:
+ line = line[:opt_maxlinesize] + "[TRUNCATED]\n"
+
lines_parsed += 1
# Check if maximum number of new log messages is exceeded
if opt_maxlines != None and lines_parsed > opt_maxlines:
outputtxt += "%s Maximum number (%d) of new log messages exceeded.\n" % (
opt_overflow, opt_maxlines)
worst = max(worst, opt_overflow_level)
- os.lseek(fl, 0, 2) # Seek to end of file, skip all other messages
+ os.lseek(file_desc, 0, 2) # Seek to end of file, skip all other messages
break
# Check if maximum processing time (per file) is exceeded. Check only
@@ -251,7 +255,7 @@ def process_logfile(logfile, patterns):
outputtxt += "%s Maximum parsing time (%.1f sec) of this log file exceeded.\n" % (
opt_overflow, opt_maxtime)
worst = max(worst, opt_overflow_level)
- os.lseek(fl, 0, 2) # Seek to end of file, skip all other messages
+ os.lseek(file_desc, 0, 2) # Seek to end of file, skip all other messages
break
level = "."
@@ -266,14 +270,14 @@ def process_logfile(logfile, patterns):
for cont_pattern in cont_patterns:
if type(cont_pattern) == int: # add that many lines
for x in range(cont_pattern):
- cont_line = next_line(f)
+ cont_line = next_line(file_handle)
if cont_line == None: # end of file
break
line = line[:-1] + "\1" + cont_line
else: # pattern is regex
while True:
- cont_line = next_line(f)
+ cont_line = next_line(file_handle)
if cont_line == None: # end of file
break
elif cont_pattern.search(cont_line[:-1]):
@@ -299,7 +303,7 @@ def process_logfile(logfile, patterns):
continue
outputtxt += "%s%s %s%s\n" % (color, level, line[:-1], tty_normal)
- new_offset = os.lseek(fl, 0, 1) # os.SEEK_CUR not available in Python 2.4
+ new_offset = os.lseek(file_desc, 0, 1) # os.SEEK_CUR not available in Python 2.4
status[logfile] = new_offset, inode
# output all lines if at least one warning, error or ok has been found
@@ -307,6 +311,11 @@ def process_logfile(logfile, patterns):
sys.stdout.write(outputtxt)
sys.stdout.flush()
+ # Handle option maxfilesize, regardless of warning or errors that have happened
+ if opt_maxfilesize != None and offset <= opt_maxfilesize and new_offset > opt_maxfilesize:
+ sys.stdout.write("%sW Maximum allowed logfile size (%d bytes) exceeded.%s\n" % (tty_yellow, opt_maxfilesize, tty_normal))
+
+
try:
config = read_config()
except Exception, e:
@@ -329,6 +338,8 @@ for filenames, patterns in config:
# Initialize options with default values
opt_maxlines = None
opt_maxtime = None
+ opt_maxlinesize = None
+ opt_maxfilesize = None
opt_regex = None
opt_overflow = 'C'
opt_overflow_level = 2
@@ -340,6 +351,10 @@ for filenames, patterns in config:
opt_maxlines = int(value)
elif key == 'maxtime':
opt_maxtime = float(value)
+ elif key == 'maxlinesize':
+ opt_maxlinesize = int(value)
+ elif key == 'maxfilesize':
+ opt_maxfilesize = int(value)
elif key == 'overflow':
if value not in [ 'C', 'I', 'W', 'O' ]:
raise Exception("Invalid value %s for overflow. Allowed are C, I, O and W" % value)