mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
new funky discovery stuff (autodiscovery works now for discovery protocols)
git-svn-id: http://www.observium.org/svn/observer/trunk@2460 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
+2
-71
@@ -16,6 +16,7 @@ include("includes/defaults.inc.php");
|
||||
include("config.php");
|
||||
include("includes/functions.php");
|
||||
include("includes/discovery/functions.inc.php");
|
||||
include("includes/discovery.inc.php");
|
||||
|
||||
$start = utime();
|
||||
$runtime_stats = array();
|
||||
@@ -151,79 +152,9 @@ $discovered_devices = 0;
|
||||
foreach (dbFetch("SELECT * FROM `devices` WHERE status = 1 AND disabled = 0 $where ORDER BY device_id DESC") as $device)
|
||||
{
|
||||
discover_device($device, $options);
|
||||
}
|
||||
|
||||
function discover_device($device, $options)
|
||||
{
|
||||
print_r($options);
|
||||
|
||||
global $config;
|
||||
global $device;
|
||||
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']." ");
|
||||
|
||||
if($device['os'] == 'generic') // verify if OS has changed from generic
|
||||
{
|
||||
$device['os']= getHostOS($device);
|
||||
if($device['os'] != 'generic')
|
||||
{
|
||||
echo "Device os was updated to".$device['os']."!";
|
||||
dbUpdate(array('os' => $device['os']), 'devices', '`device_id` = ?', array($device['device_id']));
|
||||
}
|
||||
}
|
||||
|
||||
if ($config['os'][$device['os']]['group'])
|
||||
{
|
||||
$device['os_group'] = $config['os'][$device['os']]['group'];
|
||||
echo("(".$device['os_group'].")");
|
||||
}
|
||||
|
||||
echo("\n");
|
||||
|
||||
### If we've specified a module, use that, else walk the modules array
|
||||
if ($options['m'])
|
||||
{
|
||||
if (is_file("includes/discovery/".$options['m'].".inc.php"))
|
||||
{
|
||||
include("includes/discovery/".$options['m'].".inc.php");
|
||||
}
|
||||
} else {
|
||||
foreach($config['discovery_modules'] as $module => $module_status)
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
### Set type to a predefined type for the OS if it's not already set
|
||||
|
||||
if ($device['type'] == "unknown" || $device['type'] == "")
|
||||
{
|
||||
if ($config['os'][$device['os']]['type'])
|
||||
{
|
||||
$device['type'] = $config['os'][$device['os']]['type'];
|
||||
}
|
||||
}
|
||||
|
||||
$device_end = utime(); $device_run = $device_end - $device_start; $device_time = substr($device_run, 0, 5);
|
||||
|
||||
dbUpdate(array('last_discovered' => array('NOW()'), 'type' => $device['type'], 'last_discovered_timetaken' => $device_time), 'devices', '`device_id` = ?', array($device['device_id']));
|
||||
|
||||
echo("Discovered in $device_time seconds\n");
|
||||
|
||||
global $discovered_devices;
|
||||
|
||||
echo("\n"); $discovered_devices++;
|
||||
}
|
||||
|
||||
$end = utime(); $run = $end - $start;
|
||||
|
||||
Reference in New Issue
Block a user