From c50de1713debc78a4f073eaf27bfe5c7f60a273b Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Thu, 15 Sep 2011 15:03:42 +0000 Subject: [PATCH] genericify move thing sto the correct places git-svn-id: http://www.observium.org/svn/observer/trunk@2466 61d68cd4-352d-0410-923a-c4978735b2b8 --- discovery.php | 7 +- includes/discovery/functions.inc.php | 111 +++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 4 deletions(-) diff --git a/discovery.php b/discovery.php index 992781f7bd..199783e5f4 100755 --- a/discovery.php +++ b/discovery.php @@ -16,7 +16,6 @@ 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(); @@ -169,10 +168,10 @@ if($config['version_check'] && !isset($options['q'])) { include("includes/versioncheck.inc.php"); echo('MySQL: Cell['.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,2).'s]'. - ' Row[' .($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,2).'s]'. - ' Rows[' .($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,2).'s]'. + ' Row['.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,2).'s]'. + ' Rows['.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,2).'s]'. ' Column['.($db_stats['fetchcol']+0). '/'.round($db_stats['fetchcol_sec']+0,2).'s]'. - ' Update[' .($db_stats['update']+0).'/'.round($db_stats['update_sec']+0,2).'s]'. + ' Update['.($db_stats['update']+0).'/'.round($db_stats['update_sec']+0,2).'s]'. ' Insert['.($db_stats['insert']+0). '/'.round($db_stats['insert_sec']+0,2).'s]'. ' Delete['.($db_stats['delete']+0). '/'.round($db_stats['delete_sec']+0,2).'s]'); diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index 7a0be1c48a..74f4c2c694 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -1,5 +1,116 @@ $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++; +} + ### Discover sensors function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, $divisor = '1', $multiplier = '1', $low_limit = NULL, $low_warn_limit = NULL, $warn_limit = NULL, $high_limit = NULL, $current = NULL, $poller_type = 'snmp', $entPhysicalIndex = NULL, $entPhysicalIndex_measured = NULL) {