Module: check_mk
Branch: master
Commit: 77fea825818c5aaf02a9a9c82d64eddf04254712
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=77fea825818c5a…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Fri May 3 08:23:47 2019 +0200
agent_azure: make sure we always get the same timespans
Change-Id: I0829ffc93c1613f2e0650dfbf1c3f4d3ca7bdd98
---
agents/special/agent_azure | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/agents/special/agent_azure b/agents/special/agent_azure
index 77751d9..b7e9325 100755
--- a/agents/special/agent_azure
+++ b/agents/special/agent_azure
@@ -518,20 +518,19 @@ class AzureClient(object): # pylint:
disable=too-many-instance-attributes
self._cache = {}
@staticmethod
- def _get_timespans():
+ def _get_timespans(time_end=datetime.datetime.utcnow()):
"""compute timespans dict"""
- t_end = datetime.datetime.utcnow()
def interval(**kwargs):
- start = t_end - datetime.timedelta(**kwargs)
+ start = time_end - datetime.timedelta(**kwargs)
return "%s/%s" % (start.strftime("%Y-%m-%dT%H:%M:%SZ"),
- t_end.strftime("%Y-%m-%dT%H:%M:%SZ"))
+ time_end.strftime("%Y-%m-%dT%H:%M:%SZ"))
- timespans = {}
- timespans["PT1M"] = interval(minutes=3)
- timespans["PT5M"] = interval(minutes=15)
- timespans["PT1H"] = interval(hours=3)
- return timespans
+ return {
+ "PT1M": interval(minutes=3),
+ "PT5M": interval(minutes=15),
+ "PT1H": interval(hours=3),
+ }
def init_specific(self, resources):
r_types = set(r.info["type"] for r in resources)