mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Add IPv6 only host support
This commit is contained in:
@ -24,7 +24,8 @@ if ($_POST['hostname'])
|
||||
|
||||
$snmpver = mres($_POST['snmpver']);
|
||||
if ($_POST['port']) { $port = mres($_POST['port']); } else { $port = $config['snmp']['port']; }
|
||||
print_message("Adding host $hostname communit" . (count($config['snmp']['community']) == 1 ? "y" : "ies") . " " . implode(', ',$config['snmp']['community']) . " port $port");
|
||||
$transport = mres($_POST['transport']);
|
||||
print_message("Adding host $hostname communit" . (count($config['snmp']['community']) == 1 ? "y" : "ies") . " " . implode(', ',$config['snmp']['community']) . " port $port using $transport");
|
||||
}
|
||||
elseif ($_POST['snmpver'] === "v3")
|
||||
{
|
||||
@ -48,7 +49,7 @@ if ($_POST['hostname'])
|
||||
{
|
||||
print_error("Unsupported SNMP Version. There was a dropdown menu, how did you reach this error ?");
|
||||
}
|
||||
$result = addHost($hostname, $snmpver, $port);
|
||||
$result = addHost($hostname, $snmpver, $port, $transport);
|
||||
if ($result)
|
||||
{
|
||||
print_message("Device added ($result)");
|
||||
@ -75,7 +76,7 @@ $pagetitle[] = "Add host";
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="snmpver" class="col-sm-2 control-label">SNMP Version</label>
|
||||
<div class="col-sm-3">
|
||||
<div class="col-sm-2">
|
||||
<select name="snmpver" id="snmpver" class="form-control input-sm">
|
||||
<option value="v1">v1</option>
|
||||
<option value="v2c" selected>v2c</option>
|
||||
@ -85,6 +86,14 @@ $pagetitle[] = "Add host";
|
||||
<div class="col-sm-2">
|
||||
<input type="text" name="port" placeholder="port" class="form-control input-sm">
|
||||
</div>
|
||||
<div class="col-sm-1">
|
||||
<select name="transport" id="transport" class="form-control input-sm">
|
||||
<option value="tcp">tcp</option>
|
||||
<option value="udp" selected>udp</option>
|
||||
<option value="tcp6">tcp6</option>
|
||||
<option value="udp6">udp6</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-sm-5">
|
||||
</div>
|
||||
</div>
|
||||
|
@ -261,7 +261,8 @@ function addHost($host, $snmpver, $port = '161', $transport = 'udp')
|
||||
if (dbFetchCell("SELECT COUNT(*) FROM `devices` WHERE `hostname` = ?", array($host)) == '0')
|
||||
{
|
||||
// Test DNS lookup
|
||||
if (gethostbyname($host) != $host)
|
||||
//if (gethostbyname($host) != $host)
|
||||
if (!(inet_pton($host)))
|
||||
{
|
||||
// Test reachability
|
||||
if (isPingable($host))
|
||||
@ -350,7 +351,7 @@ function addHost($host, $snmpver, $port = '161', $transport = 'udp')
|
||||
print_error("Could not ping $host"); }
|
||||
} else {
|
||||
// Failed DNS lookup
|
||||
print_error("Could not resolve $host"); }
|
||||
print_error("$host looks like an IP address, please use FQDN"); }
|
||||
} else {
|
||||
// found in database
|
||||
print_error("Already got host $host");
|
||||
|
Reference in New Issue
Block a user