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

feat(xo-server-perf-alert): don't compute RAM usage when no tools #7886

Merged
merged 15 commits into from
Sep 5, 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
2 changes: 2 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- [Pool/Networks] Networks can be filtered by VLANs, e.g. `VLAN:10`
- [REST API] Add `pifs` and `vm-controllers` collections
- [REST API/Dashboard] Add name and type of the backup in the backup job issues (PR [#7958](https://github.com/vatesfr/xen-orchestra/pull/7958))
- [Perf-alert] Display warning if no guest tools are detected while monitoring VM memory (PR [#7886](https://github.com/vatesfr/xen-orchestra/pull/7886))

### Bug fixes

Expand All @@ -37,6 +38,7 @@
<!--packages-start-->

- xo-server minor
- xo-server-perf-alert minor
- xo-web minor

<!--packages-end-->
38 changes: 33 additions & 5 deletions packages/xo-server-perf-alert/src/index.js
MathieuRA marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,39 @@ ${monitorBodies.join('\n')}`
})
}

result.listItem = ` * ${result.objectLink}: ${
result.value === undefined
? "**Can't read performance counters**"
: result.value.toFixed(1) + typeFunction.unit
}\n`
const isManagementAgentDetected = (vm, guestMetrics) => {
if ((vm.power_state !== 'Running' && vm.power_state !== 'Paused') || guestMetrics === undefined) {
return
}

const { major, minor } = guestMetrics.PV_drivers_version
const hasPvVersion = major !== undefined && minor !== undefined
return hasPvVersion || guestMetrics.other['feature-static-ip-setting'] === '1'
}

const getListItem = () => {
if (result.value == null) {
return "**Can't read performance counters**"
}

// VM RAM usage is reported by the VM itself through guest tools. If guest tools are not installed, ignore RAM usage stats
if (lcObjectType === 'vm' && definition.variableName === 'memoryUsage') {
pdonias marked this conversation as resolved.
Show resolved Hide resolved
const vm = result.object
const guestMetrics = this._xo.getXapi(uuid).getObject(vm.guest_metrics)
const managementAgentDetected = isManagementAgentDetected(vm, guestMetrics)

if (managementAgentDetected === undefined) {
return "**Can't read performance counters**"
}
if (managementAgentDetected === false) {
return '**Guest tools must be installed**'
}
}

return result.value.toFixed(1) + typeFunction.unit
}

result.listItem = ` * ${result.objectLink}: ${getListItem()}\n`

return result
} catch (error) {
Expand Down
Loading