Networking - networking mointoring system source code on asp.net or ,net

Asked By hussien on 13-Mar-11 05:58 PM
please help me on the network monitoring system with the source code on .net
c# or asp.net
and
thanks too
Ravinder Jamgotre replied to hussien on 15-Mar-11 11:19 AM
Hi Hussien,

You can use the following ASP.net code for see which machines are alive on the network.

// addressToPing can be an IPaddress or host name. 
// returns a boolean indicating successful ping 
public static bool PingComputer (string[] addressToPing) 
{ 
   
Ping pingSender = new Ping (); 
   
PingOptions options = new PingOptions (); 
 
   
// Use the default Ttl value which is 128, 
   
// but change the fragmentation behavior. 
    options
.DontFragment = true; 
 
   
// Create a buffer of 32 bytes of data to be transmitted. 
   
string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; 
   
byte[] buffer = Encoding.ASCII.GetBytes (data); 
   
int timeout = 120; 
   
PingReply reply = pingSender.Send (args[0], timeout, buffer, options); 
   
return reply.Status == IPStatus.Success; 
} 

Other PING classes for ASP.net can be found here http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping.aspx

You can use this ping code and iterate through the IP addresses on your LAN (for(i = 1; i < 255; i++)). You should probably read up on doing IP address calculations though:

http://blogs.msdn.com/knom/archive/2008/12/31/ip-address-calculations-with-c-subnetmasks-networks.aspx

This is called a 'ping sweep'. It does assume that the computers on the network have not been configured to ignore ICMP requests.

If you have the ability to install monitoring software on the various computers on the network, I've had good luck using nagios http://www.nagios.org/  for tracking which servers are up/under heavy load/out of disk space/etc in a production network. It also has a nice web front end that you wouldn't even need to use ASP for at all.

If you must create something home-grown with ASP, I would use nmap http://insecure.org/ to scan your class C subnet and then print the results in your ASP page. This isn't a very efficient method, but it would be very simple and be pretty much guaranteed to work (with appropriate options).

Hope this helps you.

Ravinder