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

fix: snmp_get_multi returns no data if the oid doesn't contain a period #7456

Merged
merged 1 commit into from Oct 11, 2017

Conversation

Projects
None yet
4 participants
@murrant
Member

murrant commented Oct 10, 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

@murrant

This comment has been minimized.

Show comment
Hide comment
@murrant

murrant Oct 10, 2017

Member

The other fix is to simply add:

if (is_null($index)) {
    $index = 0;
}
Member

murrant commented Oct 10, 2017

The other fix is to simply add:

if (is_null($index)) {
    $index = 0;
}
@scrutinizer-notifier

This comment has been minimized.

Show comment
Hide comment
@scrutinizer-notifier

scrutinizer-notifier Oct 10, 2017

The inspection completed: No new issues

scrutinizer-notifier commented Oct 10, 2017

The inspection completed: No new issues

@erotel

This comment has been minimized.

Show comment
Hide comment
@erotel

erotel Oct 10, 2017

Contributor

HI im test and for me work this code:

if (!str_contains($value, 'at this OID')) { 
           if (is_null($index)) {
                $index = 0;
                if (empty($oid)) {
                    continue; // no index or oid
                }
            }
       $array[$index][$oid] = $value;
}
Contributor

erotel commented Oct 10, 2017

HI im test and for me work this code:

if (!str_contains($value, 'at this OID')) { 
           if (is_null($index)) {
                $index = 0;
                if (empty($oid)) {
                    continue; // no index or oid
                }
            }
       $array[$index][$oid] = $value;
}
@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Oct 10, 2017

Member

How does this help when a device is asked for sysUptime.0 and replies with sysUptime = X as in the code we will expect .0 to be there or am I misunderstanding why this patch is proposed?

Member

laf commented Oct 10, 2017

How does this help when a device is asked for sysUptime.0 and replies with sysUptime = X as in the code we will expect .0 to be there or am I misunderstanding why this patch is proposed?

@murrant

This comment has been minimized.

Show comment
Hide comment
@murrant

murrant Oct 10, 2017

Member

It doesn't work around the device bugs, just makes it possible to.

So, to work around the device bug, something like this is also needed:

if (isset($snmpdata[0])) {
    $poll_device = $snmpdata[0];
} else {
    $poll_device = $snmpdata;
}

The other way to fix the issue, makes the above change unnecessary, but would cause confusion if someone requests an oid not containing a dot and it is magically put under the 0 index.

Member

murrant commented Oct 10, 2017

It doesn't work around the device bugs, just makes it possible to.

So, to work around the device bug, something like this is also needed:

if (isset($snmpdata[0])) {
    $poll_device = $snmpdata[0];
} else {
    $poll_device = $snmpdata;
}

The other way to fix the issue, makes the above change unnecessary, but would cause confusion if someone requests an oid not containing a dot and it is magically put under the 0 index.

@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Oct 10, 2017

Member

But doesn't this still then need custom code in the poller / core module to make use of the returned data that doesn't have the array index of 0?

Member

laf commented Oct 10, 2017

But doesn't this still then need custom code in the poller / core module to make use of the returned data that doesn't have the array index of 0?

@erotel

This comment has been minimized.

Show comment
Hide comment
@erotel

erotel Oct 10, 2017

Contributor

I do not think anything changes. Me code only adds to oid index 0, if oid no index. If the oid index has, nothing changes.
The correct thing would be for the manufacturer to fix the firmware. Unfortunately, it is unlikely to repair the firmware on a device they no longer produce (ray version 1).

Contributor

erotel commented Oct 10, 2017

I do not think anything changes. Me code only adds to oid index 0, if oid no index. If the oid index has, nothing changes.
The correct thing would be for the manufacturer to fix the firmware. Unfortunately, it is unlikely to repair the firmware on a device they no longer produce (ray version 1).

@murrant

This comment has been minimized.

Show comment
Hide comment
@murrant

murrant Oct 11, 2017

Member

@laf This does NOT fix the issue @erotel is having with his device. I just fixed a bug that he uncovered.

Member

murrant commented Oct 11, 2017

@laf This does NOT fix the issue @erotel is having with his device. I just fixed a bug that he uncovered.

@laf laf merged commit 46ee1b3 into librenms:master Oct 11, 2017

2 checks passed

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

@murrant murrant deleted the murrant:snmpget-multi-fix branch Oct 12, 2017

@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.