0.2.10: add username/password support for influxdb, fix (again) pvoutput upload

This commit is contained in:
bohdan-s
2022-01-20 09:27:03 +11:00
parent 330e780cf2
commit 95a9dd9793
4 changed files with 23 additions and 8 deletions
+3 -1
View File
@@ -33,8 +33,10 @@ exports:
# Output data to InfluxDB
- name: influxdb
enabled: False # [Optional] Default is False
token: "xxx" # [Required] API Token
url: "http://localhost:8086" # [Optional] Default URL is http://localhost:8086
token: "xxx" # [Required] API Token OR Username / Password
# username: # [Optional] Username if not using token
# password: # [Optional] Password if not using token
org: "Default" # [Required] InfluxDB Organization
bucket: "SunGather" # [Required] InfluxDB Bucket
measurements: # [Required] Registers to publish to bucket
+13 -5
View File
@@ -17,11 +17,19 @@ class export_influxdb(object):
logging.warning(f"InfluxDB: Please check configuration")
return False
try:
self.client = influxdb_client.InfluxDBClient(
url=config.get('url', 'http://localhost:8086'),
token=config.get('token'),
org=config.get('org')
)
if config.get('token', False):
self.client = influxdb_client.InfluxDBClient(
url=config.get('url', 'http://localhost:8086'),
token=config.get('token'),
org=config.get('org')
)
elif config.get('username',False) and config.get('password',False):
self.client = influxdb_client.InfluxDBClient(
url=config.get('url', 'http://localhost:8086'),
token=f"{config.get('username')}:{config.get('password')}",
org=config.get('org')
)
except Exception as err:
logging.error(f"InfluxDB: Error: {err}")
return False
+6 -1
View File
@@ -410,7 +410,12 @@ def main():
sys.exit(0)
# Sleep until the next scan
time.sleep(scan_interval - process_time)
if scan_interval - process_time <= 1:
logging.warning(f"SunGather is taking {process_time} to process, which is longer than interval {scan_interval}, Please increase scan interval")
time.sleep(process_time)
else:
logging.info(f'Next scrape in {int(scan_interval - process_time)} secs')
time.sleep(scan_interval - process_time)
if __name__== "__main__":
main()
+1 -1
View File
@@ -1 +1 @@
__version__ = '0.2.8'
__version__ = '0.2.10'