Commit 0fb681e6 by Szabolcs Gelencser

Handle empty storage table infos result. Get time from local time

for vm metrics. Log sent metrics.
parent f1cf131d
......@@ -62,7 +62,7 @@ class AzureVmPerformanceCounters(object):
headers = {"Authorization": 'Bearer ' + self.accessToken}
json_output = requests.get(list_metrics_url, headers=headers).json()
if json_output.has_key("value"):
if json_output.has_key("value") and len(json_output["value"]) > 0:
return json_output["value"]
else:
return None
......
......@@ -196,9 +196,7 @@ class Client:
'vm.%(name)s.memory.usage %(value)f %(time)d' % {
'name': vm.name,
'value': vm_counters["memory_usage"]["value"],
'time': self.datetime_to_time(
vm_counters["memory_usage"]["timestamp"],
),
'time': time.time(),
}
)
......@@ -207,9 +205,7 @@ class Client:
'vm.%(name)s.cpu.percent %(value)f %(time)d' % {
'name': vm.name,
'value': vm_counters["processor_usage"]["value"],
'time': self.datetime_to_time(
vm_counters["processor_usage"]["timestamp"],
),
'time': time.time(),
}
)
......@@ -223,9 +219,7 @@ class Client:
'name': vm.name,
'interface': "eth0",
'metric': pc_name,
'time': self.datetime_to_time(
vm_counters[pc_name]["timestamp"],
),
'time': time.time(),
'data': vm_counters[pc_name]["value"],
}
)
......@@ -238,6 +232,9 @@ class Client:
}
)
logger.info("current metrics:")
logger.info(metrics)
return metrics
@staticmethod
......
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 sign in to comment