MightySlaytanic / pve-monitoring

Proxmox VE temperature and disk-health stats upload to influxdb2
MIT License
74 stars 9 forks source link

[SUGGESTION] More robust HTTP & HTTPS compatibility #15

Closed boomam closed 9 months ago

boomam commented 9 months ago

Hi,
I recently migrated my InfluxDb setup from being direct port + DNS Name, to going through a reverse proxy on a shared port.
Updating the INFLUX_HOST variable in each *.sh file from being influx.domain.com to https://influx.domain.com yielded this error when running each script -

<urllib3.connection.HTTPConnection object at 0x7f3ae627a450>: Failed to resolve 'https' ([Errno -5] No address associated with hostname)
[2024-02-08 19:33:31] Connection Error: Could not upload data to https://influx.domain.com:8086 for host test-01

 
A little digging, and changing the INFLUX_HOST variable back to remove the protocol spec, then editing the following lines in each python script to be https instead of http, appears to have resolved the issue.
 

 
As a suggestion, adjusting said lines from being client = InfluxDBClient(url=f"http://{INFLUX_HOST}:{INFLUX_PORT}", token=INFLUX_TOKEN, org=INFLUX_ORGANIZATION, timeout=30000) to instead remove the http:// part, would give the flexibility to specify the protocol within the environment variable, instead of relying on python logic/code to resolve.
 
Just a suggestion. :-)

MightySlaytanic commented 9 months ago

Thanks for the update, I will update it also in my other small projects related to docker images with similar INFLUX_HOST variables.