Network Device Checker 

This tool was developed by me because I needed something to keep track of devices on the network and when they would fail. This utility will test communications with the devices using the Windows Ping utility. 

This tool will ping the device and then store the result of Success of Fail to a log database that you will be able to query to find the latest status.

Enough said .. Lets get started.

This was built with MySQL, but could be changed to work with Access.

Create Table: NetworkAddress

SET FOREIGN_KEY_CHECKS=0;
use (database);
#----------------------------
# Table structure for networkaddress
#----------------------------
CREATE TABLE `networkaddress` (
`FileID` int(11) NOT NULL auto_increment,
`Name` varchar(100) default NULL,
`address` varchar(20) default NULL,
PRIMARY KEY (`FileID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


This table is used to store the name of the device and the IP address.


Create Table: NetworkLog

SET FOREIGN_KEY_CHECKS=0;
use (database);
#----------------------------
# Table structure for networklog
#----------------------------
CREATE TABLE `networklog` (
`FileID` int(11) NOT NULL auto_increment,
`ResourceName` varchar(50) default NULL,
`Status` varchar(20) default NULL,
`LogDateTime` timestamp NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`FileID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='InnoDB free: 22528 kB; InnoDB free: 22528 kB; InnoDB free: 2';


This table is used to store the result of the Ping.



Create File: NetworkTest.cfm

<!--- Get All Network Address --->
<cfquery datasource="(DBNAME)" name="getAddress">
    SELECT *
    FROM networkaddress
</cfquery>

<cfoutput>
    <cfloop query=
"getAddress">

    <cftry>
        <cfexecute name=
"ping.exe" timeout="60" arguments="#address#" variable="execRet" />
        <cfcatch>
            <cfthrow message=
"ping process timed out" />
        </cfcatch>
    </cftry>


    <cfoutput>
        <cfset stringToSearch =
"#execRet#">
        <cfif find(
"Request timed out",stringToSearch) EQ 0>
            <cfset status =
"on-line">
            <p>#name# -- (On Line)</p>
        <cfelse>
            <cfset status =
"off-line">
            <p>#name# -- (Off Line)</p> 
        </cfif>

    <!--- Add Records to Database to read later --->
    <cfquery datasource="(DBNAME)" name="getAddress">
        INSERT INTO networklog (resourcename, status, LogDateTime )
        VALUES ('#name#', '#status#', NOW());
    </cfquery>

    </cfoutput>
    </cfloop>
</cfoutput>


This file will be the one that actually runs all the test and stores the result into the NetworkLog Database.


Create File: NetworkStatus.cfm

<!--- Get Resources --->
<cfquery datasource="(DBNAME)" name="getResources">
   
SELECT *
    FROM networklog
    Group by ResourceName
    Order by ResourceName Asc
</cfquery>

<b>Test Network Servers </b><br />
- Using Ping to check for commnucations on network every 10min.<br />
- History Log can be viewed by clicking on Resource Name.
<br /><br /> 


<cfoutput>
    <cfloop query=
"getResources">

    <!--- Get All Network Address --->
    <cfquery datasource="#application.dsn#" name="getLog">
        SELECT *
        FROM networklog
        Where ResourceName = '#getResources.ResourceName#'
        Order by FileID DESC 
    </cfquery>

    <table width="90%">
        <tr> 
            <td width=
"400">#trim(getLog.ResourceName)#</td>
            <td width=
"100">#trim(getLog.status)#</td>
            <td width=
"100">#timeformat(getLog.logDateTime, "hh:mm:ss")#</td>
        <tr>
    </table>

    </cfloop>
</cfoutput> 



That?s it .. 

You can now set your schedule and your coldfusion server will now start tracking these resources for you. 
It would be good to mention that you could build onto this so that you are sent an alert when you have a failure.

Enjoy

Thank you EasyCFM, I have used your site for well over a year now and find it a endless source for information and help.

About This Tutorial
Author: Paul Bailey
Skill Level: Beginner 
 
 
 
Platforms Tested: CFMX,CFMX7
Total Views: 22,401
Submission Date: February 11, 2006
Last Update Date: June 05, 2009
All Tutorials By This Autor: 1
Discuss This Tutorial
  • The tutorial is fantastic,but we need diargam on networking devices,make this enquiry to it.Thank you.

Advertisement

Sponsored By...
Powered By...