Skip to content
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

Bug - Nasty user_func vs divisor-multiplier issue #10122

Merged
merged 2 commits into from Apr 18, 2019

Conversation

Projects
None yet
2 participants
@PipoCanaja
Copy link
Contributor

commented Apr 18, 2019

The user_func is applied before divisor/multiplier in discovery (wrong) and after divisor/multiplier in polling (right).

This issue is not very visible (because the data is correct after first poll anyway). But it impacts the auto-calculation of the sensor_limits (like shown in below exemple)

All tests with user_func adding any constant (like FtoCelsius) will fail and need to be re-calculated. Polling should not be impacted as it is already correct.

Error is visible in the cyberpower test file, for instance :

        "discovery": {
            "sensors": [
                {
                    "sensor_deleted": 0,
                    "sensor_class": "temperature",
                    "poller_type": "snmp",
                    "sensor_oid": ".1.3.6.1.4.1.3808.1.1.4.2.1.0",
                    "sensor_index": "envirTemperature.0",
                    "sensor_type": "cyberpower",
                    "sensor_descr": "Environment Sensor Temperature",
                    "sensor_divisor": 10,
                    "sensor_multiplier": 1,
                    "sensor_current": 36.167,
                    "sensor_limit": 56.167,
                    "sensor_limit_low": 26.167,
                    "sensor_prev": null,
                    "user_func": "fahrenheit_to_celsius",
(...)
                },
            ]
        },
        "poller": {
            "sensors": [
                {
                    "sensor_deleted": 0,
                    "sensor_class": "temperature",
                    "poller_type": "snmp",
                    "sensor_oid": ".1.3.6.1.4.1.3808.1.1.4.2.1.0",
                    "sensor_index": "envirTemperature.0",
                    "sensor_type": "cyberpower",
                    "sensor_descr": "Environment Sensor Temperature",
                    "sensor_divisor": 10,
                    "sensor_multiplier": 1,
                    "sensor_current": 20.17,
                    "sensor_limit": 56.167,
                    "sensor_limit_low": 26.167,
                    "sensor_prev": 36.167,
                    "user_func": "fahrenheit_to_celsius",
 (...)
                },
            ]
        },

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
After you are done testing, you can remove the changes with ./scripts/github-remove. If there are schema changes, you can ask on discord how to revert.

@murrant

This comment has been minimized.

Copy link
Member

commented Apr 18, 2019

Good find!

@PipoCanaja

This comment has been minimized.

Copy link
Contributor Author

commented Apr 18, 2019

running the unit tests now, to find who else is impacted, excepte cyberpower.

@PipoCanaja

This comment has been minimized.

Copy link
Contributor Author

commented Apr 18, 2019

Only cyberpower had sensors with both divisor/multiplier and fahrenheit_to_celsius. Tests should be OK now.

@murrant murrant merged commit a08b833 into librenms:master Apr 18, 2019

6 checks passed

Inspection Summary
Details
Node: analysis
Details
Travis CI - Pull Request Build Passed
Details
WIP Ready for review
Details
codeclimate All good!
Details
license/cla Contributor License Agreement is signed.
Details

@PipoCanaja PipoCanaja deleted the PipoCanaja:order_issue branch Apr 29, 2019

funzoneq added a commit to funzoneq/librenms that referenced this pull request Apr 30, 2019

Bug - Nasty user_func vs divisor-multiplier issue (librenms#10122)
* Nasty user_func vs divisor-multiplier issue

* tests

spencerbutler added a commit to spencerbutler/librenms that referenced this pull request May 21, 2019

Bug - Nasty user_func vs divisor-multiplier issue (librenms#10122)
* Nasty user_func vs divisor-multiplier issue

* tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.