mirror of
https://github.com/alexhopeoconnor/SunGather.git
synced 2026-10-22 02:32:09 +10:00
0.2.10: add username/password support for influxdb, fix (again) pvoutput upload
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 @@
|
||||
__version__ = '0.2.8'
|
||||
__version__ = '0.2.10'
|
||||
Reference in New Issue
Block a user