Module: check_mk
Branch: master
Commit: 3ab26207db81d61f071a1ce79b5f634010da2320
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3ab26207db81d6…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Mar 17 11:13:08 2011 +0100
diskstat: output warn/crit levels in graph
---
checks/diskstat | 11 ++++++++---
pnp-templates/check_mk-diskstat.php | 26 +++++++++++++++++++-------
2 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/checks/diskstat b/checks/diskstat
index 8a919d6..7324ef7 100644
--- a/checks/diskstat
+++ b/checks/diskstat
@@ -76,11 +76,18 @@ def check_diskstat_line(this_time, item, params, line):
for what, ctr in [ ("read", line[5]), ("write", line[9]) ]:
countername = "diskstat.%s.%s" % (item, what)
+ # unpack levels now, need also for perfdata
+ levels = params.get(what)
+ if levels:
+ warn, crit = levels
+ else:
+ warn, crit = None, None
+
# compute IO rate in bytes/sec
timedif, sectors_per_sec = get_counter(countername, this_time, int(ctr))
bytes_per_sec = sectors_per_sec * 512
infos.append("%s/sec %s" % (get_bytes_human_readable(bytes_per_sec),
what))
- perfdata.append( (what, bytes_per_sec) )
+ perfdata.append( (what, bytes_per_sec, warn, crit) )
# compute average of the rate over ___ minutes
if average_range != None:
@@ -89,10 +96,8 @@ def check_diskstat_line(this_time, item, params, line):
bytes_per_sec = avg
# check levels
- levels = params.get(what)
if levels != None:
mb_per_sec = bytes_per_sec / 1048576
- warn, crit = levels
if mb_per_sec >= crit:
status = 2
infos[-1] += "!!"
diff --git a/pnp-templates/check_mk-diskstat.php b/pnp-templates/check_mk-diskstat.php
index 23cb413..a39119f 100644
--- a/pnp-templates/check_mk-diskstat.php
+++ b/pnp-templates/check_mk-diskstat.php
@@ -36,9 +36,9 @@ if (isset($DS[2])) {
"DEF:read=$RRDFILE[1]:$DS[1]:MAX ".
"CDEF:read_mb=read,1048576,/ ".
"AREA:read_mb#40c080:\"Read \" ".
- "GPRINT:read_mb:LAST:\"%6.1lf MByte/s last\" ".
- "GPRINT:read_mb:AVERAGE:\"%6.1lf MByte/s avg\" ".
- "GPRINT:read_mb:MAX:\"%6.1lf MByte/s max\\n\" ";
+ "GPRINT:read_mb:LAST:\"%8.1lf MB/s last\" ".
+ "GPRINT:read_mb:AVERAGE:\"%6.1lf MB/s avg\" ".
+ "GPRINT:read_mb:MAX:\"%6.1lf MB/s max\\n\" ";
# read average
if (isset($DS[3])) {
@@ -53,12 +53,24 @@ if (isset($DS[2])) {
"DEF:write=$RRDFILE[2]:$DS[2]:MAX ".
"CDEF:write_mb=write,1048576,/ ".
"CDEF:write_mb_neg=write_mb,-1,* ".
- "AREA:write_mb_neg#4080c0:Write ".
- "GPRINT:write_mb:LAST:\"%6.1lf MByte/s last\" ".
- "GPRINT:write_mb:AVERAGE:\"%6.1lf MByte/s avg\" ".
- "GPRINT:write_mb:MAX:\"%6.1lf MByte/s max\\n\" ".
+ "AREA:write_mb_neg#4080c0:\"Write \" ".
+ "GPRINT:write_mb:LAST:\"%6.1lf MB/s last\" ".
+ "GPRINT:write_mb:AVERAGE:\"%6.1lf MB/s avg\" ".
+ "GPRINT:write_mb:MAX:\"%6.1lf MB/s max\\n\" ".
"";
+ # show levels for read
+ if ($WARN[1]) {
+ $def[1] .= "HRULE:$WARN[1]#ffd000:\"Warning for read at " .
sprintf("%6.1f", $WARN[1]) . " MB/s \" ";
+ $def[1] .= "HRULE:$CRIT[1]#ff0000:\"Critical for read at " .
sprintf("%6.1f", $CRIT[1]) . " MB/s\\n\" ";
+ }
+
+ # show levels for write
+ if ($WARN[2]) {
+ $def[1] .= "HRULE:-$WARN[2]#ffd000:\"Warning for write at " .
sprintf("%6.1f", $WARN[2]) . " MB/s \" ";
+ $def[1] .= "HRULE:-$CRIT[2]#ff0000:\"Critical for write at " .
sprintf("%6.1f", $CRIT[2]) . " MB/s\\n\" ";
+ }
+
# write average
if (isset($DS[3])) {
$def[1] .=