Details
-
Improvement
-
Resolution: Fixed
-
Major
-
None
-
Professional Edition
-
None
-
None
Description
Syslog lines are not matched to devices by ip address. I dont know since when.
But the problem is, that you are using
$rows = mysqli_fetch_all($result, MYSQLI_ASSOC);
|
in the
function dbFetchRows($sql, $parameters = array(), $print_query = FALSE)
|
in mysqli.inc.php.
PHP Documentation says:
syslog.inc.php says:
$query = 'SELECT * FROM `ipv'.$ip_version.'_addresses` LEFT JOIN `ports` USING (`port_id`) WHERE `ipv'.$ip_version.'_address` = ? AND (`deleted` = ? OR `deleted` IS NULL);'; |
The problem: After joining the two tables, there are 2 device_id fields - so i think PHP is using the last field (from table ports) where device_id is NULL. So even if the first device_id field contains a value, PHP sets the value to NULL.
So we need to adjust the query to:
$query = 'SELECT `ipv'.$ip_version.'_addresses`.device_id, ports.ifAdminStatus, ports.ifOperStatus FROM `ipv'.$ip_version.'_addresses` LEFT JOIN `ports` USING (`port_id`) WHERE `ipv'.$ip_version.'_address` = ? AND (`deleted` = ? OR `deleted` IS NULL);'; |
Example:
MariaDB [observium]> SELECT ipv4_addresses.device_id FROM `ipv4_addresses` LEFT JOIN `ports` USING (`port_id`) WHERE `ipv4_address` = '10.49.50.20' AND (`deleted` = '0' OR `deleted` IS NULL);
-----------
device_id |
-----------
666 |
-----------
1 row in set (0.00 sec)
MariaDB [observium]> SELECT device_id FROM `ipv4_addresses` LEFT JOIN `ports` USING (`port_id`) WHERE `ipv4_address` = '10.49.50.20' AND (`deleted` = '0' OR `deleted` IS NULL);
ERROR 1052 (23000): Column 'device_id' in field list is ambiguous
After this change the syslog entries are stored for the correct device!
Patch is attached...
I hope you understand the problem..
Attachments
Activity
Status | Original: Resolved [ 5 ] | New: Closed [ 6 ] |
Resolution | New: Fixed [ 1 ] | |
Status | Original: In Progress [ 3 ] | New: Resolved [ 5 ] |
Status | Original: In Review [ 10101 ] | New: In Progress [ 3 ] |
Assignee | Original: Adam Armstrong [ adama ] | New: Mike Stupalov [ landy ] |
Attachment | Original: syslog.patch [ 17647 ] |
Comment |
[ Please make and attach additional information about the device: * full snmp dump from device: {noformat} snmpwalk -v2c -c <community> --hexOutputLength=0 -ObentxU <hostname> .1 > myagent.snmpwalk snmpwalk -v2c -c <community> --hexOutputLength=0 -ObentxU <hostname> .1.3.6.1.4.1 >> myagent.snmpwalk {noformat} _If device not support SNMP version 2c, replace -v2c with -v1._ * If you have problems with discovery or poller processes, please do and attach these debugs: {noformat} ./discovery.php -d -h <device> ./poller.php -d -h <device> {noformat} * additionally attach device and/or vendor specific MIB files {color:#505F79}_Note, this comment is added automatically._{color} ] |
Status | Original: Pending Response [ 10000 ] | New: In Review [ 10101 ] |
Status | Original: Open [ 1 ] | New: Pending Response [ 10000 ] |
Query correctly fixed in r10600.
Thanks.