[A-Za-z0-9]+)_(?P.+)/', $vars['type'], $graphtype); $type = basename($graphtype['type']); $subtype = basename($graphtype['subtype']); $id = $vars['id'] ?? null; if (isset($vars['device'])) { $device = is_numeric($vars['device']) ? device_by_id_cache($vars['device']) : device_by_name($vars['device']); } $auth = false; if (is_file('includes/html/graphs/' . $type . '/auth.inc.php')) { require 'includes/html/graphs/' . $type . '/auth.inc.php'; } if (! $auth) { require 'includes/html/error-no-perm.inc.php'; } else { if (Config::has("graph_types.$type.$subtype.descr")) { $title .= ' :: ' . Config::get("graph_types.$type.$subtype.descr"); } elseif ($type == 'device' && $subtype == 'collectd') { $title .= ' :: ' . \LibreNMS\Util\StringHelpers::niceCase($subtype) . ' :: ' . $vars['c_plugin']; if (isset($vars['c_plugin_instance'])) { $title .= ' - ' . $vars['c_plugin_instance']; } $title .= ' - ' . $vars['c_type']; if (isset($vars['c_type_instance'])) { $title .= ' - ' . $vars['c_type_instance']; } } else { $title .= ' :: ' . \LibreNMS\Util\StringHelpers::niceCase($subtype); } $graph_array = $vars; $graph_array['height'] = '60'; $graph_array['width'] = $thumb_width; $graph_array['legend'] = 'no'; $graph_array['to'] = Config::get('time.now'); print_optionbar_start(); echo $title; // FIXME allow switching between types for sensor and wireless also restrict types to ones that have data if ($type != 'sensor') { echo '
'; echo csrf_field(); echo "
'; } print_optionbar_end(); $show_command = isset($vars['showcommand']) && $vars['showcommand'] == 'yes'; if (! $show_command) { $thumb_array = Config::get('graphs.row.normal'); echo ''; foreach ($thumb_array as $period => $text) { $graph_array['from'] = Config::get("time.$period"); $link_array = $vars; $link_array['from'] = $graph_array['from']; $link_array['to'] = $graph_array['to']; $link_array['page'] = 'graphs'; $link = \LibreNMS\Util\Url::generate($link_array); echo ''; } echo '
'; echo '' . $text . ''; echo ''; echo \LibreNMS\Util\Url::lazyGraphTag($graph_array); echo ''; echo '
'; echo '
'; } $graph_array = $vars; $graph_array['height'] = Config::get('webui.min_graph_height'); $graph_array['width'] = $graph_width; if ($screen_width = Session::get('screen_width')) { if ($screen_width > 800) { $graph_array['width'] = ($screen_width - ($screen_width / 10)); } else { $graph_array['width'] = ($screen_width - ($screen_width / 4)); } } if ($screen_height = Session::get('screen_height')) { if ($screen_height > 960) { $graph_array['height'] = ($screen_height - ($screen_height / 2)); } else { $graph_array['height'] = max($graph_array['height'], $screen_height - ($screen_height / 1.5)); } } include_once 'includes/html/print-date-selector.inc.php'; echo '
'; echo '
'; if (isset($vars['legend']) && $vars['legend'] == 'no') { echo generate_link('Show Legend', $vars, ['page' => 'graphs', 'legend' => null]); } else { echo generate_link('Hide Legend', $vars, ['page' => 'graphs', 'legend' => 'no']); } // FIXME : do this properly // if ($type == "port" && $subtype == "bits") // { echo ' | '; if (isset($vars['previous']) && $vars['previous'] == 'yes') { echo generate_link('Hide Previous', $vars, ['page' => 'graphs', 'previous' => null]); } else { echo generate_link('Show Previous', $vars, ['page' => 'graphs', 'previous' => 'yes']); } // } echo ' | '; if ($show_command) { echo generate_link('Hide RRD Command', $vars, ['page' => 'graphs', 'showcommand' => null]); } else { echo generate_link('Show RRD Command', $vars, ['page' => 'graphs', 'showcommand' => 'yes']); } if ($vars['type'] == 'port_bits') { echo ' | '; if ($vars['port_speed_zoom'] ?? Config::get('graphs.port_speed_zoom')) { echo generate_link('Zoom to Traffic', $vars, ['page' => 'graphs', 'port_speed_zoom' => 0]); } else { echo generate_link('Zoom to Port Speed', $vars, ['page' => 'graphs', 'port_speed_zoom' => 1]); } echo ' | To show trend, set to future date'; } echo '
'; echo generate_graph_js_state($graph_array); echo '
'; if (Config::get('webui.dynamic_graphs', false) === true) { echo generate_dynamic_graph_js($graph_array); echo generate_dynamic_graph_tag($graph_array); } else { echo \LibreNMS\Util\Url::lazyGraphTag($graph_array); } echo '
'; if (Config::has('graph_descr.' . $vars['type'])) { print_optionbar_start(); echo '
'; echo Config::get('graph_descr.' . $vars['type']); print_optionbar_end(); } if ($show_command) { $vars = $graph_array; $_GET = $graph_array; $command_only = 1; require 'includes/html/graphs/graph.inc.php'; } }