Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PLINT-323] Collecting a new vSphere metric: cpu.usage.vcpus.avg #17087

Merged
merged 4 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions vsphere/changelog.d/17087.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Collect a new vSphere metric: cpu.usage.vcpus.avg
2 changes: 2 additions & 0 deletions vsphere/datadog_checks/vsphere/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'cpu.latency.avg',
'cpu.readiness.avg',
'cpu.usage.avg',
'cpu.usage.vcpus.avg',
'cpu.utilization.avg',
'datastore.siocActiveTimePercentage.avg',
'disk.capacity.contention.avg',
Expand Down Expand Up @@ -80,6 +81,7 @@
'cpu.swapwait.sum',
'cpu.system.sum',
'cpu.usage.avg',
'cpu.usage.vcpus.avg',
'cpu.usagemhz.avg',
'cpu.used.sum',
'cpu.wait.sum',
Expand Down
1 change: 1 addition & 0 deletions vsphere/metadata.csv
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ vsphere.cpu.totalCapacity.avg,gauge,,megahertz,,Total CPU capacity reserved by a
vsphere.cpu.totalmhz.avg,gauge,,megahertz,,Total megahertz of CPU being used,-1,vsphere,cpu totalmhz avg,
vsphere.cpu.usage,gauge,,percent,,Percentage of CPU capacity being used [Legacy],-1,vsphere,cpu usage,
vsphere.cpu.usage.avg,gauge,,percent,,Percentage of CPU capacity being used,-1,vsphere,cpu usage avg,
vsphere.cpu.usage.vcpus.avg,gauge,,percent,,Virtual CPU usage as a percentage during the interval,-1,vsphere,cpu usage vcpus avg,
vsphere.cpu.usagemhz,gauge,,megahertz,,Total megehertz of CPU being used [Legacy],-1,vsphere,cpu usagemhz,
vsphere.cpu.usagemhz.avg,gauge,,megahertz,,"CPU usage, as measured in megahertz",-1,vsphere,cpu usagemhz avg,
vsphere.cpu.used.sum,gauge,,millisecond,,"Time accounted to the virtual machine. If a system service runs on behalf of this virtual machine, the time spent by that service (represented by cpu.system) should be charged to this virtual machine. If not, the time spent (represented by cpu.overlap) should not be charged against this virtual machine.",0,vsphere,cpu used sum,
Expand Down
39 changes: 39 additions & 0 deletions vsphere/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,45 @@ def test_report_realtime_vm_percent_metrics(aggregator, dd_run_check, realtime_i
)


def test_report_realtime_vm_vcpu_percent_metrics(aggregator, dd_run_check, realtime_instance, service_instance):
service_instance.content.perfManager.QueryPerfCounterByLevel = mock.MagicMock(
return_value=[
vim.PerformanceManager.CounterInfo(
key=33,
groupInfo=vim.ElementDescription(key='cpu'),
nameInfo=vim.ElementDescription(key='usage.vcpus'),
rollupType=vim.PerformanceManager.CounterInfo.RollupType.average,
unitInfo=vim.ElementDescription(key='percent'),
),
]
)
service_instance.content.perfManager.QueryPerf = mock.MagicMock(
side_effect=[
[
vim.PerformanceManager.EntityMetric(
entity=vim.VirtualMachine(moId="vm1"),
value=[
vim.PerformanceManager.IntSeries(
value=[5299],
id=vim.PerformanceManager.MetricId(counterId=33),
)
],
),
],
[],
]
)
check = VSphereCheck('vsphere', {}, [realtime_instance])
dd_run_check(check)
aggregator.assert_metric(
'vsphere.cpu.usage.vcpus.avg',
value=52.99,
count=1,
hostname='vm1',
tags=['vcenter_server:FAKE'],
)


def test_report_realtime_vm_metrics_invalid_value(aggregator, dd_run_check, realtime_instance, service_instance):
service_instance.content.perfManager.QueryPerf = mock.MagicMock(
return_value=[
Expand Down
Loading