1<?php
2
3// Graphs are printed in the order they exist in \LibreNMS\Config::get('graph_types')
4$link_array = [
5    'page'   => 'device',
6    'device' => $device['device_id'],
7    'tab'    => 'munin',
8];
9
10$bg = '#ffffff';
11
12echo '<div style="clear: both;">';
13
14print_optionbar_start();
15
16echo "<span style='font-weight: bold;'>Munin</span> &#187; ";
17
18$sep = '';
19
20foreach (dbFetchRows('SELECT * FROM munin_plugins WHERE device_id = ? ORDER BY mplug_category, mplug_type', [$device['device_id']]) as $mplug) {
21    // if (strlen($mplug['mplug_category']) == 0) { $mplug['mplug_category'] = "general"; } else {  }
22    $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id'];
23    $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title'];
24    $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['plugin'] = $mplug['mplug_type'];
25}
26
27foreach ($graph_enable as $section => $nothing) {
28    if (isset($graph_enable) && is_array($graph_enable[$section])) {
29        $type = strtolower($section);
30        if (! $vars['group']) {
31            $vars['group'] = $type;
32        }
33
34        echo $sep;
35        if ($vars['group'] == $type) {
36            echo '<span class="pagemenu-selected">';
37        }
38
39        echo generate_link(ucwords($type), $link_array, ['group' => $type]);
40        if ($vars['group'] == $type) {
41            echo '</span>';
42        }
43
44        $sep = ' | ';
45    }
46}
47
48unset($sep);
49print_optionbar_end();
50
51$graph_enable = $graph_enable[$vars['group']];
52
53// foreach (\LibreNMS\Config::get('graph_types.device') as $graph => $entry)
54foreach ($graph_enable as $graph => $entry) {
55    $graph_array = [];
56    if ($graph_enable[$graph]) {
57        if (! empty($entry['plugin'])) {
58            $graph_title = $entry['title'];
59            $graph_array['type'] = 'munin_graph';
60            $graph_array['device'] = $device['device_id'];
61            $graph_array['plugin'] = $entry['plugin'];
62        } else {
63            $graph_title = \LibreNMS\Config::get("graph_types.device.$graph.descr");
64            $graph_array['type'] = 'device_' . $graph;
65        }
66
67        include 'includes/html/print-device-graph.php';
68    }
69}
70
71$pagetitle[] = 'Graphs';
72