From 4ccab34f81e106b7a79f244e96186184ae5b2c79 Mon Sep 17 00:00:00 2001 From: f0o Date: Tue, 22 Sep 2015 17:37:03 +0100 Subject: [PATCH 1/3] Added 'Transit', 'Peering' and 'Core' graphs to the widget --- html/includes/common/generic-graph.inc.php | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/html/includes/common/generic-graph.inc.php b/html/includes/common/generic-graph.inc.php index 086239df7a..c9e2c31828 100644 --- a/html/includes/common/generic-graph.inc.php +++ b/html/includes/common/generic-graph.inc.php @@ -61,6 +61,9 @@ if( defined('show_settings') || empty($widget_settings) ) { $common_output[] = ''; } $common_output[] = ' + + +
@@ -318,6 +321,29 @@ else { elseif ($type == 'munin') { $param = 'device='.$widget_settings['graph_'.$type]['device_id'].'&plugin='.$widget_settings['graph_'.$type]['name']; } + elseif ($type == 'transit' || $type == 'peering' || $type == 'core') { + $type_where = ' ('; + if (is_array($config[$type.'_descr']) === false) { + $config[$type.'_descr'] = array($config[$type.'_descr']); + } + foreach ($config[$type.'_descr'] as $additional_type) { + if (!empty($additional_type)) { + $type_where .= " $or `port_descr_type` = ?"; + $or = 'OR'; + $type_param[] = $additional_type; + } + } + $type_where .= " $or `port_descr_type` = ?"; + $or = 'OR'; + $type_param[] = $type; + $type_where .= ') '; + foreach (dbFetchRows("SELECT port_id FROM `ports` as I, `devices` AS D WHERE $type_where AND I.device_id = D.device_id ORDER BY I.ifAlias", $type_param) as $port) { + $tmp[] = $port['port_id']; + } + $param = 'id='.implode(',',$tmp); + $widget_settings['graph_type']= 'multiport_bits_separate'; + $widget_settings['title'] = 'Overall '.ucfirst($type).' Bits ('.$widget_settings['graph_range'].')'; + } else { $param = 'id='.$widget_settings['graph_'.$type][$type.'_id']; } From dddb2ead4014a5a0953f89d7bf0f8a76c0e7e598 Mon Sep 17 00:00:00 2001 From: f0o Date: Tue, 22 Sep 2015 18:05:43 +0100 Subject: [PATCH 2/3] Added custom port-desc as well --- html/includes/common/generic-graph.inc.php | 28 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/html/includes/common/generic-graph.inc.php b/html/includes/common/generic-graph.inc.php index c9e2c31828..082418148e 100644 --- a/html/includes/common/generic-graph.inc.php +++ b/html/includes/common/generic-graph.inc.php @@ -61,9 +61,11 @@ if( defined('show_settings') || empty($widget_settings) ) { $common_output[] = ''; } $common_output[] = ' - - - + + + + +
@@ -126,6 +128,14 @@ if( defined('show_settings') || empty($widget_settings) ) {
+
+
+ +
+
+ +
+
@@ -310,7 +320,7 @@ else { $widget_settings['title'] = ""; $type = explode('_',$widget_settings['graph_type'],2); $type = array_shift($type); - $widget_settings['graph_'.$type] = json_decode($widget_settings['graph_'.$type],true); + $widget_settings['graph_'.$type] = json_decode($widget_settings['graph_'.$type],true)?:$widget_settings['graph_'.$type]; if ($type == 'device') { $widget_settings['title'] = $widget_settings['graph_device']['name']." / ".$widget_settings['graph_type']; $param = 'device='.$widget_settings['graph_device']['device_id']; @@ -337,13 +347,21 @@ else { $or = 'OR'; $type_param[] = $type; $type_where .= ') '; - foreach (dbFetchRows("SELECT port_id FROM `ports` as I, `devices` AS D WHERE $type_where AND I.device_id = D.device_id ORDER BY I.ifAlias", $type_param) as $port) { + foreach (dbFetchRows("SELECT port_id FROM `ports` WHERE $type_where ORDER BY ifAlias", $type_param) as $port) { $tmp[] = $port['port_id']; } $param = 'id='.implode(',',$tmp); $widget_settings['graph_type']= 'multiport_bits_separate'; $widget_settings['title'] = 'Overall '.ucfirst($type).' Bits ('.$widget_settings['graph_range'].')'; } + elseif ($type == 'custom') { + foreach (dbFetchRows("SELECT port_id FROM `ports` WHERE `port_descr_type` = ? ORDER BY ifAlias", array($widget_settings['graph_custom'])) as $port) { + $tmp[] = $port['port_id']; + } + $param = 'id='.implode(',',$tmp); + $widget_settings['graph_type']= 'multiport_bits_separate'; + $widget_settings['title'] = 'Overall '.ucfirst(htmlspecialchars($widget_settings['graph_custom'])).' Bits ('.$widget_settings['graph_range'].')'; + } else { $param = 'id='.$widget_settings['graph_'.$type][$type.'_id']; } From 31a074d83a054ae3eaf010cd8a604a52c6401d05 Mon Sep 17 00:00:00 2001 From: f0o Date: Tue, 22 Sep 2015 18:53:32 +0100 Subject: [PATCH 3/3] Added select-input for custom_descr --- html/includes/common/generic-graph.inc.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/html/includes/common/generic-graph.inc.php b/html/includes/common/generic-graph.inc.php index 082418148e..e7cf4b9ed2 100644 --- a/html/includes/common/generic-graph.inc.php +++ b/html/includes/common/generic-graph.inc.php @@ -133,7 +133,11 @@ if( defined('show_settings') || empty($widget_settings) ) {
- +