From 8c4e5f7fe3cd89555b55a87ab11e06b54eef5133 Mon Sep 17 00:00:00 2001 From: Stephan Fudeus Date: Sun, 9 Jan 2022 20:04:07 +0100 Subject: [PATCH] Fix issues with namemapping and active authentication --- exporter.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/exporter.py b/exporter.py index 29ea227..31eb427 100755 --- a/exporter.py +++ b/exporter.py @@ -119,14 +119,14 @@ def run(self): if len(self.mapped_names) == 0: # if no custom mapped names are given we use them from the ccu. - reload_names_active = True + self.reload_names_active = True with read_names_summary.labels(self.ccu_host).time(): self.mapped_names = self.read_mapped_names() logging.info("Read {} device names from CCU".format(len(self.mapped_names))) while True: - if reload_names_active: + if self.reload_names_active: if gathering_loop_counter % self.reload_names_interval == 0: try: with read_names_summary.labels(self.ccu_host).time(): @@ -333,8 +333,11 @@ def read_mapped_names(self): } """ - response = requests.post(url, auth=auth, data=script_get_names) + response = requests.post(url, auth=self.auth, data=script_get_names) logging.debug(response.text) + if response.status_code != 200: + logging.warning("Failed to read name mappings, status code was %d", response.status_code) + return {} ccu_mapped_names = {}