From cb7c87d76f6f9dad784ba255771027ca917dc4e9 Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Wed, 1 Jul 2015 21:03:02 +1000 Subject: [PATCH] Use stacked graphs for multi-instance MIBs; add larger colour palette --- html/includes/graphs/device/mib.inc.php | 22 +++++++++++++++++----- includes/defaults.inc.php | 11 +++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/html/includes/graphs/device/mib.inc.php b/html/includes/graphs/device/mib.inc.php index 21fe1d7ee..b97cca855 100644 --- a/html/includes/graphs/device/mib.inc.php +++ b/html/includes/graphs/device/mib.inc.php @@ -13,8 +13,10 @@ */ $rrd_list = array(); -$prefix = rrd_name($device['hostname'], array($subtype, ''), ''); -foreach (glob($prefix.'*.rrd') as $filename) { +$prefix = rrd_name($device['hostname'], array($subtype, ''), ''); +$filenames = glob($prefix."*.rrd"); +$count = count($filenames); +foreach ($filenames as $filename) { // find out what * expanded to $globpart = str_replace($prefix, '', $filename); // take off the prefix $instance = substr($globpart, 0, -4); // take off ".rrd" @@ -27,9 +29,19 @@ foreach (glob($prefix.'*.rrd') as $filename) { $rrd_list[] = $ds; } -$colours = 'mixed'; $scale_min = '0'; -$nototal = 0; $simple_rrd = true; -require 'includes/graphs/generic_multi_line.inc.php'; +// If there are multiple matching files, use a stacked graph instead of a line graph +if ($count > 1) { + $nototal = 1; + $divider = $count; + $text_orig = 1; + $colours = 'manycolours'; + include "includes/graphs/generic_multi_simplex_seperated.inc.php"; +} +else { + $colours = 'mixed'; + $nototal = 0; + include "includes/graphs/generic_multi_line.inc.php"; +} diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 407402746..4c93db9d1 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -315,6 +315,17 @@ $config['graph_colours']['purples'] = array( ); $config['graph_colours']['default'] = $config['graph_colours']['blues']; +// Colour values from http://www.sapdesignguild.org/goodies/diagram_guidelines/color_palettes.html +$config['graph_colours']['manycolours'] = array( + "FFF8A3", "FAE16B", "F8D753", "F3C01C", "F0B400", // yellows + "A9CC8F", "82B16A", "5C9746", "3D8128", "1E6C0B", // greens + "B2C8D9", "779DBF", "3E75A7", "205F9A", "00488C", // blues + "BEA37A", "907A52", "7A653E", "63522B", "3D3000", // browns + "F3AA79", "EB8953", "E1662A", "DC5313", "D84000", // oranges + "B5B5A9", "8B8D82", "74796F", "5D645A", "434C43", // greys + "E6A4A5", "D6707B", "C4384F", "BC1C39", "B30023", // pinks +); + // Map colors $config['network_map_legend'] = array( '0' => '#aeaeae',