Don't display MIB menu items if MIB-based polling is disabled

This commit is contained in:
Paul Gear
2016-01-07 09:26:48 +10:00
parent 4db7b95ba2
commit 7170a240a8
6 changed files with 43 additions and 7 deletions
+10 -1
View File
@@ -110,8 +110,14 @@ if ( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) {
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'ipv6'))); ?>"><i class="fa fa-search fa-fw fa-lg"></i> IPv6 Search</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'mac'))); ?>"><i class="fa fa-search fa-fw fa-lg"></i> MAC Search</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'arp'))); ?>"><i class="fa fa-search fa-fw fa-lg"></i> ARP Tables</a></li>
<?php
if (is_module_enabled('poller', 'mib')) {
?>
<li role="presentation" class="divider"></li>
<li><a href="<?php echo(generate_url(array('page'=>'mibs'))); ?>"><i class="fa fa-file-text-o fa-fw fa-lg"></i> MIB definitions</a></li>
<?php
}
?>
</ul>
</li>
<li class="dropdown">
@@ -168,10 +174,13 @@ if ($_SESSION['userlevel'] >= '10') {
');
}
echo '
<li role="presentation" class="divider"></li>
<li role="presentation" class="divider"></li>';
if (is_module_enabled('poller', 'mib')) {
echo '
<li><a href='.generate_url(array('page'=>'mib_assoc')).'><i class="fa fa-file-text-o fa-fw fa-lg"></i> MIB associations</a></li>
<li role="presentation" class="divider"></li>
';
}
if ($config['navbar']['manage_groups']['hide'] === 0) {
echo '<li><a href="'.generate_url(array('page'=>'device-groups')).'"><i class="fa fa-th fa-fw fa-lg"></i> Manage Groups</a></li>';
+1 -1
View File
@@ -371,7 +371,7 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) {
</a>
</li>';
if (device_permitted($device['device_id'])) {
if (device_permitted($device['device_id']) && is_mib_poller_enabled($device)) {
echo '<li class="'.$select['mib'].'">
<a href="'.generate_device_url($device, array('tab' => 'mib')).'">
<i class="fa fa-file-text-o"></i> MIB
+6
View File
@@ -16,6 +16,7 @@
if (!isset($vars['section'])) {
$vars['section'] = "mib";
}
if (is_module_enabled('poller', 'mib')) {
?>
<h4><i class="fa fa-file-text-o"></i> Device MIB associations</h4>
@@ -86,3 +87,8 @@ if (!isset($vars['section'])) {
}
});
</script>
<?php
}
else {
print_mib_poller_disabled();
}
+6
View File
@@ -13,6 +13,7 @@
* the source code distribution for details.
*/
if (is_module_enabled('poller', 'mib')) {
?>
<h4>MIB associations for all devices</h4>
@@ -47,3 +48,8 @@
}
});
</script>
<?php
}
else {
print_mib_poller_disabled();
}
+7
View File
@@ -12,6 +12,8 @@
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
if (is_module_enabled('poller', 'mib')) {
?>
<h4><i class="fa fa-file-text-o"></i> All MIB definitions</h4>
@@ -52,3 +54,8 @@
}
});
</script>
<?php
}
else {
print_mib_poller_disabled();
}
+13 -5
View File
@@ -742,7 +742,7 @@ function round_Nth($val = 0, $round_to) {
*/
function count_mib_mempools($device)
{
if ($device['os'] == 'ruckuswireless') {
if (is_mib_poller_enabled($device) && $device['os'] == 'ruckuswireless') {
return 1;
}
return 0;
@@ -754,7 +754,7 @@ function count_mib_mempools($device)
*/
function count_mib_processors($device)
{
if ($device['os'] == 'ruckuswireless') {
if (is_mib_poller_enabled($device) && $device['os'] == 'ruckuswireless') {
return 1;
}
return 0;
@@ -780,7 +780,7 @@ function get_mibval($device, $oid)
function get_mib_mempools($device)
{
$mempools = array();
if ($device['os'] == 'ruckuswireless') {
if (is_mib_poller_enabled($device) && $device['os'] == 'ruckuswireless') {
$mempool = array();
$mibvals = get_mibval($device, '.1.3.6.1.4.1.25053.1.2.1.1.1.15.14.0');
$mempool['mempool_descr'] = $mibvals['object_type'];
@@ -801,7 +801,7 @@ function get_mib_mempools($device)
function get_mib_processors($device)
{
$processors = array();
if ($device['os'] == 'ruckuswireless') {
if (is_mib_poller_enabled($device) && $device['os'] == 'ruckuswireless') {
$proc = array();
$mibvals = get_mibval($device, '.1.3.6.1.4.1.25053.1.2.1.1.1.15.13.0');
$proc['processor_descr'] = $mibvals['object_type'];
@@ -819,7 +819,7 @@ function get_mib_processors($device)
*/
function is_custom_graph($type, $subtype, $device)
{
if ($device['os'] == 'ruckuswireless' && $type == 'device') {
if (is_mib_poller_enabled($device) && $device['os'] == 'ruckuswireless' && $type == 'device') {
switch ($subtype) {
case 'cpumem':
case 'mempool':
@@ -955,6 +955,14 @@ function search_phrase_column($c)
} // search_phrase_column
function print_mib_poller_disabled() {
echo '<h4>MIB polling is not enabled</h4>
<p>
Set <tt>$config[\'poller_modules\'][\'mib\'] = 1;</tt> in <tt>config.php</tt> to enable.
</p>';
} // print_mib_poller_disabled
/**
* Constructs the path to an RRD for the Ceph application
* @param string $gtype The type of rrd we're looking for