Files

85 lines
2.8 KiB
PHP
Raw Permalink Normal View History

2009-09-07 11:07:59 +00:00
<?php
2007-04-04 10:15:07 +00:00
2019-06-23 00:29:12 -05:00
// Graphs are printed in the order they exist in \LibreNMS\Config::get('graph_types')
2020-09-21 15:40:17 +02:00
$link_array = [
2015-07-13 20:10:26 +02:00
'page' => 'device',
'device' => $device['device_id'],
'tab' => 'graphs',
2020-09-21 15:40:17 +02:00
];
2010-07-31 00:54:51 +00:00
2015-07-13 20:10:26 +02:00
$bg = '#ffffff';
2011-09-18 13:11:04 +00:00
2015-07-13 20:10:26 +02:00
echo '<div style="clear: both;">';
2010-01-08 00:01:26 +00:00
print_optionbar_start();
2010-01-08 00:01:26 +00:00
2015-07-13 20:10:26 +02:00
echo "<span style='font-weight: bold;'>Graphs</span> &#187; ";
2020-09-21 15:40:17 +02:00
foreach (dbFetchRows('SELECT * FROM device_graphs WHERE device_id = ? ORDER BY graph', [$device['device_id']]) as $graph) {
2019-06-23 00:29:12 -05:00
$section = \LibreNMS\Config::get("graph_types.device.{$graph['graph']}.section");
2015-07-13 20:10:26 +02:00
if ($section != '') {
$graph_enable[$section][$graph['graph']] = $graph['graph'];
}
2010-07-31 00:54:51 +00:00
}
2015-07-13 20:10:26 +02:00
$sep = '';
foreach ($graph_enable as $section => $nothing) {
if (isset($graph_enable) && is_array($graph_enable[$section])) {
$type = strtolower($section);
2020-09-21 15:40:17 +02:00
if (! $vars['group']) {
2015-07-13 20:10:26 +02:00
$vars['group'] = $type;
}
echo $sep;
if ($vars['group'] == $type) {
echo '<span class="pagemenu-selected">';
}
if ($type == 'customoid') {
2020-09-21 15:40:17 +02:00
echo generate_link(ucwords('Custom OID'), $link_array, ['group' => $type]);
} else {
2020-09-21 15:40:17 +02:00
echo generate_link(ucwords($type), $link_array, ['group' => $type]);
}
2015-07-13 20:10:26 +02:00
if ($vars['group'] == $type) {
echo '</span>';
}
$sep = ' | ';
}
2007-04-04 10:15:07 +00:00
}
2015-07-13 20:10:26 +02:00
unset($sep);
2015-06-13 15:21:58 +10:00
print_optionbar_end();
2020-06-22 22:57:30 +02:00
$group = $vars['group'];
$graph_enable = $graph_enable[$group];
$metric = basename($vars['metric']);
2020-06-25 20:53:21 +02:00
if (($group != 'customoid') && (is_file("includes/html/pages/device/graphs/$group.inc.php"))) {
2020-06-22 22:57:30 +02:00
include "includes/html/pages/device/graphs/$group.inc.php";
} else {
foreach ($graph_enable as $graph => $entry) {
2020-09-21 15:40:17 +02:00
$graph_array = [];
2020-06-22 22:57:30 +02:00
if ($graph_enable[$graph]) {
if ($graph == 'customoid') {
2020-09-21 15:40:17 +02:00
foreach (dbFetchRows('SELECT * FROM `customoids` WHERE `device_id` = ? ORDER BY `customoid_descr`', [$device['device_id']]) as $graph_entry) {
2020-09-21 15:59:34 +02:00
$graph_title = \LibreNMS\Config::get("graph_types.device.$graph.descr") . ': ' . $graph_entry['customoid_descr'];
2020-06-22 22:57:30 +02:00
$graph_array['type'] = 'customoid_' . $graph_entry['customoid_descr'];
2020-09-21 15:40:17 +02:00
if (! empty($graph_entry['customoid_unit'])) {
2020-06-22 22:57:30 +02:00
$graph_array['unit'] = $graph_entry['customoid_unit'];
} else {
$graph_array['unit'] = 'value';
}
include 'includes/html/print-device-graph.php';
}
2020-06-22 22:57:30 +02:00
} else {
$graph_title = \LibreNMS\Config::get("graph_types.device.$graph.descr");
2020-09-21 15:40:17 +02:00
$graph_array['type'] = 'device_' . $graph;
include 'includes/html/print-device-graph.php';
}
}
2015-07-13 20:10:26 +02:00
}
}
$pagetitle[] = 'Graphs';