mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
cycle all configured communities on addhost, remove dead code, minor optimisation on isdomainresolves
git-svn-id: http://www.observium.org/svn/observer/trunk@1933 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
27
addhost.php
27
addhost.php
@@ -44,20 +44,23 @@ if (isset($argv[1]) && $argv[1])
|
||||
{
|
||||
if (isPingable($argv[1]))
|
||||
{
|
||||
# FIXME should be a foreach $config['snmp']['community'][0] as $community
|
||||
$community = $config['snmp']['community'][0];
|
||||
$added = 0;
|
||||
|
||||
foreach ($config['snmp']['community'] as $community)
|
||||
{
|
||||
$device = deviceArray($host, $community, $snmpver, $port, $transport);
|
||||
|
||||
$device = deviceArray($host, $community, $snmpver, $port, $transport);
|
||||
if (isSNMPable($device))
|
||||
{
|
||||
$snmphost = snmp_get($device, "sysName.0", "-Oqv", "SNMPv2-MIB");
|
||||
if ($snmphost == "" || ($snmphost && ($snmphost == $host || $hostshort = $host)))
|
||||
{
|
||||
$added = createHost ($host, $community, $snmpver, $port, $transport);
|
||||
if($added) { echo($added . "\n"); break; }
|
||||
|
||||
if (isSNMPable($device))
|
||||
{
|
||||
$snmphost = snmp_get($device, "sysName.0", "-Oqv", "SNMPv2-MIB");
|
||||
if ($snmphost == "" || ($snmphost && ($snmphost == $host || $hostshort = $host)))
|
||||
{
|
||||
$return = createHost ($host, $community, $snmpver, $port, $transport);
|
||||
if($return) { echo($return . "\n"); } else { echo("Adding $host failed\n"); }
|
||||
} else { echo("Given hostname does not match SNMP-read hostname ($snmphost)!\n"); }
|
||||
} else { echo("Could not reach $host with SNMP\n"); }
|
||||
} else { echo("Given hostname does not match SNMP-read hostname ($snmphost)!\n"); }
|
||||
}
|
||||
}
|
||||
} else { echo("Could not ping $host\n"); }
|
||||
} else { echo("Could not resolve $host\n"); }
|
||||
} else { echo("Already got host $host\n"); }
|
||||
|
||||
@@ -528,7 +528,7 @@ function createHost($host, $community, $snmpver, $port = 161, $transport = 'udp'
|
||||
|
||||
function isDomainResolves($domain)
|
||||
{
|
||||
return (gethostbyname($domain) != $domain | count(dns_get_record($domain)) != 0);
|
||||
return (gethostbyname($domain) != $domain || count(dns_get_record($domain)) != 0);
|
||||
}
|
||||
|
||||
function hoststatus($id)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
## FIXME not used, do we still need this?
|
||||
## included from includes/unix.php, which is also unused
|
||||
|
||||
function mailerrorgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
|
||||
global $config, $installdir;
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<?php
|
||||
include("unix-graphing.php");
|
||||
?>
|
||||
Reference in New Issue
Block a user