368d6fafea
Code backup
37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
TextToBeWritten = "<div>Pinging... </div>";
|
|
|
|
string ipBase = "172.16.94.";
|
|
for (int i = 1; i < 100; i++)
|
|
{
|
|
string ip = ipBase + i.ToString();
|
|
|
|
Ping p = new Ping();
|
|
var pingReply = p.Send(ip, 100);
|
|
|
|
|
|
|
|
if (pingReply.Status != IPStatus.Success)
|
|
TextToBeWritten += "<div><div class=\"host-offline\">Offline</div>" + ip + "</div>";
|
|
else
|
|
{
|
|
//Machine is alive
|
|
TextToBeWritten += "<div><div class=\"host-online\">Online</div>" + ip + "</div>";
|
|
|
|
IPAddress hostIPAddress = IPAddress.Parse(ip);
|
|
TextToBeWritten += "<div>";
|
|
try
|
|
{
|
|
IPHostEntry hostInfo = Dns.GetHostByAddress(hostIPAddress);
|
|
IPAddress[] address = hostInfo.AddressList;
|
|
String[] alias = hostInfo.Aliases;
|
|
TextToBeWritten += "Host: " + hostInfo.HostName;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
TextToBeWritten += "DNS Resolution Error: " + e.Message;
|
|
}
|
|
TextToBeWritten += "</div>";
|
|
|
|
|
|
}
|
|
} |