Virtual Machine with performance degraded
Scenario
In this scenario, a Virtual Machine named exercise4 is currently in a running state. The development team has reported performance issues with an application hosted on this VM.
Your task is to investigate the problem by analyzing the VM’s resource usage, including CPU, memory, and other relevant metrics. You are permitted to adjust the VM’s compute resources as needed to resolve the issue; however, a reboot is not permitted.
| 
 | 
The steps to fix exercise4 are:
Console
- 
Login to OpenShift console using the assigned user account. 
userx{password}- 
Go to Virtualization - VirtualMachines - Select the project for the assigned user account 
 
- 
Go to Virtual Machine details and check the resources being consumed and the Virtual Machine number of CPU’s 
 
- 
Click Configurationtab and change theCPU | Memory
 
- 
Change the number of CPU’s from 2 to 4 and click Save
 
- 
Verify the number of CPU’s has been changed from 2 to 4. 
 
lab grade exercise4Command line (CLI)
- 
Login to Openshift server API using the assigned user account with occommand if not logged in.
{login_command}- 
Go to the assigned namespace-userx 
oc project namespace-userx- 
List the virtual machines 
oc get virtualmachineNAME        AGE     STATUS    READY
exercise4   3m29s   Running   True- 
List the pods 
oc get podsNAME                            READY   STATUS    RESTARTS   AGE
virt-launcher-exercise4-lb66m   1/1     Running   0          3m41- 
Check the number of CPU’s 
oc get vm exercise4 -n namespace-userx \
-o jsonpath='{.spec.template.spec.domain.cpu}'{"cores":1,"sockets":2,"threads":1}- 
Validate this information within OS virtual machine 
virtctl ssh lab-user@exercise4 -c 'lscpu | grep Socket'Warning: Permanently added 'vmi/exercise4.namespace-userx' (ED25519) to the list of known hosts.
2- 
Check the virtual machine is using almost 100% CPU 
oc adm top podsNAME                            CPU(cores)   MEMORY(bytes)
virt-launcher-exercise4-lb66m   1993m        1224Mi- 
change the virtual machine sockets from 2 to 4 
oc patch vm exercise4 -n namespace-userx --type='json' \
-p='[{"op": "replace", "path": "/spec/template/spec/domain/cpu/sockets", "value": 4}]'- 
check the virtual machine is now running with 4 sockets 
oc get vm exercise4 -n namespace-userx \
-o jsonpath='{.spec.template.spec.domain.cpu}'{"cores":1,"sockets":4,"threads":1}- 
Validate this information within OS virtual machine 
virtctl ssh lab-user@exercise4 -c 'lscpu | grep Socket'Warning: Permanently added 'vmi/exercise4.namespace-userx' (ED25519) to the list of known hosts.
4- 
Command to check the CPU usage on Virtual Machine 
virtctl ssh lab-user@exercise4 \
--command "top -b -n 1 | grep 'Cpu(s)' | awk '{print \$2 \"% Used\"}'"What you learned
In this exercise, you learned that when working with a RHEL 9 virtual machine, there is no need to shut down or reboot the VM to modify the CPU configuration. Instead, you can perform a CPU hotplug operation while the VM is running. Even without using it in this exercise, it’s possible to perform memory hotplug without rebooting the virtual machine as well.