Tech Rocks

Coldfusion
Java
JQuery

An online resource for latest web technologies like Coldfusion, JRun, Pro*C, JQuery, HTML5, PHP, W3C, Java, J2EE, C, C++, ORACLE, PL/SQL, MySql, Ajax, Coldbox, Fusebox, UNIX, JavaScript, NodeJS and much more...

Thursday, November 20, 2008

Network Device Checker

A kool site i found
http://tutorial437.easycfm.com/
Detecting devices in network using coldfusion cfexecute ping.
Check it out!

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



SELECT *
FROM networkaddress

















#name# -- (On Line)





#name# -- (Off Line)






INSERT INTO networklog (resourcename, status, LogDateTime )
VALUES ('#name#', '#status#', NOW());






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


Create File: NetworkStatus.cfm



SELECT *
FROM networklog
Group by ResourceName
Order by ResourceName Asc


Test Network Servers

- Using Ping to check for commnucations on network every 10min.

- History Log can be viewed by clicking on Resource Name.










SELECT *
FROM networklog
Where ResourceName = '#getResources.ResourceName#'
Order by FileID DESC









#trim(getLog.ResourceName)##trim(getLog.status)##timeformat(getLog.logDateTime, "hh:mm:ss")#






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

1 comments :

Post a Comment