mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-02 00:32:09 +02:00
make addhost from the webinterface work correctly
git-svn-id: http://www.observium.org/svn/observer/trunk@2646 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
+1
-1
@@ -46,7 +46,7 @@ if (isset($argv[1]) && $argv[1])
|
|||||||
$config['snmp']['community'] = array($community);
|
$config['snmp']['community'] = array($community);
|
||||||
}
|
}
|
||||||
|
|
||||||
$device_id = addHost($host, $community, $snmpver, $port, $transport);
|
$device_id = addHost($host, $snmpver, $port, $transport);
|
||||||
|
|
||||||
if ($device_id)
|
if ($device_id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,11 +13,20 @@ if ($_POST['hostname'])
|
|||||||
if ($_SESSION['userlevel'] > '5')
|
if ($_SESSION['userlevel'] > '5')
|
||||||
{
|
{
|
||||||
$hostname = mres($_POST['hostname']);
|
$hostname = mres($_POST['hostname']);
|
||||||
if ($_POST['community']) { $community = mres($_POST['community']); } else { $community = $config['snmp']['community']; }
|
|
||||||
|
if ($_POST['community'])
|
||||||
|
{
|
||||||
|
$config['snmp']['community'] = array($_POST['community']);
|
||||||
|
}
|
||||||
|
|
||||||
$snmpver = mres($_POST['snmpver']);
|
$snmpver = mres($_POST['snmpver']);
|
||||||
if ($_POST['port']) { $port = mres($_POST['port']); } else { $port = "161"; }
|
if ($_POST['port']) { $port = mres($_POST['port']); } else { $port = "161"; }
|
||||||
print_message("Adding host $hostname community $community port $port");
|
print_message("Adding host $hostname communit" . (count($config['snmp']['community']) == 1 ? "y" : "ies") . " " . implode(', ',$config['snmp']['community']) . " port $port");
|
||||||
$result = addHost($hostname, $community, $snmpver, $port);
|
$result = addHost($hostname, $snmpver, $port);
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
print_message("Device added ($result)");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
print_error("You don't have the necessary privileges to add hosts.");
|
print_error("You don't have the necessary privileges to add hosts.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ function delete_device($id)
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addHost($host, $community = NULL, $snmpver = 'v2c', $port = '161', $transport = 'udp')
|
function addHost($host, $snmpver = 'v2c', $port = '161', $transport = 'udp')
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user