Ejemplo n.º 1
0
        public void LogAgregatedPing(PingAgregatedResult result)
        {
            var lines = new List <string>();

            var sb = new StringBuilder();

            sb.Append(result.TimeStamp.ToString("dd.MM.yyyy HH:mm:ss"));
            sb.Append("\t");
            sb.Append(result.TimeStamp.ToString("dd.MM.yyyy"));
            sb.Append("\t");
            sb.Append(result.TimeStamp.ToString("HH:mm:ss"));
            sb.Append("\t");
            sb.Append(result.PingedTarget);
            sb.Append("\t");
            sb.Append(result.AveragePing);
            sb.Append("\t");
            sb.Append(result.TestTotalCount);
            sb.Append("\t");
            sb.Append(result.TestSuccessfulCount);
            sb.Append("\t");
            sb.Append(result.TestFailedCount);
            sb.Append("\t");

            lines.Add(sb.ToString());

            File.AppendAllLines(Path + "/pinglog" + TimeStamp + ".txt", lines);
        }
Ejemplo n.º 2
0
        public static PingAgregatedResult PingAgregatedTest(string target, int count)
        {
            if (count <= 0)
            {
                throw new ArgumentException("count must be greater than zero");
            }

            var result = new PingAgregatedResult {
                TimeStamp = DateTime.Now, PingedTarget = target, TestTotalCount = count, TestFailedCount = 0, TestSuccessfulCount = 0, Pings = new List <long>()
            };

            for (int i = 0; i < count; i++)
            {
                var temp = PingTest(target);
                result.Pings.Add(temp.ResponseMiliseconds);

                if (temp.IsSuccess)
                {
                    result.TestSuccessfulCount++;
                }
                else
                {
                    result.TestFailedCount++;
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
 public static void PrintAgregatedPingTestResult(PingAgregatedResult result)
 {
     Console.WriteLine();
     Console.WriteLine("===== Ping Agregated Test Result: {0} ===== ", result.TimeStamp);
     Console.WriteLine("Ping target: {0}", result.PingedTarget);
     Console.WriteLine();
     Console.WriteLine("Number of subtests: {0}", result.TestTotalCount);
     Console.WriteLine("  Failed tests: {0}", result.TestFailedCount);
     Console.WriteLine("  SuccessfulTests: {0}", result.TestSuccessfulCount);
     Console.WriteLine("  Success rate: {0:N2}%", ((double)result.TestSuccessfulCount / result.TestTotalCount) * 100);
     Console.WriteLine();
     Console.WriteLine("Average ping: {0:N2} ms", result.AveragePing);
 }
Ejemplo n.º 4
0
 public static void PrintShortAgregatedPingTestResult(PingAgregatedResult result)
 {
     Console.WriteLine("[{0}]Ping({1}): Average time - {5:N2}ms Success rate - {2}/{3}({4:N2}%)", result.TimeStamp, result.PingedTarget, result.TestSuccessfulCount, result.TestTotalCount, ((double)result.TestSuccessfulCount / result.TestTotalCount) * 100, result.AveragePing);
 }