From 4e1e1f90fcd07daff23465f4237d09419d490bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20R=C4=83dulescu?= Date: Wed, 16 Apr 2014 12:12:36 +0000 Subject: [PATCH 1/2] overview: Added graphs as tooltip for memory when usage over 70% When memory usage is above warning level hovering over the value shows the graph with usage in the last 24 hours. --- inc/html.inc.php | 8 ++++---- layout/style.css | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/inc/html.inc.php b/inc/html.inc.php index 01e7328..63788b5 100644 --- a/inc/html.inc.php +++ b/inc/html.inc.php @@ -235,13 +235,13 @@ function host_summary($cat, $hosts) { if (isset($rrd_info_mu[$info]) && isset($rrd_info_mf[$info]) && isset($rrd_info_bf[$info]) && isset($rrd_info_ca[$info]) ) { $percent_mem = $rrd_info_mu[$info] * 100 / ($rrd_info_mu[$info] + $rrd_info_mf[$info] + $rrd_info_bf[$info] + $rrd_info_ca[$info]); - $class = ''; + $data_val = ''.(int)$percent_mem.'%'; if ($percent_mem > 90) - $class = ' class="crit"'; + $data_val = ''.(int)$percent_mem.'%'; elseif ($percent_mem > 70) - $class = ' class="warn"'; + $data_val = ''.(int)$percent_mem.'%'; - printf('%d%%', $class, $percent_mem); + print($data_val); } } diff --git a/layout/style.css b/layout/style.css index 3d5c94b..3564acd 100644 --- a/layout/style.css +++ b/layout/style.css @@ -43,6 +43,35 @@ a:hover { text-decoration: underline; } +a.tooltip { + border-bottom: dotted 1px blue; +} + +a.tooltip > span { + opacity: 0; + visibility: hidden; position: absolute; + -webkit-transition-property: opacity, visibility; + -webkit-transition-duration: 0.4s, 0.4s; + -webkit-transition-timing-function: ease-in-out, ease-in-out; + -moz-transition-property: opacity, visibility; + -moz-transition-duration: 0.4s, 0.4s; + -moz-transition-timing-function: ease-in-out, ease-in-out; + -o-transition-property: opacity, visibility; + -o-transition-duration: 0.4s, 0.4s; + -o-transition-timing-function: ease-in-out, ease-in-out; + transition-property: opacity, visibility; + transition-duration: 0.4s, 0.4s; + transition-timing-function: ease-in-out, ease-in-out; +} + +a.tooltip:hover > span { + opacity: 1; + text-decoration: none; + visibility: visible; + overflow: visible; + display: inline; +} + table.summary th { width: 300px; font-weight: normal; From a8a238c59c3ec3a9d953e4774945a51499485771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20R=C4=83dulescu?= Date: Wed, 16 Apr 2014 13:27:33 +0000 Subject: [PATCH 2/2] overview: show used disk percentage for rootfs --- conf/config.php | 1 + inc/html.inc.php | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/conf/config.php b/conf/config.php index 86b0870..4cc610e 100644 --- a/conf/config.php +++ b/conf/config.php @@ -29,6 +29,7 @@ # show load averages and used memory on overview page $CONFIG['showload'] = true; $CONFIG['showmem'] = false; +$CONFIG['showroot'] = false; $CONFIG['term'] = array( '2hour' => 3600 * 2, diff --git a/inc/html.inc.php b/inc/html.inc.php index 63788b5..01a5a12 100644 --- a/inc/html.inc.php +++ b/inc/html.inc.php @@ -245,6 +245,51 @@ function host_summary($cat, $hosts) { } } + if ($CONFIG['showroot']) { + if ($CONFIG['version'] == 4) { + $rrd_info_df = $rrd->rrd_info($CONFIG['datadir'].'/'.$host.'/df/df-root.rrd'); + + # ignore if file does not exist + if (!$rrd_info_df) + continue; + + if (isset($rrd_info_df["ds[free].last_ds"])) { + $total_disk = $rrd_info_df["ds[used].last_ds"] + $rrd_info_df["ds[free].last_ds"]; + # We assume 5% is allocated only for root because this is the default setting. + $percent_disk = ( $rrd_info_df["ds[used].last_ds"] + 5 * $total_disk / 100 ) * 100 / $total_disk; + + $data_val = ''.(int)$percent_disk.'%'; + if ($percent_disk > 90) + $data_val = ''.(int)$percent_disk.'%'; + elseif ($percent_disk > 70) + $data_val = ''.(int)$percent_disk.'%'; + + print($data_val); + } + + } elseif ($CONFIG['version'] == 5) { + $rrd_info_dff = $rrd->rrd_info($CONFIG['datadir'].'/'.$host.'/df-root/df_complex-free.rrd'); + $rrd_info_dfu = $rrd->rrd_info($CONFIG['datadir'].'/'.$host.'/df-root/df_complex-reserved.rrd'); + $rrd_info_dfr = $rrd->rrd_info($CONFIG['datadir'].'/'.$host.'/df-root/df_complex-used.rrd'); + + # ignore if file does not exist + if (!$rrd_info_dff || !$rrd_info_dfu || !$rrd_info_dfr) + continue; + + if (isset($rrd_info_dff["ds[value].last_ds"]) && isset($rrd_info_dfu["ds[value].last_ds"]) && isset($rrd_info_dfr["ds[value].last_ds"])) { + $percent_disk = ($rrd_info_dfu["ds[value].last_ds"] + $rrd_info_dfr["ds[value].last_ds"]) * 100 / ($rrd_info_dff["ds[value].last_ds"] + $rrd_info_dfu["ds[value].last_ds"] + $rrd_info_dfr["ds[value].last_ds"]); + + $data_val = ''.(int)$percent_disk.'%'; + if ($percent_disk > 90) + $data_val = ''.(int)$percent_disk.'%'; + elseif ($percent_disk > 70) + $data_val = ''.(int)$percent_disk.'%'; + + print($data_val); + } + } + } + print "\n"; }