Issue
Today has been release the KB 406460 related "The memory usage of agent NSX_OPSAGENT on ESXi node <UUID> has reached <kb> kilobytes which is at or above the high threshold value of 80%"
Solution
As a temporary workaround to the issue as mentioned in option 1, which consist in to restart OpsAgent on the affected hosts; I wrote a short prowershell script to restart the agent on all hosts connected to vCenter Cluster.
Let's see it below:
##########
#
# Run remote commands (Linux like) on esxi hosts to restart /etc/init.d/nsx-opsagent
#
# How it works:
# Connect to vCenter
# Get the list of ESXi hosts from the cluster
# Enable SSH on host
# Restart "/etc/init.d/nsx-opsagent" service on the host
# Disable SSH on host
#
# Requirement: Install-Module -Name Posh-SSH
#
# LM 22.05.2025
##
Import-Module -Name Posh-SSH
#Replace the parameter below with your values
$esxiUser = "root"
$esxiPassword = "<ESXi - PASSWORD>"
$vc = "<vCenter IP or FQDN>"
$vcUser = "administrator@vsphere.local"
$vcPassword = "<vCenter Password>"
$clusterName = "<Cluster Name>"
Connect-VIServer -Server $vc -User $vcUser -Password $vcPassword
$count=0
foreach ($esxiIP in (Get-Cluster -Name $clusterName | Get-VMHost)) {
$count = $count + 1
Write-Host " ----------------------- $($esxiIP) ----------------------------------"
# Enable SSH
Write-Host " Enabling SSH! " -ForegroundColor Green
Get-VMHost -Name $esxiIP| Get-VMHostService | ?{"TSM-SSH" -eq $_.Key} | Start-VMHostService
#SSH connection and service restart
$session = New-SSHSession -ComputerName $esxiIP -Credential (New-Object System.Management.Automation.PSCredential($esxiUser, (ConvertTo-SecureString $esxiPassword -AsPlainText -Force))) -Force
if ($session.Connected) {
$command = "/etc/init.d/nsx-opsagent restart"
$result = Invoke-SSHCommand -SessionId $session.SessionId -Command $command
if ($result.ExitStatus -eq 0) {
Write-Host "Service restarted! on Host ->"$esxiIP -ForegroundColor Green
} else {
Write-Host "Error on host $($esxiIP): $($result.Error)" -ForegroundColor Red
}
Remove-SSHSession -SessionId $session.SessionId | Out-Null
} else {
Write-Host "SSH Connection failed! on Host ->"$esxiIP -ForegroundColor Red
}
sleep 1
# Disable SSH
Get-VMHost -Name $esxiIP| Get-VMHostService | ?{"TSM-SSH" -eq $_.Key} | Stop-VMHostService -Confirm:$false
Write-Host " ----------------------------------------------------------------------------"
Write-Host
}
Disconnect-VIServer -Server $vc -Confirm:$false
That's it.
