Skip to content

Commit 591be61

Browse files
Additional checks for variables (#85)
* fix: only try and get token if password set Signed-off-by: Ricky Moorhouse <[email protected]> * fix: additional graphite reference #72 Signed-off-by: Ricky Moorhouse <[email protected]> --------- Signed-off-by: Ricky Moorhouse <[email protected]>
1 parent 4635804 commit 591be61

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

manager_net.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,10 @@ def fish(self):
235235
logger.debug("Disabled because a fatal error already occurred")
236236
return
237237

238-
# Allow 10 seconds to run
239-
if self.cm_token_expires - 10 < time.time():
240-
self.get_token(self.hostname, cloud_manager=True)
238+
# Only attempt to get distinct token with cm credentials if password is set
239+
if self.cm_password != "":
240+
if self.cm_token_expires - 10 < time.time():
241+
self.get_token(self.hostname, cloud_manager=True)
241242

242243
# Allow 10 seconds to run
243244
if self.token_expires - 10 < time.time():

trawler.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,13 @@ def set_gauge(self, component, target_name, value, pod_name=None, labels=None):
123123
self.gauges[prometheus_target].set(value)
124124
except ValueError as value_exception:
125125
self.logger.exception(value_exception)
126-
if self.config['graphite']['enabled']:
127-
if pod_name:
128-
metric_name = "{}.{}.{}".format(component, pod_name, target_name)
129-
else:
130-
metric_name = "{}.{}".format(component, target_name)
131-
self.graphite.stage(metric_name, value)
126+
if 'graphite' in self.config:
127+
if self.config['graphite']['enabled']:
128+
if pod_name:
129+
metric_name = "{}.{}.{}".format(component, pod_name, target_name)
130+
else:
131+
metric_name = "{}.{}".format(component, target_name)
132+
self.graphite.stage(metric_name, value)
132133

133134
def inc_counter(self, component, target_name, value, pod_name=None, labels=None):
134135
""" Set or increase prometheus counter """

0 commit comments

Comments
 (0)