diff --git a/SunGather/config-example.yaml b/SunGather/config-example.yaml index 42c01ed..7db3739 100644 --- a/SunGather/config-example.yaml +++ b/SunGather/config-example.yaml @@ -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 diff --git a/SunGather/exports/influxdb.py b/SunGather/exports/influxdb.py index a82caa0..0bc4276 100644 --- a/SunGather/exports/influxdb.py +++ b/SunGather/exports/influxdb.py @@ -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 diff --git a/SunGather/sungather.py b/SunGather/sungather.py index f5aefe5..c1cb628 100644 --- a/SunGather/sungather.py +++ b/SunGather/sungather.py @@ -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() diff --git a/SunGather/version.py b/SunGather/version.py index 93de59e..f0ca935 100644 --- a/SunGather/version.py +++ b/SunGather/version.py @@ -1 +1 @@ -__version__ = '0.2.8' \ No newline at end of file +__version__ = '0.2.10' \ No newline at end of file