Syslog name translation (#9463)

* Check to see if a host exists in a lookup table to translate received name to what LibreNMS knows

* Added some documentation on how this is configured

* Use \LibreNMS\Config instead of accessing $config directly

* Fix codeclimate finding: Additional blank lines after USE statement

* murrant suggested a much cleaner way of doing this!
This commit is contained in:
TylerSweet
2018-11-20 16:47:53 -06:00
committed by Tony Murray
parent 549f2fc50b
commit 8617f3e21d
2 changed files with 19 additions and 1 deletions

View File

@@ -3,7 +3,7 @@
// FIXME : use db functions properly
// $device_id_host = @dbFetchCell("SELECT device_id FROM devices WHERE `hostname` = '".mres($entry['host'])."' OR `sysName` = '".mres($entry['host'])."'");
// $device_id_ip = @dbFetchCell("SELECT device_id FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = '" . $entry['host']."' AND I.port_id = A.port_id");
use LibreNMS\Config;
function get_cache($host, $value)
{
@@ -57,6 +57,9 @@ function process_syslog($entry, $update)
}
$entry['host'] = preg_replace("/^::ffff:/", "", $entry['host']);
if ($new_host = Config::get('syslog_xlate.' . $entry['host'])) {
$entry['host'] = $new_host;
}
$entry['device_id'] = get_cache($entry['host'], 'device_id');
if ($entry['device_id']) {
$os = get_cache($entry['host'], 'os');