fix lldp discovery code, small fix, addhost fix

git-svn-id: http://www.observium.org/svn/observer/trunk@1547 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2010-07-30 15:04:44 +00:00
parent be799247e3
commit ee3fbf8a5f
4 changed files with 16 additions and 12 deletions
+3 -2
View File
@@ -15,14 +15,15 @@ if($argv[1]) {
$port = 161;
if (!$snmpver) $snmpver = "v2c";
if (!$community) $community = $config['snmp']['community'][0];
if ($community) { unset($config['snmp']['community']); $config['snmp']['community'][] = $community; }
list($hostshort) = explode(".", $host);
if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '".mres($host)."'"), 0) == '0' ) {
if ( isDomainResolves($argv[1])){
if ( isPingable($argv[1])) {
if ( isSNMPable($argv[1], $community, $snmpver, $port)) {
$snmphost = trim(str_replace("\"", "", shell_exec($config['snmpget'] ." -m SNMPv2-MIB -Oqv -$snmpver -c $community $host:$port sysName.0")));
# FIXME should be a foreach $config['snmp']['community'][0] as $community
$snmphost = trim(str_replace("\"", "", shell_exec($config['snmpget'] ." -m SNMPv2-MIB -Oqv -$snmpver -c ".$config['snmp']['community'][0]." $host:$port sysName.0")));
if ($snmphost == "" || ($snmphost && ($snmphost == $host || $hostshort = $host))) {
$return = createHost ($host, $community, $snmpver, $port);
if($return) { echo($return . "\n"); } else { echo("Adding $host failed\n"); }