vSphere Client becomes inaccessible intermittently and requires service restart to recover
Accessing vCenter service in ELM (linked mode) might return the error "Could not connect to one or more vCenter Server systems:https://<vcenter FQDN>:443/sdk"
/var/log/vmware/vsphere-ui/logs/vsphere_client_virgo.log
This issue is caused due to "host.PatchManager.ScanV2" task being spawned for each separate ESXi host when user scan for patches for a Cluster, Datacenter or vCenter. The task type "host.PatchManager.ScanV2" generates a XML as result (>2 Mb size)
VMware is aware of this issue and working to resolve this in a future release
As a workaround, we need to manually set the results of the tasks to null to avoid OutOfMemory error of vSphere UI. To do this, please follow the steps below:
Download the attached script prune_PatchManager_Task_Results.sh and upload to the impacted vCenter Server to the /tmp folder.
In case of connection failure, refer to Error when uploading files to vCenter Server Appliance using WinSCP
Use SSH to connect to the VCSA and enter the Bash shell
Change the file permission as executable
chmod +x /tmp/prune_PatchManager_Task_Results.sh
Run the following command in the terminal
./tmp/prune_PatchManager_Task_Results.sh
Restart the vsphere-ui service using the below command
service-control --restart vsphere-ui
To schedule the same script as Cron Job
Save the script to a persistent location on the vCenter Server
Run the below command to open the crontab configuration file :
crontab -e
Append the crontab file with this following command :
<Minute> <hour> <day_of_the_month> <month> <day_of_week>
/tmp/prune_PatchManager_Task_Results.sh
Below example will run the script after every 24 hours of interval :
02
17
* * *
/tmp/prune_PatchManager_Task_Results.sh
Which will run the script everyday at 17:02 UTC
Save the file and exit
The changes take effect immediately and the script run at the next scheduled time.
Note: The above script performs a copy of the vpx_task table from vCenter server database (VCDB) and post that executes the cleanup of the specific column having the xml data. During this process, the copy of the table will be saved under "/exports/vcdb/" directory on the VCSA.
The above file can be cleaned up manually via logging in to the VCSA using ssh or can add the below action as Cron Job.
02 19 * * * find /exports/vcdb/vpx_task*.csv -type f -mtime +1 -exec rm {} \;
which will run the cleanup everyday at 19:02 UTC and cleanup file older than 1 day