mO SharemO Share

How To: Check stability of a connection of a service like Web Database

Introduction

This article explains how we can use a script to generate a connectivity check log. The script in example shows the connectivity check of a Web Database, which helps to narrow the troubleshooting of Sync failure issues where Web database connectivity is being lost. This actually keeps querying the Web Database IP on port 1433 as same as a Ping command do and additionally it generate a log with Date/time stamp. We can compare this generated log with the SYNC log and observe if the SYNC error in SYNC log coincide with the time when reply drop is found in this generated log.

Moreover, the script can be be modified with appropriate details for different customers. Also, other service can be tested modifying the IP and PORT appropriately.

Steps to do

  • Download the Microsoft utility PSPing either from http://support.ginesys.in/downloads/utilities/PsPing.exe or from Microsoft website.

  • Copy the content mentioned in following Code Snippet in a text file. Change the Web Database host name as per requirement (in line 12).

  • Save this txt file with .ps1 extension to convert it as as PowerShell script. Example: ConnCheck.ps1.

  • Keep PSPING.exe and this PowerShell script in same folder. Preferably in GSL directory for easy locating. Further the log output will be generated in the same directory.

Code Snippet

<# Remarks- Save this file with.ps1 extension Change the WebDB host name in line 12 as per requirement Keep PSPING.exe and this PowerShell script in the same folder. #> $ConnCheck = { $dt = get-date -Format yyyyMMdd_HHmmss $i = 2 do {Get-Date | Tee-Object -Append -FilePath logs\PsPingLog_$dt.txt & "psping" -n 3s yourwebdb.gsl.co.in:1433| Tee-Object -Append -FilePath logs\PsPingLog_$dt.txt $i--} while ($i -ge 0) if ($i -le 0) {&$ConnCheck} } &$ConnCheck