Skip to content

Commit

Permalink
Refs pryorda#1. Get metrics from host only if up
Browse files Browse the repository at this point in the history
  • Loading branch information
rverchere committed May 31, 2017
1 parent c6719f4 commit eb01ea3
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions vmware_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,9 @@ def _vmware_get_vms(self, content, vm_metrics):
summary = vm.summary
power_state = 1 if summary.runtime.powerState == 'poweredOn' else 0
vm_metrics[0].add_metric([vm.name], power_state)
if summary.runtime.bootTime:
vm_metrics[1].add_metric([vm.name],
if power_state:
if summary.runtime.bootTime:
vm_metrics[1].add_metric([vm.name],
self._to_unix_timestamp(summary.runtime.bootTime))


Expand All @@ -279,23 +280,23 @@ def _vmware_get_hosts(self, content, host_metrics):
power_state = 1 if summary.runtime.powerState == 'poweredOn' else 0
host_metrics[0].add_metric([host.name], power_state)

# Uptime
if summary.runtime.bootTime:
host_metrics[1].add_metric([host.name],
if power_state:
# Uptime
if summary.runtime.bootTime:
host_metrics[1].add_metric([host.name],
self._to_unix_timestamp(summary.runtime.bootTime))


# CPU Usage (in Mhz)
host_metrics[2].add_metric([host.name],
# CPU Usage (in Mhz)
host_metrics[2].add_metric([host.name],
summary.quickStats.overallCpuUsage)
cpu_core_num = summary.hardware.numCpuCores
cpu_total = summary.hardware.cpuMhz * cpu_core_num
host_metrics[3].add_metric([host.name], cpu_total)
cpu_core_num = summary.hardware.numCpuCores
cpu_total = summary.hardware.cpuMhz * cpu_core_num
host_metrics[3].add_metric([host.name], cpu_total)

# Memory Usage (in Mhz)
host_metrics[4].add_metric([host.name],
# Memory Usage (in Mhz)
host_metrics[4].add_metric([host.name],
summary.quickStats.overallMemoryUsage)
host_metrics[5].add_metric([host.name],
host_metrics[5].add_metric([host.name],
float(summary.hardware.memorySize) / 1024 / 1024)


Expand Down

0 comments on commit eb01ea3

Please sign in to comment.