From fdce2d0a281d5871c0d17f2a4c0254fb07d1cf27 Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 9 Jul 2016 20:01:35 +0100 Subject: [PATCH] Added ability to lookup device from IP in syslog --- includes/syslog.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/syslog.php b/includes/syslog.php index 42f999dff9..ab4d1e2a12 100644 --- a/includes/syslog.php +++ b/includes/syslog.php @@ -12,7 +12,8 @@ function get_cache($host, $value) { switch ($value) { case 'device_id': // Try by hostname - $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM devices WHERE `hostname` = ? OR `sysName` = ?', array($host, $host)); + $ip = inet_pton($host); + $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM devices WHERE `hostname` = ? OR `sysName` = ? OR `ip` = ?', array($host, $host, $ip)); // If failed, try by IP if (!is_numeric($dev_cache[$host]['device_id'])) { $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM `ipv4_addresses` AS A, `ports` AS I WHERE A.ipv4_address = ? AND I.port_id = A.port_id', array($host));