ArthurMitchell42 / nutcase

A NUT and APCd UPS data conversion bridge and graphic UI to link to both Prometheus metrics and JSON format for HomePage/Uptime Kuma etc.
https://arthurmitchell42.github.io/nutcase/
GNU General Public License v3.0
28 stars 3 forks source link

502 Bad Gateway #61

Open Druidblack opened 3 months ago

Druidblack commented 3 months ago

An error appears when selecting the UPS "502 Bad Gateway"

2024-07-29 21:35:09,539 INFO configuration: Config file is /app/../config/nutcase.yml 2024-07-29 21:35:09,541 INFO configuration: Loaded YAML from /app/../config/nutcase.yml 2024-07-29 21:35:09,541 WARNING configuration: Config is missing WebHook name ok 2024-07-29 21:35:09,541 WARNING configuration: Config is missing WebHook name fail 2024-07-29 21:35:09,551 INFO configuration: Config file is /app/../config/nutcase.yml 2024-07-29 21:35:09,554 INFO configuration: Loaded YAML from /app/../config/nutcase.yml 2024-07-29 21:35:09,554 WARNING configuration: Config is missing WebHook name ok 2024-07-29 21:35:09,554 WARNING configuration: Config is missing WebHook name fail 2024-07-29 21:35:09,599 INFO db_utils: Tidying logs, deleted 0 2024-07-29 21:35:10,110 INFO __init__: NUTCase starting. Version 0.4.0.0, Logging: console INFO logfile INFO 2024-07-29 21:35:10,138 INFO db_utils: Tidying logs, deleted 0 2024-07-29 21:35:10,571 INFO __init__: NUTCase starting. Version 0.4.0.0, Logging: console INFO logfile INFO 2024-07-29 21:35:41,585 ERROR nut_server_handler: Unable to connect to NUT server: [Errno 111] Connection refused 2024-07-29 21:35:41,586 WARNING nut_server_handler: Scrape unsuccessful. 2024-07-29 21:35:43,611 ERROR nut_server_handler: Unable to connect to NUT server: timed out 2024-07-29 21:35:43,612 WARNING nut_server_handler: Scrape unsuccessful. 2024-07-29 21:35:44,824 ERROR apc_server_handler: Unable to connect to APC server: [Errno 113] No route to host 2024-07-29 21:35:44,825 WARNING apc_server_handler: Scrape APC log unsuccessful. 2024-07-29 21:35:46,680 ERROR apc_server_handler: Unable to connect to APC server: [Errno 113] No route to host 2024-07-29 21:35:46,681 WARNING apc_server_handler: Scrape APC log unsuccessful. 2024-07-29 21:35:59,501 ERROR nut_server_handler: Unable to connect to NUT server: [Errno 111] Connection refused 2024-07-29 21:35:59,501 WARNING nut_server_handler: Scrape unsuccessful. 2024-07-29 21:36:01,527 ERROR nut_server_handler: Unable to connect to NUT server: timed out 2024-07-29 21:36:01,528 WARNING nut_server_handler: Scrape unsuccessful. 2024-07-29 21:36:03,708 ERROR apc_server_handler: Unable to connect to APC server: [Errno 113] No route to host 2024-07-29 21:36:03,709 WARNING apc_server_handler: Scrape APC log unsuccessful. 2024-07-29 21:36:04,600 ERROR apc_server_handler: Unable to connect to APC server: [Errno 113] No route to host 2024-07-29 21:36:04,601 WARNING apc_server_handler: Scrape APC log unsuccessful. 2024-07-29 21:36:59,731 ERROR nut_server_handler: Unable to connect to NUT server: [Errno 111] Connection refused 2024-07-29 21:36:59,732 WARNING nut_server_handler: Scrape unsuccessful. 2024-07-29 21:37:01,791 ERROR nut_server_handler: Unable to connect to NUT server: timed out 2024-07-29 21:37:01,791 WARNING nut_server_handler: Scrape unsuccessful. 2024-07-29 21:37:02,936 ERROR apc_server_handler: Unable to connect to APC server: [Errno 113] No route to host 2024-07-29 21:37:02,937 WARNING apc_server_handler: Scrape APC log unsuccessful. 2024-07-29 21:37:04,856 ERROR apc_server_handler: Unable to connect to APC server: [Errno 113] No route to host 2024-07-29 21:37:04,857 WARNING apc_server_handler: Scrape APC log unsuccessful. 2024-07-29 21:41:35,899 ERROR nut_server_handler: Unable to connect to NUT server: [Errno 111] Connection refused 2024-07-29 21:41:35,900 WARNING nut_server_handler: Scrape unsuccessful. 2024-07-29 21:41:37,920 ERROR nut_server_handler: Unable to connect to NUT server: timed out 2024-07-29 21:41:37,921 WARNING nut_server_handler: Scrape unsuccessful. 2024-07-29 21:41:39,196 ERROR apc_server_handler: Unable to connect to APC server: [Errno 113] No route to host 2024-07-29 21:41:39,197 WARNING apc_server_handler: Scrape APC log unsuccessful. 2024-07-29 21:41:40,984 ERROR apc_server_handler: Unable to connect to APC server: [Errno 113] No route to host 2024-07-29 21:41:40,985 WARNING apc_server_handler: Scrape APC log unsuccessful. 2024-07-29 21:42:51,358 ERROR nut_server_handler: Unable to connect to NUT server: [Errno 111] Connection refused 2024-07-29 21:42:51,359 WARNING nut_server_handler: Scrape unsuccessful. 2024-07-29 21:42:53,391 ERROR nut_server_handler: Unable to connect to NUT server: timed out 2024-07-29 21:42:53,392 WARNING nut_server_handler: Scrape unsuccessful. 2024-07-29 21:42:55,612 ERROR apc_server_handler: Unable to connect to APC server: [Errno 113] No route to host 2024-07-29 21:42:55,613 WARNING apc_server_handler: Scrape APC log unsuccessful. 2024-07-29 21:42:56,476 ERROR apc_server_handler: Unable to connect to APC server: [Errno 113] No route to host 2024-07-29 21:42:56,477 WARNING apc_server_handler: Scrape APC log unsuccessful. 2024-07-29 21:43:28,263 ERROR nut_server_handler: Unable to connect to NUT server: [Errno 111] Connection refused 2024-07-29 21:43:28,263 WARNING nut_server_handler: Scrape unsuccessful. 2024-07-29 21:43:30,292 ERROR nut_server_handler: Unable to connect to NUT server: timed out 2024-07-29 21:43:30,293 WARNING nut_server_handler: Scrape unsuccessful. 2024-07-29 21:43:31,544 ERROR apc_server_handler: Unable to connect to APC server: [Errno 113] No route to host 2024-07-29 21:43:31,545 WARNING apc_server_handler: Scrape APC log unsuccessful. 2024-07-29 21:43:31,711 INFO configuration: Config file is /app/../config/nutcase.yml 2024-07-29 21:43:31,712 INFO configuration: Loaded YAML from /app/../config/nutcase.yml 2024-07-29 21:43:31,712 WARNING configuration: Config is missing WebHook name ok 2024-07-29 21:43:31,713 WARNING configuration: Config is missing WebHook name fail 2024-07-29 21:43:31,759 INFO db_utils: Tidying logs, deleted 0 2024-07-29 21:43:32,230 INFO __init__: NUTCase starting. Version 0.4.0.0, Logging: console INFO logfile INFO 2024-07-29 21:43:33,368 ERROR apc_server_handler: Unable to connect to APC server: [Errno 113] No route to host 2024-07-29 21:43:33,369 WARNING apc_server_handler: Scrape APC log unsuccessful. 2024-07-29 21:44:23,356 ERROR nut_server_handler: Unable to connect to NUT server: [Errno 111] Connection refused 2024-07-29 21:44:23,357 WARNING nut_server_handler: Scrape unsuccessful. 2024-07-29 21:44:25,384 ERROR nut_server_handler: Unable to connect to NUT server: timed out 2024-07-29 21:44:25,385 WARNING nut_server_handler: Scrape unsuccessful. 2024-07-29 21:44:26,652 ERROR apc_server_handler: Unable to connect to APC server: [Errno 113] No route to host 2024-07-29 21:44:26,653 WARNING apc_server_handler: Scrape APC log unsuccessful. 2024-07-29 21:44:28,440 ERROR apc_server_handler: Unable to connect to APC server: [Errno 113] No route to host 2024-07-29 21:44:28,441 WARNING apc_server_handler: Scrape APC log unsuccessful. 2024-07-29 21:44:45,825 ERROR nut_server_handler: Unable to connect to NUT server: [Errno 111] Connection refused 2024-07-29 21:44:45,825 WARNING nut_server_handler: Scrape unsuccessful. 2024-07-29 21:44:48,772 ERROR nut_server_handler: Unable to connect to NUT server: timed out 2024-07-29 21:44:48,773 WARNING nut_server_handler: Scrape unsuccessful. 2024-07-29 21:44:49,880 ERROR apc_server_handler: Unable to connect to APC server: [Errno 113] No route to host 2024-07-29 21:44:49,881 WARNING apc_server_handler: Scrape APC log unsuccessful. 2024-07-29 21:44:51,832 ERROR apc_server_handler: Unable to connect to APC server: [Errno 113] No route to host 2024-07-29 21:44:51,833 WARNING apc_server_handler: Scrape APC log unsuccessful. 2024-07-29 21:44:57,621 ERROR nut_server_handler: Unable to connect to NUT server: [Errno 111] Connection refused 2024-07-29 21:44:57,621 WARNING nut_server_handler: Scrape unsuccessful.

`servers:

Druidblack commented 3 months ago

Безымянный After a while, the web interface loaded itself, it shows the data, but there is no UPS selection.

ArthurMitchell42 commented 3 months ago

Hi, I need to see a debug log from the app start if you can send that please? Can you:

Thank you.

ArthurMitchell42 commented 3 months ago

It's very odd that the GUI shows data but then says no connection. Is it possible you have intermittent connection to the NUT server, or maybe even a conflicting IP address?

Druidblack commented 3 months ago

I don't think I'm interrupting work in NUT or duplicating IP. Just like this UPS is connected to me in the home assistant and in the homepages program. Безымянный I'll upload the data now

The red APC's are off now, but when you turn on the PC, they show the data. Powercom and Ippon are also turned off now.

Druidblack commented 3 months ago

502 Bad Gateway nutcase.log nutcase.yml.log

Internal Server Error nutcase.log nutcase.yml.log If I configure all UPS, then the program does not work at all and shows the Internal Server Error, as well as the integration into homepages stops working.

Druidblack commented 3 months ago

I renamed the configuration files to upload

ArthurMitchell42 commented 3 months ago

Let me have a look at that for you. I'm working away from home until Thursday and I don't have my laptop with me. I may need to sort this out at the weekend. In the mean time, were you previously using the V0.3.3_release or the latest_beta tag? You may have to go back to the V0.3.3_release until the weekend.

Druidblack commented 3 months ago

V0.3.3_release worked. In order not to redo the configuration file again, I will stay on version 4. Moreover, she is still able to transfer data to the homepages application so that I can see on my panel that my UPS is working.

ArthurMitchell42 commented 3 months ago

Ah ok, so it works to send JSON to Homepage but the GUI does not work? Or is it just the list of servers and devices that doesn't work please?

Druidblack commented 3 months ago

When configuring with one ups, choosing a ups, I get error 502, and if I specify all my UPS in the settings, I get an internal server error and the data no longer goes to the home pages.

Druidblack commented 3 months ago

good evening. is there any information on how to solve my problem?

ArthurMitchell42 commented 3 months ago

Morning, I'm looking at this now. Arthur

ArthurMitchell42 commented 3 months ago

To the first set of logs (the ones marked 502 bad gateway)

I've replicated you config file and tryed to put some bad data in like this:

settings:
  log_level: debugvv
  order_metrics: True
  coloured_log: True
  default_log_lines: 20
  cache_period: 29
servers:
  - server: "10.0.10.9"
    port: 3493
    # monitor: true
    devices:
      - device: ups
        default: true
        power: 550
        displayname: 'Downstairs CyberPower'
  - server: "10.0.10.19"
    port: 3493
    # monitor: true
    devices:
      - device: ups
        power: 550
        displayname: 'Fake address'
  - server: "10.0.10.9"
    port: 3499
    # monitor: true
    devices:
      - device: ups
        power: 550
        displayname: 'With a bad port'

But I can't get it to fail in the way you report. From the log data I see that the config in use has a number of servers in it but the example you posted only has one. Is it possible it picked up on another yaml file?

From the log I see:

Data_Handler requests for: 
192.168.1.165
    started
    success
192.168.1.195
    started
    nut_server_handler: Unable to connect to NUT server: 
        [Errno 111] Connection refused
192.168.1.183
    started
    success
192.168.1.161
    started
    success
192.168.1.1
    started
    success
192.168.1.94
    started
    time out
192.168.1.2
    started
    No route to host

Which implies 192.168.1.195 is alive but the NUT daemon is not running or the port is otherwise blocked/wrong/firewalled. Address 192.168.1.2 seams to have 'No route to host' which it a network issue. You might try pinging it from other devices or checking duplicates?

ArthurMitchell42 commented 3 months ago

Another thing to try is that the server list is set at the point that the pages in the web browser. If the configuration file is edited you will need to use ctrl-F5 on the web browser to load the page bypassing the browser cache.

ArthurMitchell42 commented 3 months ago

To the second issue, (Internal app error): This is a bug, I've fixed it and will update the container. It was triggered by an error in you YAML config file however. On line 27 you are missing one extra space at the beginning of the line, causing it not to load.

Druidblack commented 3 months ago

Thanks for the corrections. Everything is working now (almost everything).

  1. In the settings, I set the APC mode (PC Slip Irina , PC Irina), and the program for UPS shows the NUT mode. The UPS is currently turned off.

2 The program does not connect to the UPS ( IPPON Back Basic 650S Euro (mini pc)). The UPS is working on the home page and I connect to it through the server ( home assistant) and see data from it.

nutcase.log

nutcase.yml.txt Безымянный 333

ArthurMitchell42 commented 3 months ago

Good evening, it would be very helpful if you could configure a temporary setup to only use the IPPON Back Basic 650S and then set the log level to debugvv, then delete the log file and re-run the container. Once you have let it run for a coupe of minutes could you post the log file and your yaml file. This would be very helpful as I don't have an APC device to test with. Thank you.