Reconstruct addHost() so it is easier to understand

Update addHost() to return either device_id or a string
modify print_error(), print_message() to allow for $quiet variable
Only call addHost() once in addhost.php, if the snmp version isn't set, addHost will cope
Fix up snmp-scan.php and discovery-protocols.inc.php to detect when a device already exists
change in ip_exists() to make it more readable
This commit is contained in:
Tony Murray
2016-08-01 22:01:01 -05:00
parent ddf20a2f79
commit 66bed276c2
8 changed files with 177 additions and 255 deletions

View File

@ -290,13 +290,13 @@ function add_device() {
}
if (empty($message)) {
$result = addHost($hostname, $snmpver, $port, $transport, 1, $poller_group, $force_add);
if ($result) {
if (is_numeric($result)) {
$code = 201;
$status = 'ok';
$message = "Device $hostname has been added successfully";
}
else {
$message = "Failed adding $hostname";
$message = $result;
}
}