From efd9d30ee7e1afc2144f31c6c88b4bddbf8e4767 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Mon, 25 Apr 2011 17:15:36 +0000 Subject: [PATCH] move percentage colour mappings to function. make graphs for memory/storage match percentage colours (should we do this for others?) git-svn-id: http://www.observium.org/svn/observer/trunk@2160 61d68cd4-352d-0410-923a-c4978735b2b8 --- database-update.sql | 1 + html/includes/functions.inc.php | 15 +++++++++- html/includes/graphs/mempool/usage.inc.php | 28 ++++++++++--------- html/includes/graphs/storage/usage.inc.php | 15 ++++++---- html/pages/bill.inc.php | 9 ++---- html/pages/bills.inc.php | 13 ++++----- html/pages/device/health/diskio.inc.php | 8 +----- html/pages/device/health/mempool.inc.php | 10 +++---- html/pages/device/health/processor.inc.php | 12 +++----- html/pages/device/health/storage.inc.php | 10 ++----- html/pages/device/overview/mempools.inc.php | 10 ++----- html/pages/device/overview/processors.inc.php | 10 ++----- html/pages/device/overview/storage.inc.php | 10 ++----- html/pages/health/mempool.inc.php | 14 +++------- html/pages/health/processor.inc.php | 10 ++----- html/pages/health/storage.inc.php | 8 ++---- html/pages/storage.inc.php | 10 ++----- includes/polling/mempools.inc.php | 3 +- 18 files changed, 82 insertions(+), 114 deletions(-) diff --git a/database-update.sql b/database-update.sql index a054e69677..fdbd9fcdf4 100644 --- a/database-update.sql +++ b/database-update.sql @@ -37,3 +37,4 @@ ALTER TABLE `mac_accounting` CHANGE `peer_mac` `mac` VARCHAR( 32 ) CHARACTER ALTER TABLE `mac_accounting` DROP `peer_ip`, DROP `peer_desc`, DROP `peer_asn`; UPDATE sensors SET sensor_class='frequency' WHERE sensor_class='freq'; ALTER TABLE `cef_switching` ADD `cef_switching_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST; +ALTER TABLE `mempools` ADD `mempool_perc` INT NOT NULL AFTER `device_id`; diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 75ad5e3a02..ad4df7734f 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -1,5 +1,18 @@ '90') { $background['left']='c4323f'; $background['right']='C96A73'; } + elseif ($percentage > '75') { $background['left']='bf5d5b'; $background['right']='d39392'; } + elseif ($percentage > '50') { $background['left']='bf875b'; $background['right']='d3ae92'; } + elseif ($percentage > '25') { $background['left']='5b93bf'; $background['right']='92b7d3'; } + else { $background['left']='9abf5b'; $background['right']='bbd392'; } + + return($background); + +} + function generate_device_link($device, $text=0, $linksuffix="", $start=0, $end=0) { global $twoday, $day, $now, $config; @@ -388,4 +401,4 @@ function getlocations() return $locations; } -?> \ No newline at end of file +?> diff --git a/html/includes/graphs/mempool/usage.inc.php b/html/includes/graphs/mempool/usage.inc.php index 2ccc3f178d..ba8e01333f 100644 --- a/html/includes/graphs/mempool/usage.inc.php +++ b/html/includes/graphs/mempool/usage.inc.php @@ -8,21 +8,23 @@ $iter = "1"; $rrd_options .= " COMMENT:' Used\\n'"; -if ($iter=="1") { $colour="CC0000"; } elseif ($iter=="2") { $colour="008C00"; } elseif ($iter=="3") { $colour="4096EE"; } -elseif ($iter=="4") { $colour="73880A"; } elseif ($iter=="5") { $colour="D01F3C"; } elseif ($iter=="6") { $colour="36393D"; } -elseif ($iter=="7") { $colour="FF0084"; unset($iter); } +$colour="CC0000"; +$colour_area="ffaaaa"; $descr = substr(str_pad(short_hrDeviceDescr($mempool['mempool_descr']), 24),0,24); $descr = str_replace(":", "\:", $descr); -$rrd_options .= " DEF:mempoolfree=$rrd_filename:free:AVERAGE "; -$rrd_options .= " DEF:mempoolused=$rrd_filename:used:AVERAGE "; -$rrd_options .= " CDEF:mempooltotal=mempoolused,mempoolfree,+ "; -$rrd_options .= " CDEF:mempoolperc=mempoolused,mempoolused,mempoolfree,+,/,100,* "; -$rrd_options .= " LINE1:mempoolperc#" . $colour . ":'" . $descr . "' "; -$rrd_options .= " GPRINT:mempoolused:LAST:%6.2lf%sB"; -#$rrd_options .= " GPRINT:mempooltotal:LAST:%6.2lf%sB"; -$rrd_options .= " GPRINT:mempoolperc:LAST:%3.0lf%%\\\\n"; -#$rrd_options .= " GPRINT:mempoolperc:MAX:%3.0lf"; +$perc = round($mempool['mempool_perc'], 0); +$background = get_percentage_colours($perc); -?> \ No newline at end of file +$rrd_options .= " DEF:$mempool[mempool_id]used=$rrd_filename:used:AVERAGE"; +$rrd_options .= " DEF:$mempool[mempool_id]free=$rrd_filename:free:AVERAGE"; +$rrd_options .= " CDEF:$mempool[mempool_id]size=$mempool[mempool_id]used,$mempool[mempool_id]free,+"; +$rrd_options .= " CDEF:$mempool[mempool_id]perc=$mempool[mempool_id]used,$mempool[mempool_id]size,/,100,*"; +$rrd_options .= " AREA:$mempool[mempool_id]perc#" . $background['right'] . ":"; +$rrd_options .= " LINE1.25:$mempool[mempool_id]perc#" . $background['left'] . ":'$descr'"; +$rrd_options .= " GPRINT:$mempool[mempool_id]size:LAST:%6.2lf%sB"; +$rrd_options .= " GPRINT:$mempool[mempool_id]free:LAST:%6.2lf%sB"; +$rrd_options .= " GPRINT:$mempool[mempool_id]perc:LAST:%5.2lf%%\\\\n"; + +?> diff --git a/html/includes/graphs/storage/usage.inc.php b/html/includes/graphs/storage/usage.inc.php index 712c0cd36a..feba9d11c0 100644 --- a/html/includes/graphs/storage/usage.inc.php +++ b/html/includes/graphs/storage/usage.inc.php @@ -13,21 +13,24 @@ $rrd_options .= " COMMENT:' Size Free % Used\\n'"; $hostname = gethostbyid($storage['device_id']); -if ($iter=="1") { $colour="CC0000"; } elseif ($iter=="2") { $colour="008C00"; } elseif ($iter=="3") { $colour="4096EE"; } -elseif ($iter=="4") { $colour="73880A"; } elseif ($iter=="5") { $colour="D01F3C"; } elseif ($iter=="6") { $colour="36393D"; } -elseif ($iter=="7") { $colour="FF0084"; $iter = "0"; } +$colour="CC0000"; +$colour_area="ffaaaa"; $descr = substr(str_pad($storage[storage_descr], 12),0,12); $descr = str_replace(":","\:",$descr); +$percentage = round($storage['storage_perc'], 0); + +$background = get_percentage_colours($percentage); + $rrd_options .= " DEF:$storage[storage_id]used=$rrd_filename:used:AVERAGE"; $rrd_options .= " DEF:$storage[storage_id]free=$rrd_filename:free:AVERAGE"; $rrd_options .= " CDEF:$storage[storage_id]size=$storage[storage_id]used,$storage[storage_id]free,+"; $rrd_options .= " CDEF:$storage[storage_id]perc=$storage[storage_id]used,$storage[storage_id]size,/,100,*"; -$rrd_options .= " LINE1.25:$storage[storage_id]perc#" . $colour . ":'$descr'"; +$rrd_options .= " AREA:$storage[storage_id]perc#" . $background['right'] . ":"; +$rrd_options .= " LINE1.25:$storage[storage_id]perc#" . $background['left'] . ":'$descr'"; $rrd_options .= " GPRINT:$storage[storage_id]size:LAST:%6.2lf%sB"; $rrd_options .= " GPRINT:$storage[storage_id]free:LAST:%6.2lf%sB"; $rrd_options .= " GPRINT:$storage[storage_id]perc:LAST:%5.2lf%%\\\\n"; -$iter++; -?> \ No newline at end of file +?> diff --git a/html/pages/bill.inc.php b/html/pages/bill.inc.php index 36fc203e21..a1ed17b5dc 100644 --- a/html/pages/bill.inc.php +++ b/html/pages/bill.inc.php @@ -127,12 +127,9 @@ if (bill_permitted($bill_id))
Transferred ".formatStorage($total_data * 1024 * 1024)." of ".formatStorage($bill_data['bill_gb'] * 1024 * 1024 * 1024)." (".$percent."%)
Average rate " . formatRates($rate_average * 1000)); - if ($percent > 100) { $perc = "100"; } else { $perc = $percent; } - if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; - } elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; - } elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; - } elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; - } else { $left_background='9abf5b'; $right_background='bbd392'; } + $background = get_percentage_colours($percent); + $right_background = $background['right']; + $left_background = $background['left']; echo("

".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $left_background, $percent . "%", "ffffff", $right_background)."

"); diff --git a/html/pages/bills.inc.php b/html/pages/bills.inc.php index 01afa3ca32..9adaf2ec74 100644 --- a/html/pages/bills.inc.php +++ b/html/pages/bills.inc.php @@ -153,12 +153,9 @@ if ($_GET['opta'] == "add") $percent = round(($rate_data['total_data'] / ($bill['bill_gb'] * 1024)) * 100,2); } - if ($percent > 100) { $perc = "100"; } else { $perc = $percent; } - if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; } - elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; } - elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; } - elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; } - else { $left_background='9abf5b'; $right_background='bbd392'; } + $background = get_percentage_colours($percent); + $right_background = $background['right']; + $left_background = $background['left']; if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } echo(" @@ -169,7 +166,7 @@ if ($_GET['opta'] == "add") $type $allowed $used - ".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $left_background, $percent . "%", "ffffff", $right_background)." + ".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])." Edit Edit "); @@ -181,4 +178,4 @@ if ($_GET['opta'] == "add") echo(""); -?> \ No newline at end of file +?> diff --git a/html/pages/device/health/diskio.inc.php b/html/pages/device/health/diskio.inc.php index e558de4695..2c7b838f1e 100644 --- a/html/pages/device/health/diskio.inc.php +++ b/html/pages/device/health/diskio.inc.php @@ -24,12 +24,6 @@ while ($drive = mysql_fetch_assoc($query)) $fs_popup .= ""; $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; - if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; } - elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; } - elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; } - elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; } - else { $left_background='9abf5b'; $right_background='bbd392'; } - echo("" . $drive['diskio_descr'] . ""); $types = array("diskio_bits", "diskio_ops"); @@ -51,4 +45,4 @@ while ($drive = mysql_fetch_assoc($query)) echo(""); -?> \ No newline at end of file +?> diff --git a/html/pages/device/health/mempool.inc.php b/html/pages/device/health/mempool.inc.php index f54a1f6f29..8e9554881a 100644 --- a/html/pages/device/health/mempool.inc.php +++ b/html/pages/device/health/mempool.inc.php @@ -27,11 +27,9 @@ while ($mempool = mysql_fetch_assoc($mempools)) $perc = round($mempool['mempool_used'] / $mempool['mempool_total'] * 100); - if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; } - elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; } - elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; } - elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; } - else { $left_background='9abf5b'; $right_background='bbd392'; } + $background = get_percentage_colours($percent); + $right_background = $background['right']; + $left_background = $background['left']; echo("" . $text_descr . " @@ -56,4 +54,4 @@ while ($mempool = mysql_fetch_assoc($mempools)) echo(""); echo(""); -?> \ No newline at end of file +?> diff --git a/html/pages/device/health/processor.inc.php b/html/pages/device/health/processor.inc.php index 4cd23b163c..a0995caf15 100644 --- a/html/pages/device/health/processor.inc.php +++ b/html/pages/device/health/processor.inc.php @@ -21,19 +21,15 @@ while ($proc = mysql_fetch_assoc($procs)) $proc_popup .= ""; $proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; - $perc = round($proc['processor_usage']); + $percent = round($proc['processor_usage']); - if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; - } elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; - } elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; - } elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; - } else { $left_background='9abf5b'; $right_background='bbd392'; } + $background = get_percentage_colours($percent); echo(" " . $text_descr . " - ".print_percentage_bar (400, 20, $perc, $perc."%", "ffffff", $left_background, (100 - $perc)."%" , "ffffff", $right_background)." + ".print_percentage_bar (400, 20, $percent, $percent."%", "ffffff", $background['left'], (100 - $percent)."%" , "ffffff", $background['right'])." "); @@ -48,4 +44,4 @@ while ($proc = mysql_fetch_assoc($procs)) echo(""); echo(""); -?> \ No newline at end of file +?> diff --git a/html/pages/device/health/storage.inc.php b/html/pages/device/health/storage.inc.php index b2838c4495..96d10bc00b 100644 --- a/html/pages/device/health/storage.inc.php +++ b/html/pages/device/health/storage.inc.php @@ -34,14 +34,10 @@ while ($drive = mysql_fetch_assoc($query)) $fs_popup .= ""; $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; - if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; } - elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; } - elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; } - elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; } - else { $left_background='9abf5b'; $right_background='bbd392'; } + $background = get_percentage_colours($percent); echo("" . $drive['storage_descr'] . " - ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, $perc . "%", "ffffff", $right_background)." + ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], $perc . "%", "ffffff", $background['right'])." " . $free . ""); $graph_array['id'] = $drive['storage_id']; @@ -58,4 +54,4 @@ while ($drive = mysql_fetch_assoc($query)) echo(""); -?> \ No newline at end of file +?> diff --git a/html/pages/device/overview/mempools.inc.php b/html/pages/device/overview/mempools.inc.php index 01b2a16d7a..525e1082e4 100644 --- a/html/pages/device/overview/mempools.inc.php +++ b/html/pages/device/overview/mempools.inc.php @@ -15,7 +15,7 @@ if (mysql_result(mysql_query("SELECT count(*) from mempools WHERE device_id = '" while ($mempool = mysql_fetch_assoc($mempools)) { if (is_integer($mempool_rows/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - $perc = round($mempool['mempool_used'] / ($mempool['mempool_total']) * 100,2); + $perc = round($mempool['mempool_perc'],0); $text_descr = rewrite_entity_descr($mempool['mempool_descr']); @@ -30,16 +30,12 @@ if (mysql_result(mysql_query("SELECT count(*) from mempools WHERE device_id = '" $used = formatStorage($mempool['mempool_used']); $free = formatStorage($mempool['mempool_free']); - if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; } - elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; } - elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; } - elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; } - else { $left_background='9abf5b'; $right_background='bbd392'; } + $background = get_percentage_colours($perc); echo("" . $text_descr . " - ".print_percentage_bar (200, 20, $perc, "$used / $total", "ffffff", $left_background, $perc . "%", "ffffff", $right_background)." + ".print_percentage_bar (200, 20, $perc, "$used / $total", "ffffff", $background['left'], $perc . "%", "ffffff", $background['right'])." "); diff --git a/html/pages/device/overview/processors.inc.php b/html/pages/device/overview/processors.inc.php index e3a99790ea..11da816289 100644 --- a/html/pages/device/overview/processors.inc.php +++ b/html/pages/device/overview/processors.inc.php @@ -30,18 +30,14 @@ if (mysql_result(mysql_query("SELECT count(*) from processors WHERE device_id = # disable short hrDeviceDescr. need to make this prettier. #$text_descr = short_hrDeviceDescr($proc['processor_descr']); - $perc = $proc['processor_usage']; + $percent = $proc['processor_usage']; - if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; } - elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; } - elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; } - elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; } - else { $left_background='9abf5b'; $right_background='bbd392'; } + $background = get_percentage_colours($percent); echo("" . $text_descr . " - ".print_percentage_bar (200, 20, $perc, NULL, "ffffff", $left_background, $perc . "%", "ffffff", $right_background)." + ".print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])." "); $processor_rows++; diff --git a/html/pages/device/overview/storage.inc.php b/html/pages/device/overview/storage.inc.php index 4159d183fe..827520588a 100644 --- a/html/pages/device/overview/storage.inc.php +++ b/html/pages/device/overview/storage.inc.php @@ -54,15 +54,11 @@ if (mysql_result(mysql_query("SELECT count(storage_id) from storage WHERE device $mini_graph = $config['base_url'] . "/graph.php?id=".$drive['storage_id']."&type=".$graph_type."&from=".$day."&to=".$now."&width=80&height=20&bg=f4f4f4"; - if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; } - elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; } - elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; } - elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; } - else { $left_background='9abf5b'; $right_background='bbd392'; } + $background = get_percentage_colours($perc); echo("" . $drive['storage_descr'] . " - ".print_percentage_bar (200, 20, $perc, "$used / $total", "ffffff", $left_background, $perc . "%", "ffffff", $right_background)." + ".print_percentage_bar (200, 20, $perc, "$used / $total", "ffffff", $background['left'], $perc . "%", "ffffff", $background['right'])." "); $drive_rows++; } @@ -73,4 +69,4 @@ if (mysql_result(mysql_query("SELECT count(storage_id) from storage WHERE device unset ($drive_rows); -?> \ No newline at end of file +?> diff --git a/html/pages/health/mempool.inc.php b/html/pages/health/mempool.inc.php index 5fdf58a741..505463308d 100644 --- a/html/pages/health/mempool.inc.php +++ b/html/pages/health/mempool.inc.php @@ -34,22 +34,16 @@ while ($mempool = mysql_fetch_assoc($mempools)) $used = formatStorage($mempool['mempool_used']); $free = formatStorage($mempool['mempool_free']); - $perc = round($mempool['mempool_used'] / $mempool['mempool_total'] * 100); - - if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; } - elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; } - elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; } - elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; } - else { $left_background='9abf5b'; $right_background='bbd392'; } + $background = get_percentage_colours($mempool['mempool_perc']); echo(" ".generate_device_link($mempool)." " . $text_descr . " - ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, $free , "ffffff", $right_background)." + ".print_percentage_bar (400, 20, $mempool['mempool_perc'], "$used / $total", "ffffff", $background['left'], $free , "ffffff", $background['right'])." - ".$perc."% + ".$mempool['mempool_perc']."% "); if ($_GET['optb'] == "graphs") @@ -86,4 +80,4 @@ while ($mempool = mysql_fetch_assoc($mempools)) echo(""); echo(""); -?> \ No newline at end of file +?> diff --git a/html/pages/health/processor.inc.php b/html/pages/health/processor.inc.php index 3a64b1a667..134cddf03b 100644 --- a/html/pages/health/processor.inc.php +++ b/html/pages/health/processor.inc.php @@ -39,18 +39,14 @@ while ($proc = mysql_fetch_assoc($procs)) $perc = round($proc['processor_usage']); - if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; } - elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; } - elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; } - elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; } - else { $left_background='9abf5b'; $right_background='bbd392'; } + $background = get_percentage_colours($perc); echo(" ".generate_device_link($proc)." " . $text_descr . " - ".print_percentage_bar (400, 20, $perc, $perc."%", "ffffff", $left_background, (100 - $perc)."%" , "ffffff", $right_background)); + ".print_percentage_bar (400, 20, $perc, $perc."%", "ffffff", $background['left'], (100 - $perc)."%" , "ffffff", $background['right'])); echo(' '); @@ -90,4 +86,4 @@ while ($proc = mysql_fetch_assoc($procs)) echo(""); echo(""); -?> \ No newline at end of file +?> diff --git a/html/pages/health/storage.inc.php b/html/pages/health/storage.inc.php index b8f4c29ae8..7fabefe667 100644 --- a/html/pages/health/storage.inc.php +++ b/html/pages/health/storage.inc.php @@ -61,16 +61,12 @@ while ($drive = mysql_fetch_assoc($query)) $mini_graph = $config['base_url'] . "/graph.php?id=".$drive['storage_id']."&type=".$graph_type."&from=".$day."&to=".$now."&width=80&height=20&bg=f4f4f4"; - if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; } - elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; } - elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; } - elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; } - else { $left_background='9abf5b'; $right_background='bbd392'; } + $background = get_percentage_colours($perc); echo("" . generate_device_link($drive) . "" . $drive['storage_descr'] . " - ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, $free, "ffffff", $right_background)." + ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], $free, "ffffff", $background['right'])." $perc"."%"); if ($_GET['optb'] == "graphs") diff --git a/html/pages/storage.inc.php b/html/pages/storage.inc.php index 5fd63350f5..46325ff130 100644 --- a/html/pages/storage.inc.php +++ b/html/pages/storage.inc.php @@ -65,16 +65,12 @@ while ($drive = mysql_fetch_assoc($query)) $mini_graph = $config['base_url'] . "/graph.php?id=".$drive['storage_id']."&type=storage&from=".$day."&to=".$now."&width=80&height=20&bg=f4f4f4"; - if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; } - elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; } - elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; } - elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; } - else { $left_background='9abf5b'; $right_background='bbd392'; } + $background = get_percentage_colours($perc); echo("" . generate_device_link($drive) . "" . $drive['storage_descr'] . " - ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, formatStorage($free), "ffffff", $right_background)." + ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], formatStorage($free), "ffffff", $background['right'])." $perc"."%"); $row++; @@ -82,4 +78,4 @@ while ($drive = mysql_fetch_assoc($query)) echo(""); -?> \ No newline at end of file +?> diff --git a/includes/polling/mempools.inc.php b/includes/polling/mempools.inc.php index dcc894d057..9acb25108d 100755 --- a/includes/polling/mempools.inc.php +++ b/includes/polling/mempools.inc.php @@ -49,6 +49,7 @@ while ($mempool = mysql_fetch_assoc($mempool_data)) rrdtool_update($mempoolrrd,"N:".$mempool['used'].":".$mempool['free']); $update_query = "UPDATE `mempools` SET `mempool_used` = '".$mempool['used']."'"; + $update_query .= ", `mempool_perc` = '".$percent."'"; $update_query .= ", `mempool_free` = '".$mempool['free']."'"; $update_query .= ", `mempool_total` = '".$mempool['total']."'"; $update_query .= ", `mempool_largestfree` = '".$mempool['largestfree']."'"; @@ -63,4 +64,4 @@ while ($mempool = mysql_fetch_assoc($mempool_data)) unset($mempool_cache); -?> \ No newline at end of file +?>