46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
{57d4d53893621e3830a887058cd5c901c6ecfd62 true 1578 Program.cs 0xc002baa230}
using System;
|
|
using System.Net.NetworkInformation;
|
|
|
|
namespace Manarah.App
|
|
{
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
string server1 = "172.25.0.1"; // Replace with actual server name or IP address
|
|
string server2 = "172.25.0.2"; // Replace with actual server name or IP address
|
|
string server3 = "104.21.6.135"; // Replace with actual server name or IP address
|
|
|
|
Console.WriteLine("Checking server status...");
|
|
|
|
foreach (string server in new[] { server1, server2,server3 })
|
|
{
|
|
|
|
try
|
|
{
|
|
|
|
Ping ping = new Ping();
|
|
PingReply reply = ping.Send(server, 500); // Timeout after 500ms
|
|
|
|
if (reply.Status == IPStatus.Success)
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.Green;
|
|
Console.WriteLine($"{server} is up and running! Response time: {reply.RoundtripTime}ms");
|
|
}
|
|
else
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.Red;
|
|
Console.WriteLine($"{server} is not responding.");
|
|
}
|
|
}
|
|
catch (PingException ex)
|
|
{
|
|
Console.WriteLine($"Error checking {server}: {ex.Message}");
|
|
}
|
|
}
|
|
Console.ResetColor();
|
|
Console.WriteLine("Press any key to exit.");
|
|
Console.ReadKey();
|
|
}
|
|
}
|
|
} |