mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added the lookup of IP if device hostname is a hostname
This commit is contained in:
@@ -1320,3 +1320,28 @@ function oxidized_reload_nodes() {
|
||||
curl_close($ch);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform DNS lookup
|
||||
*
|
||||
* @param array $device Device array from database
|
||||
* @param string $type The type of record to lookup
|
||||
*
|
||||
* @return string ip
|
||||
*
|
||||
**/
|
||||
function dnslookup($device,$type=false) {
|
||||
if (empty($type)) {
|
||||
// We are going to use the transport to work out the record type
|
||||
if ($device['transport'] == 'udp6' || $device['transport'] == 'tcp6') {
|
||||
$type = DNS_AAAA;
|
||||
$return = 'ipv6';
|
||||
}
|
||||
else {
|
||||
$type = DNS_A;
|
||||
$return = 'ip';
|
||||
}
|
||||
}
|
||||
$record = dns_get_record($device['hostname'],$type);
|
||||
return $record[0][$return];
|
||||
}//end dnslookup
|
||||
|
Reference in New Issue
Block a user