Skip to content

Commit

Permalink
[vsphere] Check metric type to report appropriately
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnLZeller committed Jan 7, 2016
1 parent 76459c8 commit de84b5d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion checks.d/vsphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from checks import AgentCheck
from checks.libs.thread_pool import Pool
from checks.libs.vmware.basic_metrics import BASIC_METRICS
from checks.libs.vmware.all_metrics import ALL_METRICS
from util import Timer

SOURCE_TYPE = 'vsphere'
Expand Down Expand Up @@ -59,6 +60,16 @@
LAST = 'last'
INTERVAL = 'interval'

ALL_UNITS = [
'millisecond', 'kiloBytesPerSecond', 'megaHertz', 'percent', 'number',
'microsecond', 'megaBytes', 'watt', 'kiloBytes', 'joule'
]

RATE_UNITS = [
'millisecond', 'kiloBytesPerSecond', 'megaHertz', 'percent', 'number',
'microsecond', 'megaBytes', 'watt', 'kiloBytes', 'joule'
]


class VSphereEvent(object):
UNKNOWN = 'unknown'
Expand Down Expand Up @@ -748,7 +759,13 @@ def _collect_metrics_atomic(self, instance, mor):
continue
instance_name = result.id.instance or "none"
value = self._transform_value(instance, result.id.counterId, result.value[0])
self.gauge(

# Metric types are absolute, delta, and rate
if ALL_METRICS[self.metrics_metadata[i_key][result.id.counterId]['name']]['s_type'] == 'rate':
record_metric = self.rate
else:
record_metric = self.gauge
record_metric(
"vsphere.%s" % self.metrics_metadata[i_key][result.id.counterId]['name'],
value,
hostname=mor['hostname'],
Expand Down

0 comments on commit de84b5d

Please sign in to comment.