psyinfra / prometheus-eaton-ups-exporter

A Prometheus exporter for (some) Eaton UPSs
ISC License
11 stars 5 forks source link

Exporter not working on UPS Firmware 2.0.5 #23

Open nhjjr opened 12 months ago

nhjjr commented 12 months ago

I stumbled upon this today, I have 3 of the same UPS's with all the same network card.

2x of my UPS's are on Network Card Firmware 1.7.5 with one of them on 2.0.5 somehow, this error appears on my UPS with the 2.0.5 Firmware, suggesting Eaton changed something somewhat recently with the way input measures are called upon. Unfortunately I'm not well versed enough to figure out what causes the issue, although it may be possible to upgrade your firmware to 2.0.5 and figure it out for yourself. There is also a 3.0 version firmware, seems they really did support this product decently!

For anyone reading this, do not upgrade your Firmware if you wish to keep using this amazing exporter, thanks for making it! (:

Originally posted by @Randommmm in https://github.com/psyinfra/prometheus-eaton-ups-exporter/issues/22#issuecomment-1716716925

nhjjr commented 12 months ago

If you can, please provide the console output (the error trace) of the exporter when used on UPS Firmware 2.0.5. Ideally, it would be good to have a dump of the new HTML as well.

There is no immediate need for us to upgrade our firmware, so it may take a while before we get to addressing this. If someone wants to help make this happen, I'm happy to review a PR.

adyekjaer commented 11 months ago

There seems to be some bigger changes to the JSON response between different firmware versions. I've made a version that works with firmware 3.1.8. I did not spend the effort to check for firmware version to differentiate the expected output from the rest api. It does however seem to be possible to ask for firmware version using /rest/mbdetnrs/1.0/managers/1/firmwares/

@nhjjr cheers for putting this on Github - thanks!

@Randommmm ping

Randommmm commented 11 months ago

Thanks for the pings, keen to help out with this.

Command Used: python3 prometheus_eaton_ups_exporter.py -c config_ups2.json -k --verbose -w 127.0.0.1:9955 Command Output:

2023-10-11 09:44:40,520 - prometheus_eaton_ups_exporter.scraper - DEBUG - Unauthorized, try to login
2023-10-11 09:44:41,721 - prometheus_eaton_ups_exporter.scraper - DEBUG - Authentication successful on (https://192.168.1.81)
2023-10-11 09:44:42,278 - prometheus_eaton_ups_exporter.scraper - DEBUG - GET https://192.168.1.81/rest/mbdetnrs/1.0/powerDistributions/1
2023-10-11 09:44:42,557 - prometheus_eaton_ups_exporter.scraper - DEBUG - GET https://192.168.1.81/rest/mbdetnrs/1.0/powerDistributions/1/inputs/1
2023-10-11 09:44:42,934 - prometheus_eaton_ups_exporter.scraper - DEBUG - GET https://192.168.1.81/rest/mbdetnrs/1.0/powerDistributions/1/outputs/1
2023-10-11 09:44:42,964 - prometheus_eaton_ups_exporter.scraper - DEBUG - GET https://192.168.1.81/rest/mbdetnrs/1.0/powerDistributions/1/backupSystem
2023-10-11 09:44:43,217 - prometheus_eaton_ups_exporter.scraper - DEBUG - GET https://192.168.1.81/rest/mbdetnrs/1.0/powerDistributions/1/backupSystem/powerBank
Traceback (most recent call last):
  File "/home/monitor/prometheus-eaton-ups-exporter/prometheus_eaton_ups_exporter.py", line 161, in <module>
    main()
  File "/home/monitor/prometheus-eaton-ups-exporter/prometheus_eaton_ups_exporter.py", line 157, in main
    run(sys.argv[1:])
  File "/home/monitor/prometheus-eaton-ups-exporter/prometheus_eaton_ups_exporter.py", line 129, in run
    REGISTRY.register(
  File "/usr/lib/python3/dist-packages/prometheus_client/registry.py", line 40, in register
    names = self._get_names(collector)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/prometheus_client/registry.py", line 80, in _get_names
    for metric in desc_func():
  File "/home/monitor/prometheus-eaton-ups-exporter/prometheus_eaton_ups_exporter/exporter.py", line 61, in collect
    inputs_rm = inputs['measures']['realtime']
                ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'realtime'

Contents of config_ups2.json, used in this text example to break things with my normal muli-ups config.json file

{
    "ups2_name": {
        "address": "https://192.168.1.81",
        "user": "admin",
        "password": "supersecurepassword"
    }
}

I haven't had any luck scraping the web interface, I have a bit of experience with web scraping and wget, although even with the cookies file, the login still fails due to an unknown authentication method. Might need some assistance with that one.

mathisloevenich commented 11 months ago

Sorry I am just reading this conversation now, originally I created this project but now I am busy with other stuff. If I remember correctly you can look into the network communication that is send once you login. There was one where all the json formatted data was communicated. It was really hard to figure that out, but I would have to look into the webpage again to tell you exactly how and where you can find this information.