-
Notifications
You must be signed in to change notification settings - Fork 273
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
Conversation
5c782e7
to
983f456
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if you agree with me @MathieuRA but I feel like it would be more clear to use the return statement of a function instead of defining this maybeUpdateListItem
function, which essentially does "return value
if no value was returned before" (if I understood well). It would also prevent some code to execute when it is not useful.
It could be something like this : (I did not test it)
const getListItem = () => {
if (result.value === undefined) {
return "**Can't read performance counters**"
}
if (lcObjectType === 'vm' && definition.variableName === 'memoryUsage') {
const checkManagementAgent = (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 vm = result.object
const guestMetrics = this._xo.getXapi(uuid).getObject(vm.guest_metrics)
const managementAgentDetected = checkManagementAgent(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`
@b-Nollet actually
and it seems to work but isn't Mathieu's version more readable ? |
I may be misunderstanding something, but as |
@b-Nollet Yes, I think it would be better. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also link to the other PR so we can easily edit both sides if needed.
See #7831
Screenshot
Fixes first part of https://kanban.vates.fr/b/jnfjuip4eBARBNuv9/xo-releases/jHtPoS4TKqZB7QL7Z
![Capture d’écran de 2024-08-08 10-07-09](https://private-user-images.githubusercontent.com/70369997/356136574-f40129de-c0b9-456d-b0e1-a473c177c72f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzOTE1MTcsIm5iZiI6MTczOTM5MTIxNywicGF0aCI6Ii83MDM2OTk5Ny8zNTYxMzY1NzQtZjQwMTI5ZGUtYzBiOS00NTZkLWIwZTEtYTQ3M2MxNzdjNzJmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDIwMTMzN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI4NDk2MzkxN2UzNjJkZThiNDc4MmQ5NmMxNDE0OWM5MzQxNDFhZjYwZTJkYTAyMWRmM2Y4MDVkZGJmOTA4YTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.vuHCBFo6WHUdugZ_etcXo9tjjxVd0vanzOWaBZ4Ccq4)
Description
No memory usage is collected without the guest tools. That means that the selected VMs won't be monitored by the xo-server-perf-alert plugin
Checklist
Fixes #007
,See xoa-support#42
,See https://...
)Introduced by
CHANGELOG.unreleased.md