Solved

How to ping/connect to port (SMTP) and receive answer

Posted on 2004-08-23
1
2,947 Views
Last Modified: 2008-01-09
Hi there,

Now standing in front of quite nice piece of work. I am supposed to write a small ASP code (which will be running on intranet IIS system), which will allow users to preview an application server status. I might use components as well, but just do not know, where to start.

I need to have some code snippets which will:
* allow me to run a ping from web server and show results (available/NOT available)
* allow me to connect to a specified server port, send there something and receive a response
   (to check the service availability)
* etc.

Is this possible? Any ideas? web links are OK, you do not need to write a lot, just say... man, you are crazy, it is not possible.... or say yep, just use this and this...


Thanks a lot.

Bye
Petr

0
Comment
Question by:keson
1 Comment
 
LVL 7

Accepted Solution

by:
rhrowson earned 125 total points
Comment Utility
I have a vbscript that does this in conjunction with a text file. It polls for the presence of a particular page. You could modify the page it calls to send an e-mail:

Script:

Dim varTestURL
Dim varSiteName
Dim varTestURLLength
Dim varSiteNameLength
Dim varFS
Dim varInputFile
Dim varOutputFile



Set varFS=CreateObject("Scripting.FileSystemObject")
Set varInputFile = varFS.OpenTextFile("C:\WebServers.txt",1,True)




Do While Not varInputFile.AtEndOfStream
   



varTestURL=varInputFile.ReadLine



'varTestURL="http://phone/server_info.asp"
varTestURLLength=Len(varTestURL)
varSiteNameLength=InStr(8,varTestURL,"/",1)
varSiteName=Mid(varTestURL,8,(varSiteNameLength-8))
'MsgBox varSiteName
Set xmlHTTP = CreateObject("Microsoft.XMLHTTP")

xmlHTTP.Open "GET", varTestURL, False

xmlHTTP.Send
'WScript.Echo "Server Response: " & xmlHTTP.Status
If xmlHTTP.Status=200 Then
'MsgBox "OK", vbOK

'WScript.Echo
'WScript.Echo "Headers"
'WScript.Echo "======="
'WScript.Echo xmlHTTP.GetAllresponseHeaders
'WScript.Echo
'WScript.Echo "HTML"
'WScript.Echo "======="
'WScript.Echo xmlHTTP.responseText
Elseif xmlHTTP.Status<>200 Then
'       MsgBox"Panic",vbcritical
       
       
        MsgBox varSiteName & " is down"
        Set varOutputFile=varFS.OpenTextFile("C:\WebServers1.txt",8,True)
        varOutputFile.writeline(varSiteName & " Is down " & Date & " "& Time)
        varOutputFile.Close
End If

Set xmlHTTP = Nothing

Loop

You will need to create the text file and each line should look like this:

http://test/server_info.asp

the page could be an SMTP test page
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Lync server 2013 Backup Service Error ID 4049 – After File Share Migration
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now