Commit fbcba5b3 authored by Łukasz Nowak's avatar Łukasz Nowak Committed by Łukasz Nowak

promise/plugin: Support ATS with traffic_ctl

/reviewed-on !53
parent cfdbaaf1
...@@ -19,10 +19,20 @@ class RunPromise(GenericPromise): ...@@ -19,10 +19,20 @@ class RunPromise(GenericPromise):
""" """
Check trafficserver cache availability Check trafficserver cache availability
""" """
traffic_line = self.getConfig('wrapper-path') wrapper = self.getConfig('wrapper-path')
if 'traffic_line' in wrapper:
args = [wrapper, '-r', 'proxy.node.cache.percent_free']
message = "Cache not available, availability: %s"
elif 'traffic_ctl' in wrapper:
args = [wrapper, 'metric', 'get', 'proxy.process.cache.percent_full']
message = "Cache not available, occupation: %s"
else:
self.logger.error("Wrapper %r not supported." % (wrapper,))
return
process = subprocess.Popen( process = subprocess.Popen(
[traffic_line, '-r', 'proxy.node.cache.percent_free'], args,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
) )
...@@ -30,7 +40,7 @@ class RunPromise(GenericPromise): ...@@ -30,7 +40,7 @@ class RunPromise(GenericPromise):
if process.returncode == 0: if process.returncode == 0:
self.logger.info("OK") self.logger.info("OK")
else: else:
self.logger.error("Cache not available, availability: %s" % result) self.logger.error(message % (result,))
def anomaly(self): def anomaly(self):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment