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:
Tom Laermans
2011-10-05 09:32:34 +00:00
parent 86c65da8aa
commit 83f335785b
3 changed files with 14 additions and 5 deletions
+1 -1
View File
@@ -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)
{ {
+12 -3
View File
@@ -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.");
} }
+1 -1
View File
@@ -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;