mirror of
https://github.com/alexhopeoconnor/SunGather.git
synced 2026-10-23 19:12:11 +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
|
# 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
|
||||||
|
|||||||
@@ -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:
|
||||||
self.client = influxdb_client.InfluxDBClient(
|
if config.get('token', False):
|
||||||
url=config.get('url', 'http://localhost:8086'),
|
self.client = influxdb_client.InfluxDBClient(
|
||||||
token=config.get('token'),
|
url=config.get('url', 'http://localhost:8086'),
|
||||||
org=config.get('org')
|
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:
|
except Exception as err:
|
||||||
logging.error(f"InfluxDB: Error: {err}")
|
logging.error(f"InfluxDB: Error: {err}")
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -410,7 +410,12 @@ def main():
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
# Sleep until the next scan
|
# 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__":
|
if __name__== "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
__version__ = '0.2.8'
|
__version__ = '0.2.10'
|
||||||
Reference in New Issue
Block a user