From bea496aa3383b137cfc434a5dd47f88d6edad80d Mon Sep 17 00:00:00 2001 From: Schwirg László Date: Mon, 20 Sep 2021 16:35:07 +0200 Subject: [PATCH] v1.8.1 - pinger javítgatása --- Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools - TcpIp.cs | 149 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------- Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs | 39 ++++++++++++++++++++++++++++----------- Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs | 4 ++-- 3 files changed, 136 insertions(+), 56 deletions(-) diff --git a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools - TcpIp.cs b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools - TcpIp.cs index 8588e3e..4830e59 100644 --- a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools - TcpIp.cs +++ b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools - TcpIp.cs @@ -41,7 +41,31 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS this.PingCycleNumberOfPackages = pc.pingcyclenumofpackages; this.PingerActiveLength = pc.pingeractivlength; this.Configuration = pc; + if (pc.RoundTripTimeLimits!=null) + { + Pinger.RoundTripTimeLimits = pc.RoundTripTimeLimits; + Pinger.MaxRoundTripTimeoutCategory = pc.RoundTripTimeLimits.Last(); + Pinger.RoundTripTimeyCategoryLimits = pc.RoundTripTimeyCategoryLimits; + } } + /// + /// A maximális ping timeout kategória értéke + /// + public static int MaxRoundTripTimeoutCategory = 5000; + + /// + /// A FINOM válaszidő kategóriákat tartalmazza; egy válasz az i. válaszidő kategóriába tartozik, ha a pontos válaszidő nagyobb, vagy egyenlő, + /// mint az i. elem értéke, de kisebb, mint az i+1. elem értéke.A sor első elemének értéke mindig 0!!!! + /// Ha a sor értékei: 0:0,1:100,2:200,3:300,4:400,5:500, a pontos válaszidő 350, akkor ez a 2. kategóriába tartozik, ha pontos válaszidő. + /// + public static List RoundTripTimeLimits = new List { 0, 25, 50, 75, 100, 150, 200, 250, 300, 400, 500, 750, 1000, 1250, 1500, 1750, 2000, 2500, 3000, 3500, 4000, 4500, Pinger.MaxRoundTripTimeoutCategory, }; + + /// + /// A DURVA válaszidő kategóriákat tartalmazza; egy válasz az i. válaszidő kategóriába tartozik, ha a pontos válaszidő nagyobb, vagy egyenlő, + /// mint az i. elem értéke, de kisebb, mint az i+1. elem értéke.A sor első elemének értéke mindig 0!!!! + /// Ha a sor értékei: 0:0,1:100,2:200,3:300,4:400,5:500, a pontos válaszidő 350, akkor ez a 2. kategóriába tartozik, ha pontos válaszidő. + /// + public static List RoundTripTimeyCategoryLimits = new List { 0, 50, 250, 750, }; /// /// A pinger indítása/újraindítása; elindítja a ping ciklus időzítőt, és elkezdi/folytatja a ping státusz adatok letárolását @@ -88,6 +112,12 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS this.PingCycleNumberOfPackages = pc.pingcyclenumofpackages; this.PingerActiveLength = pc.pingeractivlength; this.History.SetHistoryLength(pc.pingerhistorylength); + if (pc.RoundTripTimeLimits != null) + { + Pinger.RoundTripTimeLimits = pc.RoundTripTimeLimits; + Pinger.MaxRoundTripTimeoutCategory = pc.RoundTripTimeLimits.Last(); + Pinger.RoundTripTimeyCategoryLimits = pc.RoundTripTimeyCategoryLimits; + } } } } @@ -234,12 +264,14 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS { if (pingerconfig != null) { - var _pingtimeout = GetPositiveIntFromXml(PINGTIMEOUT, pingerconfig, DEFAULT_PINGTIMEOUT); - var _pingcyclefrequency = GetPositiveIntFromXml(PINGCYCLEFREQUENCY, pingerconfig, 0); - var _pingcyclenumofpackages = GetPositiveIntFromXml(PINGCYCLENUMOFPACKAGES, pingerconfig, DEFAULT_PINGCYCLENUMOFPACKAGES); - var _pingeractivlength = GetPositiveIntFromXml(PINGERACTIVELENGTHTOSTOPPERIOD, pingerconfig, DEFAULT_PINGERACTIVELENGTH); - var _pingerhistorylength = GetPositiveIntFromXml(PINGERHISTORYLENGTH, pingerconfig, DEFAULT_PINGERHISTORYLENGTH); - SetValues(_pingtimeout, _pingcyclefrequency, _pingcyclenumofpackages, _pingeractivlength, _pingerhistorylength); + var _pingtimeout = GetPositiveIntFromXml(PINGTIMEOUT, pingerconfig); + var _pingcyclefrequency = GetPositiveIntFromXml(PINGCYCLEFREQUENCY, pingerconfig); + var _pingcyclenumofpackages = GetPositiveIntFromXml(PINGCYCLENUMOFPACKAGES, pingerconfig); + var _pingerlifetime = GetPositiveIntFromXml(PINGERACTIVELENGTHTOSTOPPERIOD, pingerconfig); + var _pingerhistorylength = GetPositiveIntFromXml(PINGERHISTORYLENGTH, pingerconfig); + var _roundtriptimelimits = pingerconfig.Element(ROUNDTRIPTIMELIMITS)?.Value; + var _roundtriptimecategorylimits = pingerconfig.Element(ROUNDTRIPTIMECATEGORYLIMITS)?.Value; + SetValues(_pingtimeout, _pingcyclefrequency, _pingcyclenumofpackages, _pingerlifetime, _pingerhistorylength, _roundtriptimelimits, _roundtriptimecategorylimits); } else { SetValues(); } } @@ -252,9 +284,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS /// pcs /// minutes /// minutes - public PingerConfig(int pingtimeout = 0, int pingcyclefrequency = 0, int pingcyclenumofpackages = 0, int pingeractivelength = 0, int pingerhistorylength = 0) + public PingerConfig(int pingtimeout = 0, int pingcyclefrequency = 0, int pingcyclenumofpackages = 0, int pingeractivelength = 0, int pingerhistorylength = 0,string rttlimits=null, string rttcatlimits=null) { - SetValues(pingtimeout, pingcyclefrequency, pingcyclenumofpackages, pingeractivelength, pingerhistorylength); + SetValues(pingtimeout, pingcyclefrequency, pingcyclenumofpackages, pingeractivelength, pingerhistorylength, rttlimits , rttcatlimits); } /// @@ -265,15 +297,40 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS /// pcs /// minutes /// minutes - private void SetValues(int pingtimeout = 0, int pingcyclefrequency = 0, int pingcyclenumofpackages = 0, int pingeractivelength = 0, int pingerhistorylength = 0) + private void SetValues(int pingtimeout = 0, int pingcyclefrequency = 0, int pingcyclenumofpackages = 0, int pingeractivelength = 0, int pingerhistorylength = 0, string rttlimits = null, string rttcatlimits = null) { - this.pingtimeout = pingtimeout <= 0 ? PingerConfig.DEFAULT_PINGTIMEOUT : pingtimeout; - this.pingcyclefrequency = pingcyclefrequency * 1000; - if (this.pingcyclefrequency < this.pingtimeout) { this.pingcyclefrequency = this.pingtimeout; } this.pingcyclenumofpackages = pingcyclenumofpackages <= 0 ? PingerConfig.DEFAULT_PINGCYCLENUMOFPACKAGES : pingcyclenumofpackages; this.pingeractivlength = (pingeractivelength <= 0 ? PingerConfig.DEFAULT_PINGERACTIVELENGTH : pingeractivelength) * 60 * 1000; this.pingerhistorylength = (pingerhistorylength <= 0 ? PingerConfig.DEFAULT_PINGERHISTORYLENGTH : pingerhistorylength) * 60 * 1000; + + try + { + // ha a megadott sor nem ok, akkor nem változtat a default-on + List rttl = rttlimits.Split(new char[] { ' ', ',', ';', '/', }, StringSplitOptions.RemoveEmptyEntries).ToList().Select(x => int.Parse(x)).ToList(); + if (rttl.Count <4) { throw new Exception(); } + if (rttl.ElementAt(0) != 0) { throw new Exception(); } + int lastelementvalue = -1; + for(var i=0;i rttcl = rttcatlimits.Split(new char[] { ' ', ',', ';', '/', }, StringSplitOptions.RemoveEmptyEntries).ToList().Select(x => int.Parse(x)).ToList(); + if (rttcl.Count != 4) { throw new Exception(); } + if (rttcl.ElementAt(0) != 0) { throw new Exception(); } + lastelementvalue = -1; + for (var i = 0; i < rttcl.Count; i++) { if (rttcl.ElementAt(i) <= lastelementvalue) { throw new Exception(); } lastelementvalue = rttcl.ElementAt(i); } + + this.RoundTripTimeLimits = rttl; + this.RoundTripTimeyCategoryLimits = rttcl; + } + catch + { + this.RoundTripTimeLimits = Pinger.RoundTripTimeLimits; + this.RoundTripTimeyCategoryLimits = Pinger.RoundTripTimeyCategoryLimits; + } + this.pingtimeout = pingtimeout <= 0 ? rttlimits.Last() : pingtimeout; + this.pingcyclefrequency = pingcyclefrequency * 1000; + if (this.pingcyclefrequency < this.pingtimeout) { this.pingcyclefrequency = this.pingtimeout; } } + /// /// Egy int értéket kiemel a megadott xml struktúrából, ha nincs ott a keresett érték, /// vagy nem integer, vagy nem pozitív, akkor az alapértelmezést adja vissza @@ -282,7 +339,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS /// az xml struktúra /// az alapértelmezett érték /// - private static int GetPositiveIntFromXml(string xname, XElement pingerconfig, int defaultvalue) + private static int GetPositiveIntFromXml(string xname, XElement pingerconfig, int defaultvalue=0) { string valstr = pingerconfig?.Element(XName.Get(xname))?.Value; int val = defaultvalue; @@ -290,6 +347,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS return val; } + public List RoundTripTimeLimits=null; + public List RoundTripTimeyCategoryLimits=null; public int pingtimeout; public int pingcyclefrequency; public int pingcyclenumofpackages; @@ -301,7 +360,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS const string PINGCYCLENUMOFPACKAGES = "PingCycleNumOfPackages"; const string PINGERACTIVELENGTHTOSTOPPERIOD = "PingerActiveLength"; const string PINGERHISTORYLENGTH = "PingerHistoryLength"; - public const int DEFAULT_PINGTIMEOUT = PingCycle.MAXROUNDTRIPTIMEOUTCATEGORY; + const string ROUNDTRIPTIMELIMITS = "RoundTripTimeLimits"; + const string ROUNDTRIPTIMECATEGORYLIMITS = "RoundTripCategoryLimits"; + public const int DEFAULT_PINGTIMEOUT = 0; public const int DEFAULT_PINGCYCLENUMOFPACKAGES = 4; public const int DEFAULT_PINGERACTIVELENGTH = 60; public const int DEFAULT_PINGERHISTORYLENGTH = 60; @@ -380,6 +441,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS this.LastPingCycle.RoundtripTimeAverage = totalrtt / this.LastPingCycle.NumberOfCycles; this.LastPingCycle.PackagesSent += newpc.PackagesSent; this.LastPingCycle.PackagesLost += newpc.PackagesLost; + this.LastPingCycle.PackagesSentCategory = this.LastPingCycle.GetLostPackageCategory(); this.LastPingCycle.LastTimestamp = newpc.StartTimestamp; if (newpc.RoundtripTimeMax != -1 && this.LastPingCycle.RoundtripTimeMax != -1) { @@ -400,12 +462,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS firstelement.NumberOfCycles = (int)((double)firstelement.NumberOfCycles * partiallength / fulllength); if (firstelement.NumberOfCycles == 0 || firstelement.PackagesSent == 0) { this.PingStateQueue.Remove(firstelement); firstelement = this.PingStateQueue.FirstOrDefault(); } - var packagelostratio = firstelement.PackagesLost / firstelement.PackagesSent; - firstelement.PackagesSentCategory = - packagelostratio == 0 ? PingCycle.LostPackageCategory.Excellent - : packagelostratio < 0.1 ? PingCycle.LostPackageCategory.Good - : packagelostratio < 0.3 ? PingCycle.LostPackageCategory.Acceptable - : PingCycle.LostPackageCategory.Bad; + firstelement.PackagesSentCategory = firstelement.GetLostPackageCategory(); firstelement.StartTimestamp = borderts; } StartTime = firstelement?.StartTimestamp ?? DateTime.MaxValue; @@ -457,17 +514,15 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS this.PackagesSentCategory = pc.PackagesSentCategory; this.NumberOfCycles = pc.NumberOfCycles; this.StatusCategory = pc.StatusCategory; + this.RoundtripTime = pc.RoundtripTime; this.RoundtripTimeAverage = pc.RoundtripTimeAverage; this.RoundtripTimeMax = pc.RoundtripTimeMax; this.RoundtripTimeMin= pc.RoundtripTimeMin; + this.RoundtripTimeCategory = pc.RoundtripTimeCategory; } #region public fields,enums /// - /// A maximális ping timeout kategória értéke - /// - public const int MAXROUNDTRIPTIMEOUTCATEGORY = 5000; - /// /// A Ping állapot ezen időpillanattól kezdődően állt/áll fenn /// public DateTime StartTimestamp; @@ -553,15 +608,19 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS { this.StartTimestamp = DateTime.Now; this.LastTimestamp = this.StartTimestamp; + PingReply pr; for (var i = 0; i < this.PackagesSent; i++) { - var pr = PingTool.Ping(this.HostNameOrAddress, (int)PingTimeout);//egy ping kérés feladása + pr = null; + try { pr = PingTool.Ping(this.HostNameOrAddress, (int)PingTimeout); }//egy ping kérés feladása + catch { } AddResponse(pr, i + 1);//a ping válasz "bedolgozása" a pingciklus-állapotba } - - this.RoundtripTime = RoundTripTimeLimits.LastOrDefault(x => x <= this.RoundtripTimeAverage); - var RoundTripTimeyCategoryValue = RoundTripTimeyCategoryLimits.LastOrDefault(x => x < this.RoundtripTimeAverage); - var RoundTripTimeyCategoryIndex = RoundTripTimeyCategoryLimits.FindIndex(x => x == RoundTripTimeyCategoryValue); + + this.PackagesSentCategory = GetLostPackageCategory(); + this.RoundtripTime = Pinger.RoundTripTimeLimits.LastOrDefault(x => x <= this.RoundtripTimeAverage); + var RoundTripTimeyCategoryValue = Pinger.RoundTripTimeyCategoryLimits.LastOrDefault(x => x < this.RoundtripTimeAverage); + var RoundTripTimeyCategoryIndex = Pinger.RoundTripTimeyCategoryLimits.FindIndex(x => x == RoundTripTimeyCategoryValue); this.RoundtripTimeCategory = RoundTripTimeyCategoryIndex == 0 ? RoundTripTimeCategory.Q1 : RoundTripTimeyCategoryIndex == 1 ? RoundTripTimeCategory.Q2 : RoundTripTimeyCategoryIndex == 2 ? RoundTripTimeCategory.Q3 @@ -576,19 +635,6 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS /// private string HostNameOrAddress; /// - /// A FINOM válaszidő kategóriákat tartalmazza; egy válasz az i. válaszidő kategóriába tartozik, ha a pontos válaszidő nagyobb, vagy egyenlő, - /// mint az i. elem értéke, de kisebb, mint az i+1. elem értéke.A sor első elemének értéke mindig 0!!!! - /// Ha a sor értékei: 0:0,1:100,2:200,3:300,4:400,5:500, a pontos válaszidő 350, akkor ez a 2. kategóriába tartozik, ha pontos válaszidő. - /// - private static List RoundTripTimeLimits = new List { 0, 25, 50, 75, 100, 150, 200, 250, 300, 400, 500, 750, 1000, 1250, 1500, 1750, 2000, 2500, 3000, 3500, 4000, 4500, PingCycle.MAXROUNDTRIPTIMEOUTCATEGORY, }; - - /// - /// A DURVA válaszidő kategóriákat tartalmazza; egy válasz az i. válaszidő kategóriába tartozik, ha a pontos válaszidő nagyobb, vagy egyenlő, - /// mint az i. elem értéke, de kisebb, mint az i+1. elem értéke.A sor első elemének értéke mindig 0!!!! - /// Ha a sor értékei: 0:0,1:100,2:200,3:300,4:400,5:500, a pontos válaszidő 350, akkor ez a 2. kategóriába tartozik, ha pontos válaszidő. - /// - private static List RoundTripTimeyCategoryLimits = new List { 0, 50, 250, 750, }; - /// /// Az egyes ping kérések timeout-ja /// private int PingTimeout; @@ -610,13 +656,30 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS else { this.PackagesLost++; } if (ipsCat < this.StatusCategory) { this.StatusCategory = ipsCat; }// a legjobb státuszt tárolja } + + /// + /// Visszaadja az elveszett és összes csomagok száma alapján a lostpackagecategory értéket + /// + /// az elveszett csomagok száma + /// az összes csomagok száma + /// + public LostPackageCategory GetLostPackageCategory() + { + double packagelostratio = (double)this.PackagesLost / (double)this.PackagesSent; + return packagelostratio == 0 ? PingCycle.LostPackageCategory.Excellent + : packagelostratio < 0.1 ? PingCycle.LostPackageCategory.Good + : packagelostratio < 0.3 ? PingCycle.LostPackageCategory.Acceptable + : PingCycle.LostPackageCategory.Bad; + } /// /// Visszaadja, hogy a PingReply adat alapján a válasz melyik státusz kategóriába tartozik /// /// /// - private IPStatusCategory GetIPStatusCategory(PingReply pr) + private static IPStatusCategory GetIPStatusCategory(PingReply pr) { + //if (new Random().Next(0, 9) < 3) { return IPStatusCategory.Failed; } + if (pr == null) { return IPStatusCategory.Failed; } switch (pr.Status) { case IPStatus.Success: return IPStatusCategory.Success;//Success = 0,The ICMP echo request succeeded; an ICMP echo reply was received. When you get this status code, the other System.Net.NetworkInformation.PingReply properties contain valid data. diff --git a/Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs b/Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs index 6c8ae7b..fe93cd5 100644 --- a/Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs +++ b/Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs @@ -109,11 +109,11 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS var config = (parameter as Menu.ExecutorParameter).GetConfig(); var pingerconfigxml = config.PingerConfigXml; var iplist = config.PingerIpAddressList; - DisplayPingerParameters(pingerconfigxml); var firstrun = true; var suppresserroneousipaddresses = false; while (true) { + DisplayPingerParameters(pingerconfigxml); DisplayAllPingerStatus(pingerconfigxml,iplist, suppresserroneousipaddresses); suppresserroneousipaddresses = true; if (!firstrun) { DisplayPingerCommands(); } @@ -162,15 +162,22 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS private static void DisplayPingerCommands() { - ColorConsole.WriteLine($"Enter 'START [ip address]' to start/restart pinging.", ConsoleColor.Yellow); - ColorConsole.WriteLine($"Enter 'STOP [ip address]' to stop pinging.", ConsoleColor.Yellow); - ColorConsole.WriteLine($"Enter 'DROP [ip address]' to drop collected data.", ConsoleColor.Yellow); - ColorConsole.WriteLine($"Enter 'SHOW [ip address]' to start monitoring .", ConsoleColor.Yellow); + ColorConsole.WriteLine(); + ColorConsole.WriteLine($"Pinger commands:", ConsoleColor.Yellow); + ColorConsole.WriteLine($"START", ConsoleColor.Yellow,prefix:" ",suffix: " [ip address] to start/restart pinging.",bracket:"[]"); + ColorConsole.WriteLine($"STOP", ConsoleColor.Yellow, prefix: " ", suffix: " [ip address] to stop pinging.", bracket: "[]"); + ColorConsole.WriteLine($"DROP", ConsoleColor.Yellow, prefix: " ", suffix: " [ip address] to drop collected data.", bracket: "[]"); + ColorConsole.WriteLine($"SHOW", ConsoleColor.Yellow, prefix: " ", suffix: " [ip address] to start monitoring.", bracket: "[]"); ColorConsole.WriteLine($"Set [ip address] to 'ALL' or '*' for action to all ip addresses.", ConsoleColor.Yellow); } private static void DisplayPingerParameters(XElement pingerconfigxml) { + ColorConsole.Clear(); + var pingertitle = "IP Pinger"; + ColorConsole.WriteLine(ColorConsole.WideString(pingertitle), ConsoleColor.Yellow); + ColorConsole.WriteLine(new string('-', 2*pingertitle.Length), ConsoleColor.Yellow); + ColorConsole.WriteLine(); ColorConsole.WriteLine($"Pinger configuration parameters:", ConsoleColor.Yellow); var pconfig = new Pinger("127.0.0.1", pingerconfigxml).Configuration; ColorConsole.WriteLine(pconfig.pingtimeout.ToString(), ConsoleColor.Yellow, prefix: " pingtimeout :", suffix: "ms"); @@ -178,11 +185,14 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS ColorConsole.WriteLine((pconfig.pingcyclefrequency / 1000).ToString(), ConsoleColor.Yellow, prefix: " cycle frequency:", suffix: "sec"); ColorConsole.WriteLine((pconfig.pingeractivlength / 60000).ToString(), ConsoleColor.Yellow, prefix: " pinger liftime :", suffix: "min"); ColorConsole.WriteLine((pconfig.pingerhistorylength / 60000).ToString(), ConsoleColor.Yellow, prefix: " history length :", suffix: "min"); - ColorConsole.WriteLine($"Pinger status for the following addresses:", ConsoleColor.Yellow); + var rttlstring = (string.Join(",", pconfig.RoundTripTimeLimits)).ToString(); + ColorConsole.WriteLine(rttlstring.Substring(0, rttlstring.Length>20?20: rttlstring.Length) + (rttlstring.Length > 20 ? "..." : ""), ConsoleColor.Yellow, prefix: " roundtrip time limit values :", suffix: "ms"); + ColorConsole.WriteLine((string.Join(",", pconfig.RoundTripTimeyCategoryLimits)).ToString(), ConsoleColor.Yellow, prefix: " roundtrip time category limit values:", suffix: "ms"); } private static void DisplayPingerHistory(List selectedpingers) { ColorConsole.WriteLine(); + ColorConsole.WriteLine($"Pinger History:", ConsoleColor.Yellow); var cursorleftposition = ColorConsole.CursorLeft; var cursortopposition = ColorConsole.CursorTop; while (true) @@ -202,8 +212,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS { var _h = pinger.GetHistory(); if (_h == null) { return 0; } - var h = new Pinger.PingHistory(pinger.GetHistory());//klónozzuk, mert egyébként ha az adatgyűjtés miatt megváltozik akkor exception-re fut a foreach - ColorConsole.Write(pinger.HostNameOrAddress, ConsoleColor.Yellow, suffix: ": "); + var h = new Pinger.PingHistory(_h);//klónozzuk, mert egyébként ha az adatgyűjtés miatt megváltozik akkor exception-re fut a foreach + ColorConsole.Write(pinger.HostNameOrAddress, ConsoleColor.Yellow, suffix: ": ",prefix:" "); var pingerstatus = pinger.Operating ? "pinging" : "still"; var pingerstatuscolor = pinger.Operating ? ConsoleColor.Green : ConsoleColor.Yellow; ColorConsole.Write(pingerstatus.PadRight(10), pingerstatuscolor); @@ -212,7 +222,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS if (lc != null) { var responseinfo = lc.StatusCategory != Pinger.PingCycle.IPStatusCategory.Success ? $"{lc.StatusCategory}" : $"RT:{lc.RoundtripTime} [{lc.RoundtripTimeMin}<{lc.RoundtripTimeAverage}<{lc.RoundtripTimeMax}]ms, LP:{lc.PackagesSentCategory}"; - responseinfo=responseinfo.PadRight(35)+" "; + responseinfo=responseinfo.PadRight(40)+" "; ColorConsole.Write(responseinfo, GetPingCycleDisplayColor(lc)); foreach (var he in h.PingStateQueue) @@ -227,7 +237,12 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS ColorConsole.WriteLine(); return h.PingCycleFrequency; } - private static string GetPingCycleDisplayCharacter(Pinger.PingCycle he) { return he.StatusCategory != Pinger.PingCycle.IPStatusCategory.Success ? "9" : he.RoundtripTimeCategory.ToString().Substring(1); } + private static string GetPingCycleDisplayCharacter(Pinger.PingCycle he) + { + return he.StatusCategory != Pinger.PingCycle.IPStatusCategory.Success + ? "9" + : he.RoundtripTimeCategory.ToString().Substring(1); + } private static ConsoleColor GetPingCycleDisplayColor(Pinger.PingCycle pingcycle) { return pingcycle.StatusCategory != Pinger.PingCycle.IPStatusCategory.Success ? ConsoleColor.Red @@ -239,13 +254,15 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS } private static void DisplayAllPingerStatus(XElement pingerconfigxml,List iplist, bool suppresserroneousipaddresses=false) { + ColorConsole.WriteLine(); + ColorConsole.WriteLine($"Pinger status for the following addresses:", ConsoleColor.Yellow); foreach (var ip in iplist) { DisplayOnePingerStatus(ip, pingerconfigxml, suppresserroneousipaddresses); } } private static void DisplayOnePingerStatus(MaintenanceToolsXmlProcessor.IPAddressParsingResult ip, XElement pingerconfigxml,bool suppresserroneousipaddresses = false) { if (ip.GoodIP) { - ColorConsole.Write($"{ip.IP}", ConsoleColor.Green); + ColorConsole.Write($"{ip.IP}", ConsoleColor.Green,prefix:" "); var pingerlist = PingerList.Select(x => x.HostNameOrAddress).ToList(); Pinger pinger; diff --git a/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs b/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs index 75b1382..129a57d 100644 --- a/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs +++ b/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.8.0.0")] -[assembly: AssemblyFileVersion("1.8.0.0")] +[assembly: AssemblyVersion("1.8.1.0")] +[assembly: AssemblyFileVersion("1.8.1.0")] -- libgit2 0.21.2