* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see . */
/**
* Generic Graph Widget
* @author Daniel Preussker
* @copyright 2015-2016 Daniel Preussker, QuxLabs UG
* @license GPL
* @package LibreNMS
* @subpackage Widgets
*/
if (defined('SHOW_SETTINGS') || empty($widget_settings)) {
$common_output[] = '
';
} else {
$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];
if ($type == 'device') {
if (empty($widget_settings['title'])) {
$widget_settings['title'] = $widget_settings['graph_device']['name']." / ".$widget_settings['graph_type'];
}
$param = 'device='.$widget_settings['graph_device']['device_id'];
} elseif ($type == 'application') {
$param = 'id='.$widget_settings['graph_'.$type]['app_id'];
} 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 == 'custom' || $type == 'manual') {
if ($type == 'custom' || $type == 'manual') {
$type = $widget_settings['graph_'.$type];
$type = explode(',', $type);
}
$ports = get_ports_from_type($type);
foreach ($ports as $port) {
$tmp[] = $port['port_id'];
}
$param = 'id='.implode(',', $tmp);
$widget_settings['graph_type'] = 'multiport_bits_separate';
if (empty($widget_settings['title'])) {
$widget_settings['title'] = 'Overall '.ucfirst(htmlspecialchars($type)).' Bits ('.$widget_settings['graph_range'].')';
}
} else {
$param = 'id='.$widget_settings['graph_'.$type][$type.'_id'];
}
if (empty($widget_settings['title'])) {
$widget_settings['title'] = $widget_settings['graph_'.$type]['hostname']." / ".$widget_settings['graph_'.$type]['name']." / ".$widget_settings['graph_type'];
}
$common_output[] = '
';
}