mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
genericify move thing sto the correct places
git-svn-id: http://www.observium.org/svn/observer/trunk@2466 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -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]');
|
||||
|
||||
|
@@ -1,5 +1,116 @@
|
||||
<?php
|
||||
|
||||
/* Observium Network Management and Monitoring System
|
||||
* Copyright (C) 2006-2011, Observium Developers - http://www.observium.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* See COPYING for more details.
|
||||
*/
|
||||
|
||||
function discover_new_device($hostname)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if($config['autodiscovery']['xdp']) {
|
||||
if ( isDomainResolves($hostname . "." . $config['mydomain']) ) {
|
||||
$dst_host = $hostname . "." . $config['mydomain'];
|
||||
} else {
|
||||
$dst_host = $hostname;
|
||||
}
|
||||
$ip = gethostbyname($dst_host);
|
||||
|
||||
if ( match_network($config['nets'], $ip) )
|
||||
{
|
||||
$remote_device_id = addHost ($dst_host, NULL, "v2c");
|
||||
if($remote_device_id) {
|
||||
$remote_device = device_by_id_cache($remote_device_id, 1);
|
||||
echo("+[".$remote_device['hostname']."(".$remote_device['device_id'].")]");
|
||||
discover_device($remote_device);
|
||||
$remote_device = device_by_id_cache($remote_device_id, 1);
|
||||
return $remote_device_id;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
function discover_device($device, $options = NULL)
|
||||
{
|
||||
|
||||
global $config;
|
||||
$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++;
|
||||
}
|
||||
|
||||
### 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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user