mirror of
https://github.com/librenms/librenms.git
synced 2024-09-24 20:09:06 +00:00
Provide more useful diagnostics when adding a device via the API
This commit is contained in:
parent
4a8f54dafc
commit
a58c857ed2
@ -341,21 +341,25 @@ function add_device()
|
|||||||
{
|
{
|
||||||
$message = "You haven't specified an SNMP version to use";
|
$message = "You haven't specified an SNMP version to use";
|
||||||
}
|
}
|
||||||
|
$code = 200;
|
||||||
if(empty($message))
|
if(empty($message))
|
||||||
{
|
{
|
||||||
require_once("../includes/functions.php");
|
require_once("../includes/functions.php");
|
||||||
$result = addHost($hostname, $snmpver, $port, $transport, 1);
|
$result = addHost($hostname, $snmpver, $port, $transport, 1);
|
||||||
if($result)
|
if($result)
|
||||||
{
|
{
|
||||||
$status = 'ok';
|
$status = "ok";
|
||||||
$message = 'Device has been added successfully';
|
$message = "Device $hostname has been added successfully";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$code = 500;
|
||||||
|
$status = "error";
|
||||||
$message = "Failed adding $hostname";
|
$message = "Failed adding $hostname";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$app->response->setStatus($code);
|
||||||
$output = array("status" => $status, "message" => $message);
|
$output = array("status" => $status, "message" => $message);
|
||||||
$app->response->headers->set('Content-Type', 'application/json');
|
$app->response->headers->set('Content-Type', 'application/json');
|
||||||
echo _json_encode($output);
|
echo _json_encode($output);
|
||||||
|
Loading…
Reference in New Issue
Block a user