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 # Output data to InfluxDB
- name: influxdb - name: influxdb
enabled: False # [Optional] Default is False enabled: False # [Optional] Default is False
token: "xxx" # [Required] API Token
url: "http://localhost:8086" # [Optional] Default URL is http://localhost:8086 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 org: "Default" # [Required] InfluxDB Organization
bucket: "SunGather" # [Required] InfluxDB Bucket bucket: "SunGather" # [Required] InfluxDB Bucket
measurements: # [Required] Registers to publish to bucket measurements: # [Required] Registers to publish to bucket
+8
View File
@@ -17,11 +17,19 @@ class export_influxdb(object):
logging.warning(f"InfluxDB: Please check configuration") logging.warning(f"InfluxDB: Please check configuration")
return False return False
try: try:
if config.get('token', False):
self.client = influxdb_client.InfluxDBClient( self.client = influxdb_client.InfluxDBClient(
url=config.get('url', 'http://localhost:8086'), url=config.get('url', 'http://localhost:8086'),
token=config.get('token'), token=config.get('token'),
org=config.get('org') 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: except Exception as err:
logging.error(f"InfluxDB: Error: {err}") logging.error(f"InfluxDB: Error: {err}")
return False return False
+5
View File
@@ -410,6 +410,11 @@ def main():
sys.exit(0) sys.exit(0)
# Sleep until the next scan # Sleep until the next scan
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) time.sleep(scan_interval - process_time)
if __name__== "__main__": if __name__== "__main__":
+1 -1
View File
@@ -1 +1 @@
__version__ = '0.2.8' __version__ = '0.2.10'