Monitoring ZVM-vCenter Connection Using Powershell

Zerto Virtual Manager VM requires continuous connection to vCenter, which it supports. Once the connection is somehow interrupted, you will not be able to access the Zerto Portal and perform any actions such as failover. Fortunately, replication should not be interrupted as it is performed by the Z-VRAs installed on each ESXi host.

In vCenter there is a Zerto alarm:

com.zerto.event.disconnectedvcenter

which should occur if this connection is interrupted. However, if you want to monitor it in a different way, I created a simple Powershell script for this.

The script presented in this article can be found at My GitHub Repository.


Script

Before running the script, you may need to create a new source in the event log with the following command:

New-EventLog -Source “Zerto” -LogName “Application”

The script is really simple, if the connection is ok then nothing needs to be done, if not then create an event.

Make sure you include your vCenter’s IP address in the script.

#vmcloud.pl
if ((Test-NetConnection -ComputerName YOUR_vCenter_IP -Port 443).TcpTestSucceeded){
		Write-Host "vCenter is up" -ForegroundColor Green
	    }
	else
    {
		Write-Host "vCenter is down" -ForegroundColor Red
		Write-EventLog -LogName "Application" -Source "Zerto" -EventID 16 -EntryType Error -Message "Connection with vCenter over port 443 is down"
	}

Running a script:

If there is no connection between ZVM and vCenter, an Error event will be created in the application log, source “Zerto” with event ID 16. You can use them for any monitoring tool in your infrastructure.


Creating a task

To automate this process, I used a task scheduler.

With the script below, you can create a task that will run every 5 minutes, once started, indefinitely.

Modify the connection script location if necessary.

#vmcloud.pl
$taskName = "ZVM-vCenter Connection"
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "C:\temp\vCenter_connection.ps1"
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes 5)
Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger -RunLevel Highest -User "System"

Thank you for reading! Here are some links you may be interested in:

Leave a comment

Create a website or blog at WordPress.com

Up ↑