mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Show only relevant MIB graphs
This reduces noise in the drop-down by only displaying MIB graphs defined for the device.
This commit is contained in:
@@ -64,7 +64,7 @@ else {
|
||||
onchange="window.open(this.options[this.selectedIndex].value,'_top')" >
|
||||
<?php
|
||||
|
||||
foreach (get_graph_subtypes($type) as $avail_type) {
|
||||
foreach (get_graph_subtypes($type, $device) as $avail_type) {
|
||||
echo("<option value='".generate_url($vars, array('type' => $type."_".$avail_type, 'page' => "graphs"))."'");
|
||||
if ($avail_type == $subtype) {
|
||||
echo(" selected");
|
||||
|
@@ -649,9 +649,9 @@ function is_client_authorized($clientip) {
|
||||
|
||||
/*
|
||||
* @return an array of all graph subtypes for the given type
|
||||
* FIXME not all of these are going to be valid
|
||||
*/
|
||||
function get_graph_subtypes($type) {
|
||||
function get_graph_subtypes($type, $device = null)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$types = array();
|
||||
@@ -669,7 +669,7 @@ function get_graph_subtypes($type) {
|
||||
// find the MIB subtypes
|
||||
foreach ($config['graph_types'] as $type => $unused1) {
|
||||
foreach ($config['graph_types'][$type] as $subtype => $unused2) {
|
||||
if (is_mib_graph($type, $subtype)) {
|
||||
if (is_mib_graph($type, $subtype) && $device != null && is_device_graph($device, $subtype)) {
|
||||
$types[] = $subtype;
|
||||
}
|
||||
}
|
||||
@@ -680,6 +680,13 @@ function get_graph_subtypes($type) {
|
||||
} // get_graph_subtypes
|
||||
|
||||
|
||||
function is_device_graph($device, $subtype)
|
||||
{
|
||||
$query = 'SELECT COUNT(*) FROM `device_graphs` WHERE `device_id` = ? AND `graph` = ?';
|
||||
return dbFetchCell($query, array($device['device_id'], $subtype)) > 0;
|
||||
} // is_device_graph
|
||||
|
||||
|
||||
function get_smokeping_files($device) {
|
||||
global $config;
|
||||
$smokeping_files = array();
|
||||
|
Reference in New Issue
Block a user