mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
recognise some new OSes, add an image for dlink, move sysObjectId polling to be global for os detection
git-svn-id: http://www.observium.org/svn/observer/trunk@1345 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
16
addhost.php
16
addhost.php
@@ -18,17 +18,19 @@ if($argv[1]) {
|
|||||||
if (!$community) $community = $config['community'];
|
if (!$community) $community = $config['community'];
|
||||||
|
|
||||||
list($hostshort) = explode(".", $host);
|
list($hostshort) = explode(".", $host);
|
||||||
if ( isDomainResolves($argv[1])){
|
if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '".mres($host)."'"), 0) == '0' ) {
|
||||||
if ( isPingable($argv[1])) {
|
if ( isDomainResolves($argv[1])){
|
||||||
if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '".mres($host)."'"), 0) == '0' ) {
|
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")));
|
$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);
|
$return = createHost ($host, $community, $snmpver, $port);
|
||||||
if($return) { echo($return . "\n"); } else { echo("Adding $host failed\n"); }
|
if($return) { echo($return . "\n"); } else { echo("Adding $host failed\n"); }
|
||||||
} else { echo("Given hostname does not match SNMP-read hostname!\n"); }
|
} else { echo("Given hostname does not match SNMP-read hostname!\n"); }
|
||||||
} else { echo("Already got host $host\n"); }
|
} else { echo("Could not reach $host with SNMP\n"); }
|
||||||
} else { echo("Could not ping $host\n"); }
|
} else { echo("Could not ping $host\n"); }
|
||||||
} else { echo("Could not resolve $host\n"); }
|
} else { echo("Could not resolve $host\n"); }
|
||||||
|
} else { echo("Already got host $host\n"); }
|
||||||
} else { echo("Add Host Tool\nUsage: ./addhost.php <hostname> [community] [v1|v2c] [port]\n"); }
|
} else { echo("Add Host Tool\nUsage: ./addhost.php <hostname> [community] [v1|v2c] [port]\n"); }
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
BIN
html/images/os/dlink.png
Normal file
BIN
html/images/os/dlink.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 997 B |
@@ -99,8 +99,10 @@ function getHostOS($device)
|
|||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$sysDescr_cmd = $config['snmpget']." -m SNMPv2-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " sysDescr.0";
|
$sysDescr = snmp_get ($device, "sysDescr.0", "-Ovq");
|
||||||
$sysDescr = str_replace("\"", "", trim(shell_exec($sysDescr_cmd)));
|
$sysObjectId = snmp_get ($device, "sysObjectID.0", "-Ovqn");
|
||||||
|
|
||||||
|
|
||||||
$dir_handle = @opendir($config['install_dir'] . "/includes/osdiscovery") or die("Unable to open $path");
|
$dir_handle = @opendir($config['install_dir'] . "/includes/osdiscovery") or die("Unable to open $path");
|
||||||
while ($file = readdir($dir_handle))
|
while ($file = readdir($dir_handle))
|
||||||
{
|
{
|
||||||
|
|||||||
9
includes/osdiscovery/discover-airport.php
Normal file
9
includes/osdiscovery/discover-airport.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if(!$os) {
|
||||||
|
|
||||||
|
if(strpos($sysDescr, "Apple AirPort") !== FALSE) { $os = "airport"; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
if(!$os) {
|
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"; }
|
if(strstr($sysObjectId, ".1.3.6.1.4.1.207")) { $os = "allied"; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
10
includes/osdiscovery/discover-dlink.inc.php
Normal file
10
includes/osdiscovery/discover-dlink.inc.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if(!$os) {
|
||||||
|
|
||||||
|
if(strpos($sysDescr, "DES-") !== FALSE) { $os = "dlink"; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
9
includes/osdiscovery/discover-extremeware.php
Executable file
9
includes/osdiscovery/discover-extremeware.php
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if(!$os) {
|
||||||
|
|
||||||
|
if(strstr($sysObjectId, ".1.3.6.1.4.1.1916.2")) { $os = "extremeware"; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
if(!$os) {
|
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"; }
|
if(strstr($sysObjectId, ".1.3.6.1.4.1.2636")) { $os = "junos"; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
if(!$os) {
|
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"; }
|
if(strstr($sysObjectId, ".1.3.6.1.4.1.4874")) { $os = "junose"; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
10
includes/osdiscovery/discover-zywall.php
Normal file
10
includes/osdiscovery/discover-zywall.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if(!$os) {
|
||||||
|
|
||||||
|
if(strpos($sysDescr, "ZyWALL") !== FALSE) { $os = "zywall"; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user