mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00: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:
+5
-2
@@ -41,14 +41,17 @@ if (isset($argv[1]) && $argv[1])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$snmpver) $snmpver = "v2c";
|
if (!$snmpver) $snmpver = "v2c";
|
||||||
|
|
||||||
if ($community)
|
if ($community)
|
||||||
{
|
{
|
||||||
unset($config['snmp']['community']);
|
unset($config['snmp']['community']);
|
||||||
$config['snmp']['community'][] = $community;
|
$config['snmp']['community'][] = $community;
|
||||||
}
|
}
|
||||||
|
$device_id = addHost($host, $community, $snmpver, $port = '161', $transport = 'udp');
|
||||||
|
|
||||||
addHost($host, $community, $snmpver, $port = '161', $transport = 'udp');
|
if($device_id) {
|
||||||
|
$device = device_by_id_cache($device_id);
|
||||||
|
echo("Added device ".$device['hostname']." (".$device['device_id'].")\n");
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -4,5 +4,5 @@ ALTER TABLE `bgpPeers_cbgp` ADD `AcceptedPrefixes` INT NOT NULL ,ADD `DeniedP
|
|||||||
ALTER TABLE `bgpPeers_cbgp` ADD UNIQUE `unique_index` ( `device_id` , `bgpPeerIdentifier` , `afi` , `safi` );
|
ALTER TABLE `bgpPeers_cbgp` ADD UNIQUE `unique_index` ( `device_id` , `bgpPeerIdentifier` , `afi` , `safi` );
|
||||||
ALTER TABLE `ports` ADD UNIQUE `device_ifIndex` ( `device_id` , `ifIndex` );
|
ALTER TABLE `ports` ADD UNIQUE `device_ifIndex` ( `device_id` , `ifIndex` );
|
||||||
ALTER TABLE `devices` CHANGE `port` `port` SMALLINT( 5 ) UNSIGNED NOT NULL DEFAULT '161';
|
ALTER TABLE `devices` CHANGE `port` `port` SMALLINT( 5 ) UNSIGNED NOT NULL DEFAULT '161';
|
||||||
CREATE TABLE IF NOT EXISTS `ipsec_tunnels` ( `tunnel_id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) NOT NULL, `peer_port` int(11) NOT NULL, `peer_addr` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `local_addr` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `local_port` int(11) NOT NULL, `tunnel_name` varchar(96) COLLATE utf8_unicode_ci NOT NULL, `tunnel_status` varchar(11) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`tunnel_id`), UNIQUE KEY `unique_index` (`device_id`,`peer_addr`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;
|
CREATE TABLE IF NOT EXISTS `ipsec_tunnels` ( `tunnel_id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) NOT NULL, `peer_port` int(11) NOT NULL, `peer_addr` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `local_addr` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `local_port` int(11) NOT NULL, `tunnel_name` varchar(96) COLLATE utf8_unicode_ci NOT NULL, `tunnel_status` varchar(11) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`tunnel_id`), UNIQUE KEY `unique_index` (`device_id`,`peer_addr`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||||
|
|
||||||
|
|||||||
+2
-71
@@ -16,6 +16,7 @@ include("includes/defaults.inc.php");
|
|||||||
include("config.php");
|
include("config.php");
|
||||||
include("includes/functions.php");
|
include("includes/functions.php");
|
||||||
include("includes/discovery/functions.inc.php");
|
include("includes/discovery/functions.inc.php");
|
||||||
|
include("includes/discovery.inc.php");
|
||||||
|
|
||||||
$start = utime();
|
$start = utime();
|
||||||
$runtime_stats = array();
|
$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)
|
foreach (dbFetch("SELECT * FROM `devices` WHERE status = 1 AND disabled = 0 $where ORDER BY device_id DESC") as $device)
|
||||||
{
|
{
|
||||||
discover_device($device, $options);
|
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;
|
$end = utime(); $run = $end - $start;
|
||||||
|
|||||||
+2
-2
@@ -179,11 +179,11 @@ function ifclass($ifOperStatus, $ifAdminStatus)
|
|||||||
return $ifclass;
|
return $ifclass;
|
||||||
}
|
}
|
||||||
|
|
||||||
function device_by_id_cache($device_id)
|
function device_by_id_cache($device_id, $refresh = '0')
|
||||||
{
|
{
|
||||||
global $device_cache;
|
global $device_cache;
|
||||||
|
|
||||||
if (isset($device_cache[$device_id]) && is_array($device_cache[$device_id]))
|
if (!$refresh && isset($device_cache[$device_id]) && is_array($device_cache[$device_id]))
|
||||||
{
|
{
|
||||||
$device = $device_cache[$device_id];
|
$device = $device_cache[$device_id];
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -34,8 +34,9 @@ $config['virsh'] = "/usr/bin/virsh";
|
|||||||
|
|
||||||
if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["SERVER_PORT"]))
|
if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["SERVER_PORT"]))
|
||||||
{
|
{
|
||||||
$config['base_url'] = "http://" . $_SERVER["SERVER_NAME"] .":".$_SERVER["SERVER_PORT"];
|
$config['base_url'] = "http://" . $_SERVER["SERVER_NAME"] .":".$_SERVER["SERVER_PORT"]."/";
|
||||||
}
|
}
|
||||||
|
|
||||||
$config['title_image'] = "images/observium-logo.png";
|
$config['title_image'] = "images/observium-logo.png";
|
||||||
$config['stylesheet'] = "css/styles.css";
|
$config['stylesheet'] = "css/styles.css";
|
||||||
$config['mono_font'] = "DejaVuSansMono";
|
$config['mono_font'] = "DejaVuSansMono";
|
||||||
|
|||||||
Executable
+113
@@ -0,0 +1,113 @@
|
|||||||
|
<?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 ( 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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++;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -21,7 +21,12 @@ if ($device['os'] == "ironware")
|
|||||||
{
|
{
|
||||||
$fdp = $fdp_if_array[$entry_key];
|
$fdp = $fdp_if_array[$entry_key];
|
||||||
$remote_device_id = @mysql_result(mysql_query("SELECT `device_id` FROM `devices` WHERE `sysName` = '".$fdp['snFdpCacheDeviceId']."' OR `hostname`='".$fdp['snFdpCacheDeviceId']."'"), 0);
|
$remote_device_id = @mysql_result(mysql_query("SELECT `device_id` FROM `devices` WHERE `sysName` = '".$fdp['snFdpCacheDeviceId']."' OR `hostname`='".$fdp['snFdpCacheDeviceId']."'"), 0);
|
||||||
|
|
||||||
|
if(!$remote_device_id)
|
||||||
|
{
|
||||||
|
$remote_device_id = discover_new_device($fdp['snFdpCacheDeviceId']);
|
||||||
|
}
|
||||||
|
|
||||||
if ($remote_device_id)
|
if ($remote_device_id)
|
||||||
{
|
{
|
||||||
$if = $fdp['snFdpCacheDevicePort'];
|
$if = $fdp['snFdpCacheDevicePort'];
|
||||||
@@ -49,6 +54,12 @@ if ($cdp_array)
|
|||||||
$cdp = $cdp_if_array[$entry_key];
|
$cdp = $cdp_if_array[$entry_key];
|
||||||
$remote_device_id = @mysql_result(mysql_query("SELECT `device_id` FROM `devices` WHERE `sysName` = '".$cdp['cdpCacheDeviceId']."' OR `hostname`='".$cdp['cdpCacheDeviceId']."'"), 0);
|
$remote_device_id = @mysql_result(mysql_query("SELECT `device_id` FROM `devices` WHERE `sysName` = '".$cdp['cdpCacheDeviceId']."' OR `hostname`='".$cdp['cdpCacheDeviceId']."'"), 0);
|
||||||
|
|
||||||
|
if(!$remote_device_id)
|
||||||
|
{
|
||||||
|
$remote_device_id = discover_new_device($cdp['cdpCacheDeviceId']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($remote_device_id)
|
if ($remote_device_id)
|
||||||
{
|
{
|
||||||
$if = $cdp['cdpCacheDevicePort'];
|
$if = $cdp['cdpCacheDevicePort'];
|
||||||
@@ -89,13 +100,20 @@ if ($lldp_array)
|
|||||||
{
|
{
|
||||||
$lldp = $lldp_instance[$entry_instance];
|
$lldp = $lldp_instance[$entry_instance];
|
||||||
$remote_device_id = @mysql_result(mysql_query("SELECT `device_id` FROM `devices` WHERE `sysName` = '".$lldp['lldpRemSysName']."' OR `hostname`='".$lldp['lldpRemSysName']."'"), 0);
|
$remote_device_id = @mysql_result(mysql_query("SELECT `device_id` FROM `devices` WHERE `sysName` = '".$lldp['lldpRemSysName']."' OR `hostname`='".$lldp['lldpRemSysName']."'"), 0);
|
||||||
|
|
||||||
|
if(!$remote_device_id)
|
||||||
|
{
|
||||||
|
$remote_device_id = discover_new_device($lldp['lldpRemSysName']);
|
||||||
|
}
|
||||||
|
|
||||||
if ($remote_device_id)
|
if ($remote_device_id)
|
||||||
{
|
{
|
||||||
$if = $lldp['lldpRemPortDesc']; $id = $lldp['lldpRemPortId'];
|
$if = $lldp['lldpRemPortDesc']; $id = $lldp['lldpRemPortId'];
|
||||||
$remote_interface_id = @mysql_result(mysql_query("SELECT interface_id FROM `ports` WHERE (`ifDescr` = '$if' OR `ifName`='$if' OR `ifDescr`= '$id' OR `ifName`='$id') AND `device_id` = '".$remote_device_id."'"),0);
|
$remote_interface_id = @mysql_result(mysql_query("SELECT interface_id FROM `ports` WHERE (`ifDescr` = '$if' OR `ifName`='$if' OR `ifDescr`= '$id' OR `ifName`='$id') AND `device_id` = '".$remote_device_id."'"),0);
|
||||||
} else { $remote_interface_id = "0"; }
|
} else {
|
||||||
|
$remote_interface_id = "0";
|
||||||
|
}
|
||||||
|
|
||||||
if (is_numeric($interface['interface_id']) && isset($lldp['lldpRemSysName']) && isset($lldp['lldpRemPortId']))
|
if (is_numeric($interface['interface_id']) && isset($lldp['lldpRemSysName']) && isset($lldp['lldpRemPortId']))
|
||||||
{
|
{
|
||||||
discover_link($interface['interface_id'], 'lldp', $remote_interface_id, $lldp['lldpRemSysName'], $lldp['lldpRemPortId'], NULL, $lldp['lldpRemSysDesc']);
|
discover_link($interface['interface_id'], 'lldp', $remote_interface_id, $lldp['lldpRemSysName'], $lldp['lldpRemPortId'], NULL, $lldp['lldpRemSysDesc']);
|
||||||
|
|||||||
+21
-10
@@ -175,7 +175,7 @@ function delete_device($id)
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addHost($host, $community, $snmpver, $port = '161', $transport = 'udp')
|
function addHost($host, $community = NULL, $snmpver = 'v2c', $port = '161', $transport = 'udp')
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@@ -194,23 +194,26 @@ function addHost($host, $community, $snmpver, $port = '161', $transport = 'udp')
|
|||||||
foreach ($config['snmp']['community'] as $community)
|
foreach ($config['snmp']['community'] as $community)
|
||||||
{
|
{
|
||||||
$device = deviceArray($host, $community, $snmpver, $port, $transport);
|
$device = deviceArray($host, $community, $snmpver, $port, $transport);
|
||||||
|
|
||||||
if (isSNMPable($device))
|
if (isSNMPable($device))
|
||||||
{
|
{
|
||||||
|
print_message("Trying community $community");
|
||||||
$snmphost = snmp_get($device, "sysName.0", "-Oqv", "SNMPv2-MIB");
|
$snmphost = snmp_get($device, "sysName.0", "-Oqv", "SNMPv2-MIB");
|
||||||
if ($snmphost == "" || ($snmphost && ($snmphost == $host || $hostshort = $host)))
|
if ($snmphost == "" || ($snmphost && ($snmphost == $host || $hostshort = $host)))
|
||||||
{
|
{
|
||||||
$added = createHost ($host, $community, $snmpver, $port, $transport);
|
$device_id = createHost ($host, $community, $snmpver, $port, $transport);
|
||||||
if($added) { echo($added . "\n"); }
|
return $device_id;
|
||||||
} else {
|
} else {
|
||||||
print_error("Given hostname does not match SNMP-read hostname ($snmphost)!");
|
print_error("Given hostname does not match SNMP-read hostname ($snmphost)!");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
print_error("No reply on community $community");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$added)
|
if (!$device_id)
|
||||||
{
|
{
|
||||||
/// Faild SNMP
|
/// Faild SNMP
|
||||||
print_error("Could not reach $host with given SNMP community"); }
|
print_error("Could not reach $host with given SNMP community");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/// failed Reachability
|
/// failed Reachability
|
||||||
print_error("Could not ping $host"); }
|
print_error("Could not ping $host"); }
|
||||||
@@ -364,17 +367,25 @@ function utime()
|
|||||||
function createHost($host, $community, $snmpver, $port = 161, $transport = 'udp')
|
function createHost($host, $community, $snmpver, $port = 161, $transport = 'udp')
|
||||||
{
|
{
|
||||||
$host = trim(strtolower($host));
|
$host = trim(strtolower($host));
|
||||||
$device = array('hostname' => $host, 'sysName' => $host, 'community' => $community, 'port' => $port, 'transport' => $transport, 'status' => '1', 'snmpver' => $snmpver);
|
|
||||||
|
$device = array('hostname' => $host,
|
||||||
|
'sysName' => $host,
|
||||||
|
'community' => $community,
|
||||||
|
'port' => $port,
|
||||||
|
'transport' => $transport,
|
||||||
|
'status' => '1',
|
||||||
|
'snmpver' => $snmpver);
|
||||||
|
|
||||||
$device['os'] = getHostOS($device);
|
$device['os'] = getHostOS($device);
|
||||||
|
|
||||||
if ($device['os'])
|
if ($device['os'])
|
||||||
{
|
{
|
||||||
|
|
||||||
$id = dbInsert($device, 'devices');
|
$device_id = dbInsert($device, 'devices');
|
||||||
|
|
||||||
if ($id)
|
if ($device_id)
|
||||||
{
|
{
|
||||||
return("Created host : $host (id:".$id.") (os:".$device['os'].")");
|
return($device_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ if (!array_key_exists('SCRIPT_FILENAME', $_SERVER)
|
|||||||
# ============================================================================
|
# ============================================================================
|
||||||
$mysql_user = 'user';
|
$mysql_user = 'user';
|
||||||
$mysql_pass = 'password';
|
$mysql_pass = 'password';
|
||||||
|
$mysql_host = 'localhost';
|
||||||
$mysql_port = 3306;
|
$mysql_port = 3306;
|
||||||
$mysql_ssl = FALSE; # Whether to use SSL to connect to MySQL.
|
$mysql_ssl = FALSE; # Whether to use SSL to connect to MySQL.
|
||||||
|
|
||||||
@@ -160,9 +161,9 @@ if (!function_exists('array_change_key_case') ) {
|
|||||||
# ============================================================================
|
# ============================================================================
|
||||||
function validate_options($options) {
|
function validate_options($options) {
|
||||||
debug($options);
|
debug($options);
|
||||||
$opts = array('host', 'items', 'user', 'pass', 'heartbeat', 'nocache', 'port');
|
$opts = array('items', 'user', 'pass', 'heartbeat', 'nocache', 'port');
|
||||||
# Required command-line options
|
# Required command-line options
|
||||||
foreach ( array('host') as $option ) {
|
foreach ( array() as $option ) {
|
||||||
if (!isset($options[$option]) || !$options[$option] ) {
|
if (!isset($options[$option]) || !$options[$option] ) {
|
||||||
usage("Required option --$option is missing");
|
usage("Required option --$option is missing");
|
||||||
}
|
}
|
||||||
@@ -251,6 +252,8 @@ function ss_get_mysql_stats( $options ) {
|
|||||||
$user = isset($options['user']) ? $options['user'] : $mysql_user;
|
$user = isset($options['user']) ? $options['user'] : $mysql_user;
|
||||||
$pass = isset($options['pass']) ? $options['pass'] : $mysql_pass;
|
$pass = isset($options['pass']) ? $options['pass'] : $mysql_pass;
|
||||||
$port = isset($options['port']) ? $options['port'] : $mysql_port;
|
$port = isset($options['port']) ? $options['port'] : $mysql_port;
|
||||||
|
$port = isset($options['host']) ? $options['host'] : $mysql_host;
|
||||||
|
|
||||||
$heartbeat = isset($options['heartbeat']) ? $options['heartbeat'] : $heartbeat;
|
$heartbeat = isset($options['heartbeat']) ? $options['heartbeat'] : $heartbeat;
|
||||||
# If there is a port, or if it's a non-standard port, we add ":$port" to the
|
# If there is a port, or if it's a non-standard port, we add ":$port" to the
|
||||||
# hostname.
|
# hostname.
|
||||||
|
|||||||
Reference in New Issue
Block a user