mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 08:02:23 +02:00
per-device disabling of poller/discovery modules
git-svn-id: http://www.observium.org/svn/observer/trunk@2255 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
+7
-1
@@ -162,6 +162,8 @@ function discover_device($device, $options)
|
||||
global $config;
|
||||
global $valid; $valid = array(); ## Reset $valid array
|
||||
|
||||
$attribs = get_dev_attribs($device['device_id']);
|
||||
|
||||
$device_start = utime(); // Start counting device poll time
|
||||
|
||||
echo($device['hostname'] . " ".$device['device_id']." ".$device['os']." ");
|
||||
@@ -192,9 +194,13 @@ function discover_device($device, $options)
|
||||
} else {
|
||||
foreach($config['discovery_modules'] as $module => $module_status)
|
||||
{
|
||||
if($module_status || $device_attribs['discovery_module'][$module])
|
||||
if ($attribs['discover_'.$module] || ( $module_status && !isset($attribs['discover_'.$module])))
|
||||
{
|
||||
include('includes/discovery/'.$module.'.inc.php');
|
||||
} elseif (isset($attribs['discover_'.$module]) && $attribs['discover_'.$module] == "0") {
|
||||
echo("Module [ $module ] disabled on host.\n");
|
||||
} else {
|
||||
echo("Module [ $module ] disabled globally.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,68 @@
|
||||
<?php
|
||||
|
||||
if($_POST['toggle_poller'] && isset($config['poller_modules'][$_POST['toggle_poller']]))
|
||||
{
|
||||
$module = mres($_POST['toggle_poller']);
|
||||
if (isset($attribs['poll_'.$module]) && $attribs['poll_'.$module] != $config['poller_modules'][$_POST['toggle_poller']])
|
||||
{
|
||||
del_dev_attrib($device, 'poll_' . $module);
|
||||
} elseif ($config['poller_modules'][$_POST['toggle_poller']] == 0) {
|
||||
set_dev_attrib($device, 'poll_' . $module, "1");
|
||||
} else {
|
||||
set_dev_attrib($device, 'poll_' . $module, "0");
|
||||
}
|
||||
$attribs = get_dev_attribs($device['device_id']);
|
||||
}
|
||||
|
||||
if($_POST['toggle_discovery'] && isset($config['discovery_modules'][$_POST['toggle_discovery']]))
|
||||
{
|
||||
$module = mres($_POST['toggle_discovery']);
|
||||
if (isset($attribs['discover_'.$module]) && $attribs['discover_'.$module] != $config['discovery_modules'][$_POST['toggle_discovery']])
|
||||
{
|
||||
del_dev_attrib($device, 'discover_' . $module);
|
||||
} elseif ($config['discovery_modules'][$_POST['toggle_discovery']] == 0) {
|
||||
set_dev_attrib($device, 'discover_' . $module, "1");
|
||||
} else {
|
||||
set_dev_attrib($device, 'discover_' . $module, "0");
|
||||
}
|
||||
$attribs = get_dev_attribs($device['device_id']);
|
||||
}
|
||||
|
||||
echo('<div style="margin: 0px 10px; width: 500px; float: left;">');
|
||||
$i=0;
|
||||
|
||||
echo('<div style="padding:4px 0px 4px 8px;" class=graphhead>Poller Modules</div>');
|
||||
|
||||
echo('<table width="100%" cellpadding=5>');
|
||||
echo('<tr><th>Module</th><th>Global</th><th>Device</th></tr>');
|
||||
foreach($config['poller_modules'] as $module => $module_status)
|
||||
{
|
||||
if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
|
||||
echo('<tr bgcolor="'.$bg_colour.'"><td><b>'.$module.'</b></td><td>'.($module_status ? '<span class=green>enabled</span>' : '<span class=red>disabled</span>' ).'</td></tr>');
|
||||
|
||||
echo('<tr bgcolor="'.$bg_colour.'"><td><b>'.$module.'</b></td><td>');
|
||||
|
||||
echo(($module_status ? '<span class=green>enabled</span>' : '<span class=red>disabled</span>' ));
|
||||
|
||||
echo('</td><td>');
|
||||
|
||||
if(isset($attribs['poll_'.$module]))
|
||||
{
|
||||
if ($attribs['poll_'.$module]) {echo("<span class=green>enabled</span>");} else { echo('<span class=red>disabled</span>'); }
|
||||
} else {
|
||||
echo(($module_status ? '<span class=green>enabled</span>' : '<span class=red>disabled</span>' ));
|
||||
}
|
||||
|
||||
|
||||
echo('</td><td>');
|
||||
|
||||
echo('<form id="toggle_poller" name="toggle_poller" method="post" action="">
|
||||
<input type=hidden name="toggle_poller" value="'.$module.'">
|
||||
<input type="submit" name="Submit" value="Toggle" />
|
||||
</label>
|
||||
</form>');
|
||||
|
||||
|
||||
echo('</td></tr>');
|
||||
$i++;
|
||||
}
|
||||
echo('</table>');
|
||||
@@ -19,10 +72,36 @@ echo('<div style="margin: 0px 10px; width: 500px; float: right;">');
|
||||
$i=0;
|
||||
echo('<div style="padding:4px 0px 4px 8px;" class=graphhead>Discovery Modules</div>');
|
||||
echo('<table width="100%" cellpadding=5>');
|
||||
echo('<tr><th>Module</th><th>Global</th><th>Device</th></tr>');
|
||||
foreach($config['discovery_modules'] as $module => $module_status)
|
||||
{
|
||||
if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
|
||||
echo('<tr bgcolor="'.$bg_colour.'"><td><b>'.$module.'</b></td><td>'.($module_status ? '<span class=green>enabled</span>' : '<span class=red>disabled</span>' ).'</td></tr>');
|
||||
echo('<tr bgcolor="'.$bg_colour.'"><td><b>'.$module.'</b></td><td>');
|
||||
|
||||
echo(($module_status ? '<span class=green>enabled</span>' : '<span class=red>disabled</span>' ));
|
||||
|
||||
echo('</td><td>');
|
||||
|
||||
if(isset($attribs['discover_'.$module]))
|
||||
{
|
||||
if ($attribs['discover_'.$module]) {echo("<span class=green>enabled</span>");} else { echo('<span class=red>disabled</span>'); }
|
||||
} else {
|
||||
echo(($module_status ? '<span class=green>enabled</span>' : '<span class=red>disabled</span>' ));
|
||||
}
|
||||
|
||||
|
||||
echo('</td><td>');
|
||||
|
||||
echo('<form id="toggle_discovery" name="toggle_discovery" method="post" action="">
|
||||
<input type=hidden name="toggle_discovery" value="'.$module.'">
|
||||
<input type="submit" name="Submit" value="Toggle" />
|
||||
</label>
|
||||
</form>');
|
||||
|
||||
|
||||
echo('</td></tr>');
|
||||
|
||||
|
||||
$i++;
|
||||
}
|
||||
echo('</table>');
|
||||
|
||||
+7
-1
@@ -108,6 +108,8 @@ function poll_device($device, $options) {
|
||||
|
||||
global $config;
|
||||
|
||||
$attribs = get_dev_attribs($device['device_id']);
|
||||
|
||||
$status = 0; unset($array);
|
||||
$device_start = utime(); // Start counting device poll time
|
||||
|
||||
@@ -164,9 +166,13 @@ function poll_device($device, $options) {
|
||||
} else {
|
||||
foreach($config['poller_modules'] as $module => $module_status)
|
||||
{
|
||||
if($module_status || $device_attribs['poller_module'][$module])
|
||||
if ($attribs['poll_'.$module] || ( $module_status && !isset($attribs['poll_'.$module])))
|
||||
{
|
||||
include('includes/polling/'.$module.'.inc.php');
|
||||
} elseif (isset($attribs['poll_'.$module]) && $attribs['poll_'.$module] == "0") {
|
||||
echo("Module [ $module ] disabled on host.\n");
|
||||
} else {
|
||||
echo("Module [ $module ] disabled globally.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user