Module: check_mk
Branch: master
Commit: 6776fc929310a8174e28f5ece5a32b5c40b578c1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6776fc929310a8…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Fri May 3 06:58:31 2019 +0200
agent_azure: refactor collection of metrics
Change-Id: I929dcbeba9b64da1c118a9992a93f06db471c122
---
agents/special/agent_azure | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/agents/special/agent_azure b/agents/special/agent_azure
index 0a1d2c9..77751d9 100755
--- a/agents/special/agent_azure
+++ b/agents/special/agent_azure
@@ -608,15 +608,14 @@ class AzureClient(object): # pylint:
disable=too-many-instance-attributes
return metrics
- def get_metrics(self, resource, err):
+ # TODO: adding the metrics as a side effect is not good.
+ # I'll get the caching right, then change this back. (mo)
+ def collect_metrics(self, resource, err):
metric_params = METRICS_SELECTED.get(resource.info["type"], [])
- metrics = []
for metricnames, interval, aggregation, filter_ in metric_params:
- metrics += self._fetch_specific_metrics(resource, metricnames, interval,
aggregation,
- filter_, err)
-
- return metrics
+ resource.metrics += self._fetch_specific_metrics(resource, metricnames,
interval,
+ aggregation, filter_, err)
def process_resource(args):
@@ -625,8 +624,7 @@ def process_resource(args):
client.process_specific(resource)
err = IssueCollecter() # pass this to methods to collect issues
- for metric in client.get_metrics(resource, err):
- resource.metrics.append(metric)
+ client.collect_metrics(resource, err)
agent_info_section = AzureSection('agent_info')
agent_info_section.add(('remaining-reads', client.remaining_reads))