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