fixed a bug where stale link/device data would lead to broken map #1297

merged 3 commits into from Jun 18, 2015


None yet

4 participants

einhirn commented Jun 18, 2015

As discussed in IRC (cut down to just the interesting bits):

[15:12] f0o: einhirn: did you get around that map bug?
[15:22] einhirn: f0o: I analyzed the json data a bit and found a place where "label" is "null".
[15:22] einhirn: just have to find out why.
[15:29] einhirn: f0o: look here there's a "NULL" in the query results...

(since Pastebin's set to 1 Week expiry)

mysql> SELECT DISTINCT least(`devices`.`device_id`, `remote_device_id`) AS `remote_device_id`, devices.hostname, GREATEST(`remote_device_id`,`devices`.`device_id`) AS `local_device_id` FROM `links` LEFT JOIN `ports` ON `local_port_id`=`ports`.`port_id` LEFT JOIN `devices` ON `ports`.`device_id`=`devices`.`device_id`  AND `local_device_id` != 0 AND `remote_device_id` != 0;
| remote_device_id | hostname       | local_device_id |
|             NULL | NULL           |            NULL |
|               18 |blah |              56 |
|               16 | bleh   |              18 |
|               18 | blubb    |              19 |

(on with IRC log)

[15:36] f0o: einhirn: maybe add a NOT NULL or something
[15:36] f0o: would be nice if it's that trivial
[15:37] lafwood: einhirn: I wonder if you've got stale data in your links table
[15:38] einhirn: probably - why else would there be a "NULL"...
[15:38] einhirn: First I want to fix the map so this problem doesn't happen any more. Then I can maybe dive in the stored data *g*
[15:44] lafwood: einhirn: Maybe add AND local_port_id > 0 to the end of that query
[15:48] einhirn: Didn't help - there still is a device that has a "NULL" hostname.
[15:48] einhirn: That's the problem.
[15:48] einhirn: So I need to add the "IS NOT NULL" to the query for the hostname.
[15:57] einhirn: hmm...
[15:57] einhirn: How do I see if dbFetchRow returned nothing?
[15:58] einhirn: I'd just skip "empty" device ids when Building the node list.
@einhirn einhirn fixed a bug where stale link/device data would lead to broken map
@laf laf commented on an outdated diff Jun 18, 2015
@@ -51,7 +60,7 @@
if ($v['id'] == $link_devices['remote_device_id']) {
$to = $v['id'];
- $port .= ' > ' .shorten_interface_type($link_devices['remote_port']);
+ $port = ' > ' .shorten_interface_type($link_devices['remote_port']);
laf Jun 18, 2015 Member

This is overwriting a previously set value of $port. This is supposed to build up a string that says interface1 > interface2.

@einhirn einhirn minor correction about being undefined in some cases
@f0o f0o added the WebUI label Jun 18, 2015
@einhirn einhirn another minor correction about $port being undefined in some cases
@laf laf merged commit 876eefd into librenms:master Jun 18, 2015

1 of 2 checks passed

Scrutinizer Errored
Auto-Deploy Build finished.
@einhirn einhirn deleted the rztuc:issue-map-broken branch Jun 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment