Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PING a series of servers

Status
Not open for further replies.

mcourtr

Technical User
May 13, 2002
6
US
I have a database table with several hundred servers in it that need to be checked on a daily basis. Basically just checking the IP channel from one location to another. I need a CF ping script that will return simply success or failure - no other information is needed - just yay or nay. I have a very simplistic script that I wrote that does the job but not very efficiently. Especially when servers fail the test. Does anyone have a superior script?

Code:
<cfset ipList = "[list of ip addresses]">

<table border="1">
<cfloop list="#ipList#" index="i">
  <cfset ip="#i#">
  <cfexecute
    name="ping.exe"
    arguments="#ip# -n 1"
    timeout="5"
    variable="results" />
  <tr>
    <td><cfoutput>#ip#</cfoutput></td>
    <td>
      <cfif results contains "Reply from #ip#">
        <span style="color:green">Success</span>
      <cfelseif results contains "Request timed out.">
        <span style="color:red">Failed</span>
      <cfelse>
        Unknown
      </cfif>
    </td>
  </tr>
</cfloop>
</table>
 
Try running about 10 of these pings from a batch file on your workstation and then the same 10 through cfexecute and see if there is a significant time difference.

I did that and the difference on my server and workstation was almost zero; the .bat file ran 170ms faster.

Lyndon
 
Yes, I do see the similarities in execution time. I should mention that what I'm really comparing is the execution time between CF and Perl. Using the Net::ping module in Perl, failures take a fraction of the time that CF does.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top