change in influxdb address requirements

This commit is contained in:
avollkopf 2023-03-13 07:14:26 +01:00
parent f71481f782
commit 7aecdac6a7
3 changed files with 11 additions and 11 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.1.6" __version__ = "4.1.7.a1"
__codename__ = "Groundhog Day" __codename__ = "Groundhog Day"

View file

@ -49,7 +49,7 @@ class LogController:
if self.influxdb == "Yes": if self.influxdb == "Yes":
self.influxdbcloud = self.cbpi.config.get("INFLUXDBCLOUD", "No") self.influxdbcloud = self.cbpi.config.get("INFLUXDBCLOUD", "No")
self.influxdbaddr = self.cbpi.config.get("INFLUXDBADDR", None) self.influxdbaddr = self.cbpi.config.get("INFLUXDBADDR", None)
self.influxdbport = self.cbpi.config.get("INFLUXDBPORT", None) #self.influxdbport = self.cbpi.config.get("INFLUXDBPORT", None)
self.influxdbname = self.cbpi.config.get("INFLUXDBNAME", None) self.influxdbname = self.cbpi.config.get("INFLUXDBNAME", None)
self.influxdbuser = self.cbpi.config.get("INFLUXDBUSER", None) self.influxdbuser = self.cbpi.config.get("INFLUXDBUSER", None)
self.influxdbpwd = self.cbpi.config.get("INFLUXDBPWD", None) self.influxdbpwd = self.cbpi.config.get("INFLUXDBPWD", None)
@ -68,7 +68,7 @@ class LogController:
logging.error("InfluxDB ID Error: {}".format(e)) logging.error("InfluxDB ID Error: {}".format(e))
if self.influxdbcloud == "Yes": if self.influxdbcloud == "Yes":
self.influxdburl="https://" + self.influxdbaddr + "/api/v2/write?org=" + self.influxdbuser + "&bucket=" + self.influxdbname + "&precision=s" self.influxdburl=self.influxdbaddr + "/api/v2/write?org=" + self.influxdbuser + "&bucket=" + self.influxdbname + "&precision=s"
try: try:
header = {'User-Agent': name, 'Authorization': "Token {}".format(self.influxdbpwd)} header = {'User-Agent': name, 'Authorization': "Token {}".format(self.influxdbpwd)}
http = urllib3.PoolManager() http = urllib3.PoolManager()
@ -78,7 +78,7 @@ class LogController:
else: else:
self.base64string = base64.b64encode(('%s:%s' % (self.influxdbuser,self.influxdbpwd)).encode()) self.base64string = base64.b64encode(('%s:%s' % (self.influxdbuser,self.influxdbpwd)).encode())
self.influxdburl='http://' + self.influxdbaddr + ':' + str(self.influxdbport) + '/write?db=' + self.influxdbname self.influxdburl= self.influxdbaddr + '/write?db=' + self.influxdbname
try: try:
header = {'User-Agent': name, 'Content-Type': 'application/x-www-form-urlencoded','Authorization': 'Basic %s' % self.base64string.decode('utf-8')} header = {'User-Agent': name, 'Content-Type': 'application/x-www-form-urlencoded','Authorization': 'Basic %s' % self.base64string.decode('utf-8')}
http = urllib3.PoolManager() http = urllib3.PoolManager()

View file

@ -40,7 +40,7 @@ class ConfigUpdate(CBPiExtension):
logfiles = self.cbpi.config.get("CSVLOGFILES", None) logfiles = self.cbpi.config.get("CSVLOGFILES", None)
influxdb = self.cbpi.config.get("INFLUXDB", None) influxdb = self.cbpi.config.get("INFLUXDB", None)
influxdbaddr = self.cbpi.config.get("INFLUXDBADDR", None) influxdbaddr = self.cbpi.config.get("INFLUXDBADDR", None)
influxdbport = self.cbpi.config.get("INFLUXDBPORT", None) #influxdbport = self.cbpi.config.get("INFLUXDBPORT", None)
influxdbname = self.cbpi.config.get("INFLUXDBNAME", None) influxdbname = self.cbpi.config.get("INFLUXDBNAME", None)
influxdbuser = self.cbpi.config.get("INFLUXDBUSER", None) influxdbuser = self.cbpi.config.get("INFLUXDBUSER", None)
influxdbpwd = self.cbpi.config.get("INFLUXDBPWD", None) influxdbpwd = self.cbpi.config.get("INFLUXDBPWD", None)
@ -229,12 +229,12 @@ class ConfigUpdate(CBPiExtension):
logger.warning('Unable to update config') logger.warning('Unable to update config')
## Check if influxdbport is in config ## Check if influxdbport is in config
if influxdbport is None: #if influxdbport is None:
logger.info("INIT Influxdbport") # logger.info("INIT Influxdbport")
try: # try:
await self.cbpi.config.add("INFLUXDBPORT", "8086", ConfigType.STRING, "Port of your influxdb server") # await self.cbpi.config.add("INFLUXDBPORT", "8086", ConfigType.STRING, "Port of your influxdb server")
except: # except:
logger.warning('Unable to update config') # logger.warning('Unable to update config')
## Check if influxdbname is in config ## Check if influxdbname is in config
if influxdbname is None: if influxdbname is None: