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

Add battery operating time for APC UPS devices #14230

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mwobst
Copy link
Contributor

@mwobst mwobst commented Aug 24, 2022

PLEASE NOTE: This pull request leads to a failing test because the difference mentioned below is calculated by using the current date. Thus the difference in the file tests/data/apc_managementmoduleaosv6.8.8-appv6.8.8.json will always be wrong after at least one day has passed after the last commit. This somewhat seems to be a flaw within the test framework (or so I suppose).

Description:
With this feature, the date of last battery change is determined and used for building the difference to today. That difference is stored as minutes and displayed as years + minutes as »Battery Operating Time«. The limits are 4 years (warning/yellow) and 5 years (critical/red) – values from our own experience.

Time display in GUI (device main page):

apc_battery_operation_time

DO NOT DELETE THE UNDERLYING TEXT

Please note

Please read this information carefully. You can run ./lnms dev:check to check your code before submitting.

  • Have you followed our code guidelines?
  • If my Pull Request does some changes/fixes/enhancements in the WebUI, I have inserted a screenshot of it.
  • If my Pull Request makes discovery/polling/yaml changes, I have added/updated test data.

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.

@CLAassistant
Copy link

CLAassistant commented Aug 24, 2022

CLA assistant check
All committers have signed the CLA.

It fetches the date of the last battery replacement, builds
the difference with current date and stores that difference
as seconds. The limits are 4 years (low/yellow) and 5 years (high/red).
@mwobst mwobst force-pushed the tud-zih/22.8-apc_battery_operation_time branch from 6217118 to 686591f Compare August 24, 2022 09:22
@mwobst
Copy link
Contributor Author

mwobst commented Aug 24, 2022

As expected, the tests will fail. Is there any recommendation how to proceed. I could revert to a draft requested but I don’t think this would really help …

For people not involved: There was a similar pull request that also had been approved and merged, but lead to this failing tests and was thus reverted. The feature though is not only required by us, it also raised interest by other users.

@Jellyfrog
Copy link
Member

  1. Could you implement this in yaml instead? You need to add a custom function to do the conversion (called user_func in yaml)
    You can add a function to LibreNMS\Util\Time.php, and call it like user_func: \LibreNMS\Util\Time:name-it-something-generic-and-good

  2. You have to manually fix the failing json file (check the test output for what to change)

@mwobst
Copy link
Contributor Author

mwobst commented Aug 25, 2022

  1. Could you implement this in yaml instead? You need to add a custom function to do the conversion (called user_func in yaml)
    You can add a function to LibreNMS\Util\Time.php, and call it like user_func: \LibreNMS\Util\Time:name-it-something-generic-and-good

I am not exactly deep into the topic, so I have to ask some questions: Which file do you mean with "instead" … and is there any other example which I can use for orientation?

  1. You have to manually fix the failing json file (check the test output for what to change)

Test output? When and where do I see it?
(Please bear with me as I am working on several other (and different) things at work …)

@murrant
Copy link
Member

murrant commented Sep 6, 2022

  1. includes/definitions/discovery/apc.yaml
  2. at the bottom by the X's go to the right and click details (wait a second for it to scroll)

@Jellyfrog Jellyfrog added the Device 🖥️ New or added device support label Oct 11, 2022
@PipoCanaja PipoCanaja closed this Jan 9, 2024
@PipoCanaja PipoCanaja reopened this Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Device 🖥️ New or added device support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants