Skip to main content
InSource Solutions

TN AppSvr 111 How to monitor if an IP Address returns a valid "Ping" response

 

insource logo large.jpg

 

Description

This tech note walks through using the System.Net.NetworkInformation .Net function to determine whether an IP Address returns a ping response.

 

  • Author: Joseph Hefner
  • Published: 01/06/2015
  • Applies to: Application Server 3.1 or later

 

Instructions

Create an attribute to hold the current status of the ping and one that holds the IP Address that you wish to monitor. In the example below the attributes are called "PingStatus" and "Address" effectively:

 

 

Capture3.JPG

 

 

Next create a script to monitor the ping and update the attribute with the current status of the ping. In the example below, I chose a periodic script that updates every one minute in order to make sure not to overwhelm the system.

 

 

Capture4.JPG

 

The sample script from the screenshot above can be downloaded from below:

 

dim p1 as System.Net.NetworkInformation.Ping;
dim PR as System.Net.NetworkInformation.PingReply;

p1 = new System.Net.NetworkInformation.Ping();
PR = p1.Send(Me.Address);

' check when the ping is not success
if (not PR.Status.ToString().Equals("Success")) then
logmessage ("The ping is not successfull");
Me.PingStatus = false;
EndIf;

' check after the ping is  success
If (PR.Status.ToString().Equals("Success")) then
logmessage ("The ping is successfull");
Me.PingStatus = true;
EndIf;

 

;