User Tools

Site Tools


vrealize:general:verify

Verify vRA and vRO is running

When vRA stops working, and you really have no idea why, you need to start looking into alot of different logfiles. Here is a Powershell Script you can use as a TEMPLATE if you want to check if all services of vRA is running as expected and if there is any issues with Load Balanser or any indvidual hosts. This will give you a very quick overview and pinpoint witch service is down.

You must enter the Load Balanser URL for vRA, IaaS and Manager, and also each seperate node (This so the script can check everything) Also enter the username/password for the vRA server. NOTE: if you do not have a loadbalanser infront, just enter the same name in the “nodes”

YOU MIGHT NEED TO RUN THE SCRIPT MORE THAN ONCE, FOR SOME REASON THE WEB API CALLS SOMETIMES FAILS TO SEND ANY DATA (Feature of vRA)

 
$MainURL = "cloud.customer.net";      # URL of the Load Balancer (Main URL) The URL you surf to when accessing vRA
$IaaSURL = "iaascloud.customer.net";  # URL of the Load Balancer, this is the IaaS infratruture URL
$ManagerURL = "iaasmanager.customer.net"; #URL of the Load Balancer, this is the Manager infrastructure URL
 
 
$vRANodes = @("A00-P1-APP041.customer.net","A00-P1-APP042.customer.net"); # Hostnames of each of the vRA nodes
 
$IaaSNodes = @("A00-P1-APP043.customer.net","A00-P1-APP044.customer.net"); # Hostnames of each of the Infratructure nodes
 
$ManagerNodes= @("A00-P1-APP045.customer.net","A00-P1-APP046.customer.net"); # Hostnames of each of the Manager nodes
 
# Credentials
$CredStr = "root:PasswordForRoot"
$encCred = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($CredStr)) 
 
 
 
# Default ports and URL, change if needed
 
$VAMIPORT = 5480
$VA_CONFIGURL = "/config/nodes/list?json=true&components=true";
$SVCPOINTSURL = "/component-registry/services/status?limit=1000";
$VMPSProxy = "/VMPS2Proxy";
 
$Script:MaxW = $Host.UI.RawUI.WindowSize.Width
 
if ($Script:MaxW -eq $null)
{
    $Script:MaxW = 120;
}
 
function WriteStatus([int]$level,[string]$text,[int]$status,[string]$statustext)
{
    $len = $text.Length;
    $Color = "White"
    if ($level -eq 0)
    {
        $Color = "Yellow"
    }
    elseif ($level -eq 1)
    {
        $Color = "Cyan"
    }
    elseif ($level -eq 2)
    {
        $Color = "Gray"
    }
    else
    {
 
    }
    Write-Host -ForegroundColor $Color $text -NoNewline
 
    if ($status -eq 0)
    {
        Write-Host 
    }
    else
    {
        $Color = "Green" # Status 1
        if ($status -eq 2)
        {
            $Color = "Yellow"
        }
        elseif ($status -eq 3)
        {
            $Color = "Red"
        }
 
        [string]$str ="";
        $Pos =  $Script:MaxW - $statustext.Length;
        while ($len -lt $Pos)
        {
            $str += " ";
            $len++;
        }
        $str += "[";
        Write-Host $str -NoNewline
        Write-Host $statustext -BackgroundColor $Color -NoNewline
        Write-Host "]"
    }
 
 
 
}
 
 
function RetriveApplianceInfo([string]$node)
{
    $url = "https://$($node):$($VAMIPORT)$VA_CONFIGURL"
 
    WriteStatus 0 "Downloading Appliance configuration ($node)" 0
 
    $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
    $headers.Add('Accept','Application/Json')
    $headers.Add("Authorization","Basic $encCred");
 
 
    $response = Invoke-WebRequest -Uri $url -Method Get -Headers $headers -UseBasicParsing
    $json = ConvertFrom-Json $($response.Content)
 
    $Count = $json.Count
    for ([int]$i=0;$i -lt $Count;$i++)
    {
        $nodeType = $json[$i].nodeType;
        $nodeHost = $json[$i].nodeHost;
        $nodeId = $json[$i].nodeId;
        $comp = $json[$i].components;
        if ($nodeType -eq "VA")
        {
            WriteStatus 1 "Found VA Host: $nodehost ($nodeid)" 0
            for ([int]$j=0;$j -lt $comp.Count;$j++)
            {
                if ($comp[$j].nodeType -eq "vRA" )
                {
                    if ($comp[$j].primary -eq $true)
                    {
                        WriteStatus 2 "Node: $($comp[$j].nodeType), Version: $($comp[$j].version)" 1 "Primary"
                    }
                    elseif ($comp[$j].primary -eq $false)
                    {
                        WriteStatus 2 "Node: $($comp[$j].nodeType), Version: $($comp[$j].version)" 1 "Secondary"
                    }
                }
                elseif ($comp[$j].nodeType -eq "vRO" )
                {
                           WriteStatus 2 "Node: $($comp[$j].nodeType), Version: $($comp[$j].version)" 0
                }
                else
                {
                           WriteStatus 2 "Unknown NodeType: $($comp[$j].nodeType)" 0
                }
 
            }
        }
        elseif ($nodeType -eq "IAAS")
        {
            WriteStatus 1 "Found IAAS Host: $nodehost ($nodeid)" 0
            for ([int]$j=0;$j -lt $comp.Count;$j++)
            {
                [int]$stid =0
                if ($comp[$j].state -eq "Started")
                {
                    $stid =1
                }
                elseif ($comp[$j].state -eq "Passive")
                {
                    $stid =2
                }
                elseif ($comp[$j].state -eq "Active")
                {
                    $stid =1
                }
                elseif ($comp[$j].state -eq "Available")
                {
                    $stid =1
                }
                else
                {
                    $stid =3
                }
                WriteStatus 2 "This node: $($comp[$j].nodeType) Version: $($comp[$j].version)" $stid $($comp[$j].state)
 
            }
        }
    }
}
function GetServiceInfo([string]$hostid,[string]$url)
{
    $response = Invoke-WebRequest -Uri $url
    $json = ConvertFrom-Json $response.Content
 
    if ($json.serviceInitializationStatus -ne "REGISTERED")
    {
        if ($json.serviceInitializationStatus -eq $null)
        {
            # Handle /system/health
            if ($json.EncryptionServiceImpl -eq "Encryption Service DB")
            {
                if ($json.AllOk -eq $true)
                {
                    WriteStatus 2 "($hostid)ClusterNode: $($json.HostName) ($($json.ClusterId)) Version: $($json.ServiceVersion)" 1 "RUNNING"
                }
                else
                {
                    WriteStatus 2 "($hostid)ClusterNode: $($json.HostName) ($($json.ClusterId)) Version: $($json.ServiceVersion)" 3 "DOWN"
                }
 
            }
            else
            {
                WriteStatus 2 "($hostid)Unknown ServiceType" 0
            }
        }
    }
    else
    {
        if ($json.errorMessage -ne $null)
        {
 
            WriteStatus 2 "($hostid)Service: $($json.serviceName) ($($json.serviceRegistrationId))" 2 "ERROR"
        }
        else
        {
            WriteStatus 2 "($hostid)Service: $($json.serviceName) ($($json.serviceRegistrationId))" 1 "REGISTERED"
        }
    }
 
}
 
 
function GetServicePoints([string]$url)
{
    [string]$RealURL = "HTTPS://$url$SVCPOINTSURL";
    $respone = Invoke-WebRequest -Uri $RealURL
    $json = ConvertFrom-Json $respone.Content
    $Count = $json.content.count
    for ([int]$i=0;$i -le $Count;$i++)
    {
        if ($json.content[$i].notAvailable -eq $false)
        {
            # Replace URL with Each vRA node aswell
            [string]$EndPointLB =$json.content[$i].statusEndPointUrl
            [string]$M = "HTTPS://$MainURL".ToLower();
            [string]$Iaas = "HTTPS://$IaaSURL".ToLower();
            if ($EndPointLB.ToLower().StartsWith($M))
            {
 
                GetServiceInfo $url $EndPointLB
                foreach ($vNODE in $vRANodes)
                {
                    [string]$EndPoint = $EndPointLB.Replace($MainURL,$vNODE)
                    GetServiceInfo $vNODE $EndPoint
                }
 
            }
            elseif ($EndPointLB.ToLower().StartsWith($Iaas))
            {
                GetServiceInfo $url $EndPointLB
                foreach ($vNODE in $IaaSNodes)
                {
                    [string]$EndPoint = $EndPointLB.Replace($IaaSURL,$vNODE)
                    GetServiceInfo $vNODE $EndPoint
                }
            }
            else
            {
                Write-Host "IaasNode or vRA node not found in list" -ForegroundColor Yellow
            }
        }
        else
        {
        }
  }
}
 
function CheckVMPS($url)
{
    [string]$realURL = "HTTPS://$url$VMPSProxy";
    try 
    { 
        $response = Invoke-WebRequest -Uri $realURL 
    } 
    catch  [System.Net.WebException]
    {
        if ($_.Exception.Response.StatusCode -eq 401)
        {
            # Check for IIS Return page, or standard 401
            if ($_.ErrorDetails.Message -like "*401.2*")
            {
                WriteStatus 2 "VMPS2Proxy $url" 2 "(Backup)";
                return;
            }
            else
            {
                WriteStatus 1 "VMPS2Proxy $url" 2 "Error";
                return;
            }
        }
        elseif ($_.Exception.Status -eq "ConnectFailure")
        {
            WriteStatus 1 "VMPS2Proxy $url" 2 "DOWN";
            return;
        }
        else
        {
            # Other Error
            Write-Host $_.Exception.Response.StatusCode
            Write-Host {0:x} $_.Exception.hResult
            Write-Host {0:x} $_.Exception.Status
            WriteStatus 2 "VMPS2Proxy $url" 2 "Unknown";
            return;
        }
    }
    WriteStatus 1 "VMPS2Proxy ($url)" 1 "UP";
}
 
 
function VerifyVCO([string]$url)
{
   $realurl = "https://$url$VCO_CHECKURL"
    WriteStatus 0 "Checking VRO (VCO) ($url)" 0
 
    try 
    { 
        $response = Invoke-WebRequest -Uri $realurl
        WriteStatus 1 "vRealize Orchstrator Node" 1 "UP"
 
    } 
    catch  [System.Net.WebException]
    {
        if ($_.Exception.Response.StatusCode -eq 503)
        {
            WriteStatus 1 "vRealize Orchstrator Node" 3 "DOWN"
        }
        elseif ($_.Exception.Response.StatusCode -eq 404)
        {
            WriteStatus 1 "vRealize Orchstrator Node" 3 "404 - NOT FOUND"
        }
        elseif ($_.Exception.Response.StatusCode -eq 401)
        {
            WriteStatus 1 "vRealize Orchstrator Node" 3 "401"
        }
        elseif ($_.Exception.Status -eq "ConnectFailure")
        {
            WriteStatus 1 "vRealize Orchstrator Node" 3 "DOWN"
        }
        else
        {
            WriteStatus 1 "vRealize Orchstrator Node" 3 "UNKNOWN"
        }
 
    }
}
 
GetServicePoints $MainURL
 
foreach ($vRANode in $vRANodes)
{
    RetriveApplianceInfo $vRANode
}
CheckVMPS $ManagerURL
foreach ($managerNode in $ManagerNodes)
{
    CheckVMPS $managerNode
}
 
# Verify vRO
 
VerifyVCO $MainURL
foreach ($vRANode in $vRANodes)
{
    VerifyVCO $vRANode
 
}
vrealize/general/verify.txt · Last modified: 2021/04/07 23:34 by vmware