Module: check_mk
Branch: master
Commit: 8a96ba625f27c3b925622b3c6a8c5ae70d75a505
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8a96ba625f27c3…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Dec 9 08:38:22 2010 +0100
Applied patches from Josef Hack to make the uptime check show up days:
0002-Uptime-modify-pluginoutput-to-see-days.patch
0003-Uptime-pnp4nagios-template-Convert-Graph-to-days-and.patch
Thanks Josef Hack!
---
checks/uptime | 5 +++--
pnp-templates/check_mk-uptime.php | 10 ++++++----
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/checks/uptime b/checks/uptime
index 0a43080..051a40b 100644
--- a/checks/uptime
+++ b/checks/uptime
@@ -33,10 +33,11 @@ def check_uptime(_no_item, _no_params, info):
seconds = uptime % 60
rem = uptime / 60
minutes = rem % 60
- hours = rem / 60
+ hours = (rem % 1440) / 60
+ days = rem / 1440
now = int(time.time())
since = time.strftime("%c", time.localtime(now - uptime))
- return (0, "OK - up since %s (%d:%02d:%02d)" % (since, hours, minutes,
seconds), [ ("uptime", uptime) ])
+ return (0, "OK - up since %s (%dd %02d:%02d:%02d)" % (since, days, hours,
minutes, seconds), [ ("uptime", uptime) ])
check_info["uptime"] = (check_uptime, "Uptime", 1, inventory_uptime)
diff --git a/pnp-templates/check_mk-uptime.php b/pnp-templates/check_mk-uptime.php
index 7eaa652..52de72e 100644
--- a/pnp-templates/check_mk-uptime.php
+++ b/pnp-templates/check_mk-uptime.php
@@ -23,10 +23,12 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-$opt[1] = "--vertical-label 'Uptime (s)' -l0 --title \"Uptime (time
since last reboot)\" ";
+$opt[1] = "--vertical-label 'Uptime (d)' -l0 --title \"Uptime (time
since last reboot)\" ";
-$def[1] = "DEF:uptime=$RRDFILE[1]:$DS[1]:MAX ";
-$def[1] .= "AREA:uptime#80f000:\"Uptime (sec)\" ";
+$def[1] = "DEF:sec=$RRDFILE[1]:$DS[1]:MAX ";
+$def[1] .= "CDEF:uptime=sec,86400,/ ";
+$def[1] .= "AREA:uptime#80f000:\"Uptime (days)\" ";
$def[1] .= "LINE:uptime#408000 ";
-
+$def[1] .= "GPRINT:uptime:LAST:\"%7.2lf %s LAST\" ";
+$def[1] .= "GPRINT:uptime:MAX:\"%7.2lf %s MAX\" ";
?>