diff --git a/addhost.php b/addhost.php index 7e7bd2a9a..b33cd6058 100755 --- a/addhost.php +++ b/addhost.php @@ -18,17 +18,19 @@ if($argv[1]) { if (!$community) $community = $config['community']; list($hostshort) = explode(".", $host); - if ( isDomainResolves($argv[1])){ - if ( isPingable($argv[1])) { - if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '".mres($host)."'"), 0) == '0' ) { + 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"))); - if ($snmphost == "" || $snmphost && ($snmphost == $host || $hostshort = $host)) { + if ($snmphost != "" || $snmphost && ($snmphost == $host || $hostshort = $host)) { $return = createHost ($host, $community, $snmpver, $port); if($return) { echo($return . "\n"); } else { echo("Adding $host failed\n"); } } else { echo("Given hostname does not match SNMP-read hostname!\n"); } - } else { echo("Already got host $host\n"); } - } else { echo("Could not ping $host\n"); } - } else { echo("Could not resolve $host\n"); } + } else { echo("Could not reach $host with SNMP\n"); } + } else { echo("Could not ping $host\n"); } + } else { echo("Could not resolve $host\n"); } + } else { echo("Already got host $host\n"); } } else { echo("Add Host Tool\nUsage: ./addhost.php [community] [v1|v2c] [port]\n"); } ?> diff --git a/html/images/os/dlink.png b/html/images/os/dlink.png new file mode 100644 index 000000000..93a8338ac Binary files /dev/null and b/html/images/os/dlink.png differ diff --git a/includes/functions.php b/includes/functions.php index d0afd06e7..8429a2904 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -99,8 +99,10 @@ function getHostOS($device) { global $config; - $sysDescr_cmd = $config['snmpget']." -m SNMPv2-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " sysDescr.0"; - $sysDescr = str_replace("\"", "", trim(shell_exec($sysDescr_cmd))); + $sysDescr = snmp_get ($device, "sysDescr.0", "-Ovq"); + $sysObjectId = snmp_get ($device, "sysObjectID.0", "-Ovqn"); + + $dir_handle = @opendir($config['install_dir'] . "/includes/osdiscovery") or die("Unable to open $path"); while ($file = readdir($dir_handle)) { diff --git a/includes/osdiscovery/discover-airport.php b/includes/osdiscovery/discover-airport.php new file mode 100644 index 000000000..64f2006df --- /dev/null +++ b/includes/osdiscovery/discover-airport.php @@ -0,0 +1,9 @@ + diff --git a/includes/osdiscovery/discover-allied.php b/includes/osdiscovery/discover-allied.php index 6421e9206..d6b14b147 100755 --- a/includes/osdiscovery/discover-allied.php +++ b/includes/osdiscovery/discover-allied.php @@ -2,7 +2,6 @@ if(!$os) { - $sysObjectId = shell_exec($config['snmpget'] . " -Ovqn -".$device['snmpver']." -c ". $device['community'] ." ". $device['hostname'].":".$device['port'] ." sysObjectID.0"); if(strstr($sysObjectId, ".1.3.6.1.4.1.207")) { $os = "allied"; } } diff --git a/includes/osdiscovery/discover-dlink.inc.php b/includes/osdiscovery/discover-dlink.inc.php new file mode 100644 index 000000000..08427e8a6 --- /dev/null +++ b/includes/osdiscovery/discover-dlink.inc.php @@ -0,0 +1,10 @@ + diff --git a/includes/osdiscovery/discover-extremeware.php b/includes/osdiscovery/discover-extremeware.php new file mode 100755 index 000000000..bc356f18c --- /dev/null +++ b/includes/osdiscovery/discover-extremeware.php @@ -0,0 +1,9 @@ + diff --git a/includes/osdiscovery/discover-junos.php b/includes/osdiscovery/discover-junos.php index fef8c26c9..20946de6d 100755 --- a/includes/osdiscovery/discover-junos.php +++ b/includes/osdiscovery/discover-junos.php @@ -2,7 +2,6 @@ if(!$os) { - $sysObjectId = shell_exec($config['snmpget'] . " -Ovqn -".$device['snmpver']." -c ". $device['community'] ." ". $device['hostname'].":".$device['port'] ." sysObjectID.0"); if(strstr($sysObjectId, ".1.3.6.1.4.1.2636")) { $os = "junos"; } } diff --git a/includes/osdiscovery/discover-junose.php b/includes/osdiscovery/discover-junose.php index 2f2b7d42a..7a4f8f542 100755 --- a/includes/osdiscovery/discover-junose.php +++ b/includes/osdiscovery/discover-junose.php @@ -2,7 +2,6 @@ if(!$os) { - $sysObjectId = shell_exec($config['snmpget'] . " -Ovqn -".$device['snmpver']." -c ". $device['community'] ." ". $device['hostname'].":".$device['port'] ." sysObjectID.0"); if(strstr($sysObjectId, ".1.3.6.1.4.1.4874")) { $os = "junose"; } } diff --git a/includes/osdiscovery/discover-zywall.php b/includes/osdiscovery/discover-zywall.php new file mode 100644 index 000000000..7ae44e51d --- /dev/null +++ b/includes/osdiscovery/discover-zywall.php @@ -0,0 +1,10 @@ +