New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add if statement for ROS os when querying remote port id for LLDP map #7079

Merged
merged 2 commits into from Jul 29, 2017

Conversation

Projects
None yet
3 participants
@EnzoZafra
Contributor

EnzoZafra commented Jul 25, 2017

DO NOT DELETE THIS TEXT

Please note

Please read this information carefully. You can run ./scripts/pre-commit.php to check your code before submitting.

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926

Siemens Ruggedcom switches does not have the functionality to give ports/interfaces descriptions. When you do an snmpwalk on oid `ifDescr' for each port, it is empty and therefore inserts a whitespace into the 'ifDescr' field in the ports table.

When you do an snmpwalk on oid 'lldpRemoteSystemsData', you get the following: https://pastebin.com/LbechkBG

The discovery-protocols module will then query the database for a remote_port_id using this ifDescr which will always return the first port (port 1) because all of the ifDescr for each port on that device is a whitespace. I created an if statement that will search the ifName only instead of ifDescr OR ifName.

Instead of an if-statement, another solution I suggest is re-arranging the query from this:

$remote_port_id = dbFetchCell('SELECT \port_id` FROM `ports` WHERE (`ifDescr` = ? OR `ifName` = ? OR `ifDescr` = ? OR `ifName` = ? OR `ifPhysAddress` = ?) AND `device_id` = ?', array($if, $if, $id, $id, $remote_port_mac_address, $remote_device_id));`

to this:

$remote_port_id = dbFetchCell('SELECT \port_id` FROM `ports` WHERE (`ifName` = ? OR `ifDescr` = ? OR `ifDescr` = ? OR `ifName` = ? OR `ifPhysAddress` = ?) AND `device_id` = ?', array($id, $id, $if, $if, $remote_port_mac_address, $remote_device_id));`

but I'm not sure how this will break the map for other OS'.

We can also store the ifName as the ifDescr in the ports module if the ifDescr oid is empty. That way, it will fix any other issues caused by ifDescr being empty. Let me know what is preferred

@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Jul 25, 2017

Member

But they return ifName and / or ifAlias? I reckon it might be better to fix this in ports polling.

I don't think changing the order is the right thing to do, ifDescr is/should be a standard value returned so this is an edge case rather than the norm

Member

laf commented Jul 25, 2017

But they return ifName and / or ifAlias? I reckon it might be better to fix this in ports polling.

I don't think changing the order is the right thing to do, ifDescr is/should be a standard value returned so this is an edge case rather than the norm

@EnzoZafra

This comment has been minimized.

Show comment
Hide comment
@EnzoZafra

EnzoZafra Jul 25, 2017

Contributor

Yup, there is an ifName and/or an ifAlias per port. My idea is to set the ifDescr as the ifName if it's empty. Should I do this only for the 'ROS' OS or just do it for all?

Contributor

EnzoZafra commented Jul 25, 2017

Yup, there is an ifName and/or an ifAlias per port. My idea is to set the ifDescr as the ifName if it's empty. Should I do this only for the 'ROS' OS or just do it for all?

@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Jul 25, 2017

Member

I would do it for all. We do the same for ifAlias / ifName already.

Member

laf commented Jul 25, 2017

I would do it for all. We do the same for ifAlias / ifName already.

@EnzoZafra EnzoZafra closed this Jul 25, 2017

@EnzoZafra EnzoZafra reopened this Jul 27, 2017

@scrutinizer-notifier

This comment has been minimized.

Show comment
Hide comment
@scrutinizer-notifier

scrutinizer-notifier Jul 27, 2017

The inspection completed: No new issues

scrutinizer-notifier commented Jul 27, 2017

The inspection completed: No new issues

@laf laf merged commit f66d73d into librenms:master Jul 29, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla Contributor License Agreement is signed.
Details
@lock

This comment has been minimized.

Show comment
Hide comment
@lock

lock bot May 17, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed.

lock bot commented May 17, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed.

@lock lock bot locked as resolved and limited conversation to collaborators May 17, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.