mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
safer createHost()
git-svn-id: http://www.observium.org/svn/observer/trunk@2280 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -365,15 +365,17 @@ function utime()
|
||||
function createHost($host, $community, $snmpver, $port = 161, $transport = 'udp')
|
||||
{
|
||||
$host = trim(strtolower($host));
|
||||
$device = deviceArray($host, $community, $snmpver, $port, $transport);
|
||||
$host_os = getHostOS($device);
|
||||
$device = array('hostname' => $host, 'sysName' => $host, 'community' => $community, 'port' => $port, 'transport' => $transport, 'status' => '1', 'snmpver' => $snmpver);
|
||||
$device['os'] = getHostOS($device);
|
||||
|
||||
if ($host_os)
|
||||
if ($device['os'])
|
||||
{
|
||||
$sql = mysql_query("INSERT INTO `devices` (`hostname`, `sysName`, `community`, `port`, `transport`, `os`, `status`,`snmpver`) VALUES ('$host', '$host', '$community', '$port', '$transport', '$host_os', '1','$snmpver')");
|
||||
if (mysql_affected_rows())
|
||||
|
||||
$id = dbInsert($device, 'devices');
|
||||
|
||||
if ($id)
|
||||
{
|
||||
return("Created host : $host (id:".mysql_insert_id().") (os:$host_os)");
|
||||
return("Created host : $host (id:".$id.") (os:".$device['os'].")");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user