Monitoring Unified Messaging Worker Process Port Number

Unified Messaging worker process in Exchange uses either port 5065 & 5067, we had some issues with Avaya session manager that it was not able to redirect to these ports after making an initial connection on port 5060.

Therefore till the problem can be fixed Avaya team was doing hard coding of the port numbers (5065 /5067) but issue here is these port number changes between  5065 & 5067.

GIF-How-a-face-changes-with-changing-light

Again powershell has came as a rescue here & we have built a nice workaround, if port changes than Avaya team gets alerted & they change the port at their end.

For example:

If initially port is 5065 & for some reason after Unified Messaging server reboot port changes to 5067 , alert is being generated.

To achieve this goal we need something as telnet to programmatically test the port numbers so here is the powershell script that we embedded in our solution.

http://blogs.technet.com/b/wsnetdoc/archive/2011/11/07/windows-powershell-script-test-port.aspx

Download & extract the solution from below link:

https://gallery.technet.microsoft.com/scriptcenter/Unified-Messaging-Port-de7b57dc

Update the UMsrvsWport.txt as shown below(script can handle multiple servers)

Update the UMportMon.ps1 file with email addresses & smtp server

$smtpServer = “smtpserver”

$fromadd = “SystemsMonitoring@labtest.com”
$email1 = “Sukhija1@labtest.com”

Schedule the script from task scheduler every 15 -30 minutes & now when ever port changes you will get alert as below:

######################################################################### 
#            Author: Vikas Sukhija 
#            Date: 4/4/2016 
#            Reviewer: 
#            Desc: Monitor Port for unified messsaging &  
#            send alert if it changes 
#            Refrence: http://blogs.technet.com/b/wsnetdoc/archive/2011/11/07/windows-powershell-script-test-port.aspx 
######################################################################### 
#--------For Log Files-------------- 
 
$date = get-date -format d  
$date = $date.ToString().Replace(“/”, “-”)  
$time = get-date -format t  
$time = $time.ToString().Replace(":""-")  
$time = $time.ToString().Replace(" """)  
 
$logs = ".\Logs" + "\" + "UMporttest" + $date + "_" + $time + "_.log" 
 
$smtpServer = "smtpserver" 
$fromadd = "SystemsMonitoring@labtest.com" 
 
$email1 = "Sukhija1@labtest.com" 
 
$port1 = "5065" 
$port2 = "5067" 
 
 
Start-Transcript -Path $logs  
 
################LOad Test Port Function###################### 
 
write-host "Loading test port function" -foregroundcolor green 
 
. .\test-port.ps1 
 
$arrsrvpo = @() 
 
$umsrvs = gc .\UMsrvsWport.txt 
 
$umsrvs | foreach-object { 
 
$srv = $_.split(":")[0] 
$port = $_.split(":")[1] 
 
 
#####################Test ports now#################### 
 
if($port1 -eq $port) { 
Write-host "$port1 is the current port on server $srv" -foregroundcolor green 
 
$tport1 = Test-Port -computer $srv -port $port1 -tcp 
$tport2 = Test-Port -computer $srv -port $port2 -tcp 
 
if(($tport1.open -like $false-and ($tport2.open -like $true)){ 
 
$msg = new-object Net.Mail.MailMessage 
$smtp = new-object Net.Mail.SmtpClient($smtpServer) 
 
#Mail sender 
$msg.From = $fromadd 
#mail recipient 
$msg.To.Add($email1$msg.Subject = "Open Critical: Port $port1 is not open on $srv - Pls change it in avaya session manager to $port2" 
$msg.Body = "Port $port1 is not open on $srv - Pls change it in avaya session manager to $port2" 
$smtp.Send($msg) 
 
#################update ports file################## 
$arrsrvpo +$srv + ":" + $port2 
 
    } 
else$arrsrvpo +$srv + ":" + $port1} 
 
} 
 
if($port2 -eq $port) { 
 
Write-host "$port2 is the current port on server $srv" -foregroundcolor green 
 
$tport1 = Test-Port -computer $srv -port $port1 -tcp 
$tport2 = Test-Port -computer $srv -port $port2 -tcp 
 
if(($tport2.open -like $false-and ($tport1.open -like $true)){ 
 
$msg = new-object Net.Mail.MailMessage 
$smtp = new-object Net.Mail.SmtpClient($smtpServer) 
 
#Mail sender 
$msg.From = $fromadd 
#mail recipient 
$msg.To.Add($email1) 
 
$msg.Subject = "Open Critical: Port $port2 is not open on $srv - Pls change it in avaya session manager to $port1" 
$msg.Body = "Port $port2 is not open on $srv - Pls change it in avaya session manager to $port1" 
$smtp.Send($msg) 
 
#################update ports file################## 
 
$arrsrvpo +$srv + ":" + $port1 
    } 
else$arrsrvpo +$srv + ":" + $port2} 
 
} 
 
} 
 
$arrsrvpo > ".\UMsrvsWport.txt" 
 
stop-transcript 
 
##############################################################
Regards
Sukhija Vikas
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s