Commit bea496aa3383b137cfc434a5dd47f88d6edad80d
1 parent
ca5e6d7e
v1.8.1
- pinger javítgatása
Showing
3 changed files
with
136 additions
and
56 deletions
Show diff stats
Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools - TcpIp.cs
| ... | ... | @@ -41,7 +41,31 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS |
| 41 | 41 | this.PingCycleNumberOfPackages = pc.pingcyclenumofpackages; |
| 42 | 42 | this.PingerActiveLength = pc.pingeractivlength; |
| 43 | 43 | this.Configuration = pc; |
| 44 | + if (pc.RoundTripTimeLimits!=null) | |
| 45 | + { | |
| 46 | + Pinger.RoundTripTimeLimits = pc.RoundTripTimeLimits; | |
| 47 | + Pinger.MaxRoundTripTimeoutCategory = pc.RoundTripTimeLimits.Last(); | |
| 48 | + Pinger.RoundTripTimeyCategoryLimits = pc.RoundTripTimeyCategoryLimits; | |
| 49 | + } | |
| 44 | 50 | } |
| 51 | + /// <summary> | |
| 52 | + /// A maximális ping timeout kategória értéke | |
| 53 | + /// </summary> | |
| 54 | + public static int MaxRoundTripTimeoutCategory = 5000; | |
| 55 | + | |
| 56 | + /// <summary> | |
| 57 | + /// 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ő, | |
| 58 | + /// mint az i. elem értéke, de kisebb, mint az i+1. elem értéke.A sor első elemének értéke mindig 0!!!! | |
| 59 | + /// 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ő. | |
| 60 | + /// </summary> | |
| 61 | + public static List<int> RoundTripTimeLimits = new List<int> { 0, 25, 50, 75, 100, 150, 200, 250, 300, 400, 500, 750, 1000, 1250, 1500, 1750, 2000, 2500, 3000, 3500, 4000, 4500, Pinger.MaxRoundTripTimeoutCategory, }; | |
| 62 | + | |
| 63 | + /// <summary> | |
| 64 | + /// 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ő, | |
| 65 | + /// mint az i. elem értéke, de kisebb, mint az i+1. elem értéke.A sor első elemének értéke mindig 0!!!! | |
| 66 | + /// 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ő. | |
| 67 | + /// </summary> | |
| 68 | + public static List<int> RoundTripTimeyCategoryLimits = new List<int> { 0, 50, 250, 750, }; | |
| 45 | 69 | |
| 46 | 70 | /// <summary> |
| 47 | 71 | /// 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 |
| 88 | 112 | this.PingCycleNumberOfPackages = pc.pingcyclenumofpackages; |
| 89 | 113 | this.PingerActiveLength = pc.pingeractivlength; |
| 90 | 114 | this.History.SetHistoryLength(pc.pingerhistorylength); |
| 115 | + if (pc.RoundTripTimeLimits != null) | |
| 116 | + { | |
| 117 | + Pinger.RoundTripTimeLimits = pc.RoundTripTimeLimits; | |
| 118 | + Pinger.MaxRoundTripTimeoutCategory = pc.RoundTripTimeLimits.Last(); | |
| 119 | + Pinger.RoundTripTimeyCategoryLimits = pc.RoundTripTimeyCategoryLimits; | |
| 120 | + } | |
| 91 | 121 | } |
| 92 | 122 | } |
| 93 | 123 | } |
| ... | ... | @@ -234,12 +264,14 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS |
| 234 | 264 | { |
| 235 | 265 | if (pingerconfig != null) |
| 236 | 266 | { |
| 237 | - var _pingtimeout = GetPositiveIntFromXml(PINGTIMEOUT, pingerconfig, DEFAULT_PINGTIMEOUT); | |
| 238 | - var _pingcyclefrequency = GetPositiveIntFromXml(PINGCYCLEFREQUENCY, pingerconfig, 0); | |
| 239 | - var _pingcyclenumofpackages = GetPositiveIntFromXml(PINGCYCLENUMOFPACKAGES, pingerconfig, DEFAULT_PINGCYCLENUMOFPACKAGES); | |
| 240 | - var _pingeractivlength = GetPositiveIntFromXml(PINGERACTIVELENGTHTOSTOPPERIOD, pingerconfig, DEFAULT_PINGERACTIVELENGTH); | |
| 241 | - var _pingerhistorylength = GetPositiveIntFromXml(PINGERHISTORYLENGTH, pingerconfig, DEFAULT_PINGERHISTORYLENGTH); | |
| 242 | - SetValues(_pingtimeout, _pingcyclefrequency, _pingcyclenumofpackages, _pingeractivlength, _pingerhistorylength); | |
| 267 | + var _pingtimeout = GetPositiveIntFromXml(PINGTIMEOUT, pingerconfig); | |
| 268 | + var _pingcyclefrequency = GetPositiveIntFromXml(PINGCYCLEFREQUENCY, pingerconfig); | |
| 269 | + var _pingcyclenumofpackages = GetPositiveIntFromXml(PINGCYCLENUMOFPACKAGES, pingerconfig); | |
| 270 | + var _pingerlifetime = GetPositiveIntFromXml(PINGERACTIVELENGTHTOSTOPPERIOD, pingerconfig); | |
| 271 | + var _pingerhistorylength = GetPositiveIntFromXml(PINGERHISTORYLENGTH, pingerconfig); | |
| 272 | + var _roundtriptimelimits = pingerconfig.Element(ROUNDTRIPTIMELIMITS)?.Value; | |
| 273 | + var _roundtriptimecategorylimits = pingerconfig.Element(ROUNDTRIPTIMECATEGORYLIMITS)?.Value; | |
| 274 | + SetValues(_pingtimeout, _pingcyclefrequency, _pingcyclenumofpackages, _pingerlifetime, _pingerhistorylength, _roundtriptimelimits, _roundtriptimecategorylimits); | |
| 243 | 275 | } |
| 244 | 276 | else { SetValues(); } |
| 245 | 277 | } |
| ... | ... | @@ -252,9 +284,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS |
| 252 | 284 | /// <param name="pingcyclenumofpackages">pcs</param> |
| 253 | 285 | /// <param name="pingeractivelength">minutes</param> |
| 254 | 286 | /// <param name="pingerhistorylength">minutes</param> |
| 255 | - public PingerConfig(int pingtimeout = 0, int pingcyclefrequency = 0, int pingcyclenumofpackages = 0, int pingeractivelength = 0, int pingerhistorylength = 0) | |
| 287 | + public PingerConfig(int pingtimeout = 0, int pingcyclefrequency = 0, int pingcyclenumofpackages = 0, int pingeractivelength = 0, int pingerhistorylength = 0,string rttlimits=null, string rttcatlimits=null) | |
| 256 | 288 | { |
| 257 | - SetValues(pingtimeout, pingcyclefrequency, pingcyclenumofpackages, pingeractivelength, pingerhistorylength); | |
| 289 | + SetValues(pingtimeout, pingcyclefrequency, pingcyclenumofpackages, pingeractivelength, pingerhistorylength, rttlimits , rttcatlimits); | |
| 258 | 290 | } |
| 259 | 291 | |
| 260 | 292 | /// <summary> |
| ... | ... | @@ -265,15 +297,40 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS |
| 265 | 297 | /// <param name="pingcyclenumofpackages">pcs</param> |
| 266 | 298 | /// <param name="pingeractivelength">minutes</param> |
| 267 | 299 | /// <param name="pingerhistorylength">minutes</param> |
| 268 | - private void SetValues(int pingtimeout = 0, int pingcyclefrequency = 0, int pingcyclenumofpackages = 0, int pingeractivelength = 0, int pingerhistorylength = 0) | |
| 300 | + private void SetValues(int pingtimeout = 0, int pingcyclefrequency = 0, int pingcyclenumofpackages = 0, int pingeractivelength = 0, int pingerhistorylength = 0, string rttlimits = null, string rttcatlimits = null) | |
| 269 | 301 | { |
| 270 | - this.pingtimeout = pingtimeout <= 0 ? PingerConfig.DEFAULT_PINGTIMEOUT : pingtimeout; | |
| 271 | - this.pingcyclefrequency = pingcyclefrequency * 1000; | |
| 272 | - if (this.pingcyclefrequency < this.pingtimeout) { this.pingcyclefrequency = this.pingtimeout; } | |
| 273 | 302 | this.pingcyclenumofpackages = pingcyclenumofpackages <= 0 ? PingerConfig.DEFAULT_PINGCYCLENUMOFPACKAGES : pingcyclenumofpackages; |
| 274 | 303 | this.pingeractivlength = (pingeractivelength <= 0 ? PingerConfig.DEFAULT_PINGERACTIVELENGTH : pingeractivelength) * 60 * 1000; |
| 275 | 304 | this.pingerhistorylength = (pingerhistorylength <= 0 ? PingerConfig.DEFAULT_PINGERHISTORYLENGTH : pingerhistorylength) * 60 * 1000; |
| 305 | + | |
| 306 | + try | |
| 307 | + { | |
| 308 | + // ha a megadott sor nem ok, akkor nem változtat a default-on | |
| 309 | + List<int> rttl = rttlimits.Split(new char[] { ' ', ',', ';', '/', }, StringSplitOptions.RemoveEmptyEntries).ToList().Select(x => int.Parse(x)).ToList(); | |
| 310 | + if (rttl.Count <4) { throw new Exception(); } | |
| 311 | + if (rttl.ElementAt(0) != 0) { throw new Exception(); } | |
| 312 | + int lastelementvalue = -1; | |
| 313 | + for(var i=0;i<rttl.Count;i++) { if (rttl.ElementAt(i) <= lastelementvalue) { throw new Exception(); } lastelementvalue=rttl.ElementAt(i); } | |
| 314 | + | |
| 315 | + List<int> rttcl = rttcatlimits.Split(new char[] { ' ', ',', ';', '/', }, StringSplitOptions.RemoveEmptyEntries).ToList().Select(x => int.Parse(x)).ToList(); | |
| 316 | + if (rttcl.Count != 4) { throw new Exception(); } | |
| 317 | + if (rttcl.ElementAt(0) != 0) { throw new Exception(); } | |
| 318 | + lastelementvalue = -1; | |
| 319 | + for (var i = 0; i < rttcl.Count; i++) { if (rttcl.ElementAt(i) <= lastelementvalue) { throw new Exception(); } lastelementvalue = rttcl.ElementAt(i); } | |
| 320 | + | |
| 321 | + this.RoundTripTimeLimits = rttl; | |
| 322 | + this.RoundTripTimeyCategoryLimits = rttcl; | |
| 323 | + } | |
| 324 | + catch | |
| 325 | + { | |
| 326 | + this.RoundTripTimeLimits = Pinger.RoundTripTimeLimits; | |
| 327 | + this.RoundTripTimeyCategoryLimits = Pinger.RoundTripTimeyCategoryLimits; | |
| 328 | + } | |
| 329 | + this.pingtimeout = pingtimeout <= 0 ? rttlimits.Last() : pingtimeout; | |
| 330 | + this.pingcyclefrequency = pingcyclefrequency * 1000; | |
| 331 | + if (this.pingcyclefrequency < this.pingtimeout) { this.pingcyclefrequency = this.pingtimeout; } | |
| 276 | 332 | } |
| 333 | + | |
| 277 | 334 | /// <summary> |
| 278 | 335 | /// Egy int értéket kiemel a megadott xml struktúrából, ha nincs ott a keresett érték, |
| 279 | 336 | /// vagy nem integer, vagy nem pozitív, akkor az alapértelmezést adja vissza |
| ... | ... | @@ -282,7 +339,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS |
| 282 | 339 | /// <param name="pingerconfig">az xml struktúra</param> |
| 283 | 340 | /// <param name="defaultvalue">az alapértelmezett érték</param> |
| 284 | 341 | /// <returns></returns> |
| 285 | - private static int GetPositiveIntFromXml(string xname, XElement pingerconfig, int defaultvalue) | |
| 342 | + private static int GetPositiveIntFromXml(string xname, XElement pingerconfig, int defaultvalue=0) | |
| 286 | 343 | { |
| 287 | 344 | string valstr = pingerconfig?.Element(XName.Get(xname))?.Value; |
| 288 | 345 | int val = defaultvalue; |
| ... | ... | @@ -290,6 +347,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS |
| 290 | 347 | return val; |
| 291 | 348 | } |
| 292 | 349 | |
| 350 | + public List<int> RoundTripTimeLimits=null; | |
| 351 | + public List<int> RoundTripTimeyCategoryLimits=null; | |
| 293 | 352 | public int pingtimeout; |
| 294 | 353 | public int pingcyclefrequency; |
| 295 | 354 | public int pingcyclenumofpackages; |
| ... | ... | @@ -301,7 +360,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS |
| 301 | 360 | const string PINGCYCLENUMOFPACKAGES = "PingCycleNumOfPackages"; |
| 302 | 361 | const string PINGERACTIVELENGTHTOSTOPPERIOD = "PingerActiveLength"; |
| 303 | 362 | const string PINGERHISTORYLENGTH = "PingerHistoryLength"; |
| 304 | - public const int DEFAULT_PINGTIMEOUT = PingCycle.MAXROUNDTRIPTIMEOUTCATEGORY; | |
| 363 | + const string ROUNDTRIPTIMELIMITS = "RoundTripTimeLimits"; | |
| 364 | + const string ROUNDTRIPTIMECATEGORYLIMITS = "RoundTripCategoryLimits"; | |
| 365 | + public const int DEFAULT_PINGTIMEOUT = 0; | |
| 305 | 366 | public const int DEFAULT_PINGCYCLENUMOFPACKAGES = 4; |
| 306 | 367 | public const int DEFAULT_PINGERACTIVELENGTH = 60; |
| 307 | 368 | public const int DEFAULT_PINGERHISTORYLENGTH = 60; |
| ... | ... | @@ -380,6 +441,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS |
| 380 | 441 | this.LastPingCycle.RoundtripTimeAverage = totalrtt / this.LastPingCycle.NumberOfCycles; |
| 381 | 442 | this.LastPingCycle.PackagesSent += newpc.PackagesSent; |
| 382 | 443 | this.LastPingCycle.PackagesLost += newpc.PackagesLost; |
| 444 | + this.LastPingCycle.PackagesSentCategory = this.LastPingCycle.GetLostPackageCategory(); | |
| 383 | 445 | this.LastPingCycle.LastTimestamp = newpc.StartTimestamp; |
| 384 | 446 | if (newpc.RoundtripTimeMax != -1 && this.LastPingCycle.RoundtripTimeMax != -1) |
| 385 | 447 | { |
| ... | ... | @@ -400,12 +462,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS |
| 400 | 462 | firstelement.NumberOfCycles = (int)((double)firstelement.NumberOfCycles * partiallength / fulllength); |
| 401 | 463 | if (firstelement.NumberOfCycles == 0 || firstelement.PackagesSent == 0) { this.PingStateQueue.Remove(firstelement); firstelement = this.PingStateQueue.FirstOrDefault(); } |
| 402 | 464 | |
| 403 | - var packagelostratio = firstelement.PackagesLost / firstelement.PackagesSent; | |
| 404 | - firstelement.PackagesSentCategory = | |
| 405 | - packagelostratio == 0 ? PingCycle.LostPackageCategory.Excellent | |
| 406 | - : packagelostratio < 0.1 ? PingCycle.LostPackageCategory.Good | |
| 407 | - : packagelostratio < 0.3 ? PingCycle.LostPackageCategory.Acceptable | |
| 408 | - : PingCycle.LostPackageCategory.Bad; | |
| 465 | + firstelement.PackagesSentCategory = firstelement.GetLostPackageCategory(); | |
| 409 | 466 | firstelement.StartTimestamp = borderts; |
| 410 | 467 | } |
| 411 | 468 | StartTime = firstelement?.StartTimestamp ?? DateTime.MaxValue; |
| ... | ... | @@ -457,17 +514,15 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS |
| 457 | 514 | this.PackagesSentCategory = pc.PackagesSentCategory; |
| 458 | 515 | this.NumberOfCycles = pc.NumberOfCycles; |
| 459 | 516 | this.StatusCategory = pc.StatusCategory; |
| 517 | + this.RoundtripTime = pc.RoundtripTime; | |
| 460 | 518 | this.RoundtripTimeAverage = pc.RoundtripTimeAverage; |
| 461 | 519 | this.RoundtripTimeMax = pc.RoundtripTimeMax; |
| 462 | 520 | this.RoundtripTimeMin= pc.RoundtripTimeMin; |
| 521 | + this.RoundtripTimeCategory = pc.RoundtripTimeCategory; | |
| 463 | 522 | } |
| 464 | 523 | |
| 465 | 524 | #region public fields,enums |
| 466 | 525 | /// <summary> |
| 467 | - /// A maximális ping timeout kategória értéke | |
| 468 | - /// </summary> | |
| 469 | - public const int MAXROUNDTRIPTIMEOUTCATEGORY = 5000; | |
| 470 | - /// <summary> | |
| 471 | 526 | /// A Ping állapot ezen időpillanattól kezdődően állt/áll fenn |
| 472 | 527 | /// </summary> |
| 473 | 528 | public DateTime StartTimestamp; |
| ... | ... | @@ -553,15 +608,19 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS |
| 553 | 608 | { |
| 554 | 609 | this.StartTimestamp = DateTime.Now; |
| 555 | 610 | this.LastTimestamp = this.StartTimestamp; |
| 611 | + PingReply pr; | |
| 556 | 612 | for (var i = 0; i < this.PackagesSent; i++) |
| 557 | 613 | { |
| 558 | - var pr = PingTool.Ping(this.HostNameOrAddress, (int)PingTimeout);//egy ping kérés feladása | |
| 614 | + pr = null; | |
| 615 | + try { pr = PingTool.Ping(this.HostNameOrAddress, (int)PingTimeout); }//egy ping kérés feladása | |
| 616 | + catch { } | |
| 559 | 617 | AddResponse(pr, i + 1);//a ping válasz "bedolgozása" a pingciklus-állapotba |
| 560 | 618 | } |
| 561 | - | |
| 562 | - this.RoundtripTime = RoundTripTimeLimits.LastOrDefault(x => x <= this.RoundtripTimeAverage); | |
| 563 | - var RoundTripTimeyCategoryValue = RoundTripTimeyCategoryLimits.LastOrDefault(x => x < this.RoundtripTimeAverage); | |
| 564 | - var RoundTripTimeyCategoryIndex = RoundTripTimeyCategoryLimits.FindIndex(x => x == RoundTripTimeyCategoryValue); | |
| 619 | + | |
| 620 | + this.PackagesSentCategory = GetLostPackageCategory(); | |
| 621 | + this.RoundtripTime = Pinger.RoundTripTimeLimits.LastOrDefault(x => x <= this.RoundtripTimeAverage); | |
| 622 | + var RoundTripTimeyCategoryValue = Pinger.RoundTripTimeyCategoryLimits.LastOrDefault(x => x < this.RoundtripTimeAverage); | |
| 623 | + var RoundTripTimeyCategoryIndex = Pinger.RoundTripTimeyCategoryLimits.FindIndex(x => x == RoundTripTimeyCategoryValue); | |
| 565 | 624 | this.RoundtripTimeCategory = RoundTripTimeyCategoryIndex == 0 ? RoundTripTimeCategory.Q1 |
| 566 | 625 | : RoundTripTimeyCategoryIndex == 1 ? RoundTripTimeCategory.Q2 |
| 567 | 626 | : RoundTripTimeyCategoryIndex == 2 ? RoundTripTimeCategory.Q3 |
| ... | ... | @@ -576,19 +635,6 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS |
| 576 | 635 | /// </summary> |
| 577 | 636 | private string HostNameOrAddress; |
| 578 | 637 | /// <summary> |
| 579 | - /// 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ő, | |
| 580 | - /// mint az i. elem értéke, de kisebb, mint az i+1. elem értéke.A sor első elemének értéke mindig 0!!!! | |
| 581 | - /// 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ő. | |
| 582 | - /// </summary> | |
| 583 | - private static List<int> RoundTripTimeLimits = new List<int> { 0, 25, 50, 75, 100, 150, 200, 250, 300, 400, 500, 750, 1000, 1250, 1500, 1750, 2000, 2500, 3000, 3500, 4000, 4500, PingCycle.MAXROUNDTRIPTIMEOUTCATEGORY, }; | |
| 584 | - | |
| 585 | - /// <summary> | |
| 586 | - /// 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ő, | |
| 587 | - /// mint az i. elem értéke, de kisebb, mint az i+1. elem értéke.A sor első elemének értéke mindig 0!!!! | |
| 588 | - /// 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ő. | |
| 589 | - /// </summary> | |
| 590 | - private static List<int> RoundTripTimeyCategoryLimits = new List<int> { 0, 50, 250, 750, }; | |
| 591 | - /// <summary> | |
| 592 | 638 | /// Az egyes ping kérések timeout-ja |
| 593 | 639 | /// </summary> |
| 594 | 640 | private int PingTimeout; |
| ... | ... | @@ -610,13 +656,30 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS |
| 610 | 656 | else { this.PackagesLost++; } |
| 611 | 657 | if (ipsCat < this.StatusCategory) { this.StatusCategory = ipsCat; }// a legjobb státuszt tárolja |
| 612 | 658 | } |
| 659 | + | |
| 660 | + /// <summary> | |
| 661 | + /// Visszaadja az elveszett és összes csomagok száma alapján a lostpackagecategory értéket | |
| 662 | + /// </summary> | |
| 663 | + /// <param name="packageslost">az elveszett csomagok száma</param> | |
| 664 | + /// <param name="packagessent">az összes csomagok száma</param> | |
| 665 | + /// <returns></returns> | |
| 666 | + public LostPackageCategory GetLostPackageCategory() | |
| 667 | + { | |
| 668 | + double packagelostratio = (double)this.PackagesLost / (double)this.PackagesSent; | |
| 669 | + return packagelostratio == 0 ? PingCycle.LostPackageCategory.Excellent | |
| 670 | + : packagelostratio < 0.1 ? PingCycle.LostPackageCategory.Good | |
| 671 | + : packagelostratio < 0.3 ? PingCycle.LostPackageCategory.Acceptable | |
| 672 | + : PingCycle.LostPackageCategory.Bad; | |
| 673 | + } | |
| 613 | 674 | /// <summary> |
| 614 | 675 | /// Visszaadja, hogy a PingReply adat alapján a válasz melyik státusz kategóriába tartozik |
| 615 | 676 | /// </summary> |
| 616 | 677 | /// <param name="pr"></param> |
| 617 | 678 | /// <returns></returns> |
| 618 | - private IPStatusCategory GetIPStatusCategory(PingReply pr) | |
| 679 | + private static IPStatusCategory GetIPStatusCategory(PingReply pr) | |
| 619 | 680 | { |
| 681 | + //if (new Random().Next(0, 9) < 3) { return IPStatusCategory.Failed; } | |
| 682 | + if (pr == null) { return IPStatusCategory.Failed; } | |
| 620 | 683 | switch (pr.Status) |
| 621 | 684 | { |
| 622 | 685 | 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. | ... | ... |
Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs
| ... | ... | @@ -109,11 +109,11 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS |
| 109 | 109 | var config = (parameter as Menu.ExecutorParameter).GetConfig<MaintenanceToolsXmlProcessor>(); |
| 110 | 110 | var pingerconfigxml = config.PingerConfigXml; |
| 111 | 111 | var iplist = config.PingerIpAddressList; |
| 112 | - DisplayPingerParameters(pingerconfigxml); | |
| 113 | 112 | var firstrun = true; |
| 114 | 113 | var suppresserroneousipaddresses = false; |
| 115 | 114 | while (true) |
| 116 | 115 | { |
| 116 | + DisplayPingerParameters(pingerconfigxml); | |
| 117 | 117 | DisplayAllPingerStatus(pingerconfigxml,iplist, suppresserroneousipaddresses); |
| 118 | 118 | suppresserroneousipaddresses = true; |
| 119 | 119 | if (!firstrun) { DisplayPingerCommands(); } |
| ... | ... | @@ -162,15 +162,22 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS |
| 162 | 162 | |
| 163 | 163 | private static void DisplayPingerCommands() |
| 164 | 164 | { |
| 165 | - ColorConsole.WriteLine($"Enter 'START [ip address]' to start/restart pinging.", ConsoleColor.Yellow); | |
| 166 | - ColorConsole.WriteLine($"Enter 'STOP [ip address]' to stop pinging.", ConsoleColor.Yellow); | |
| 167 | - ColorConsole.WriteLine($"Enter 'DROP [ip address]' to drop collected data.", ConsoleColor.Yellow); | |
| 168 | - ColorConsole.WriteLine($"Enter 'SHOW [ip address]' to start monitoring .", ConsoleColor.Yellow); | |
| 165 | + ColorConsole.WriteLine(); | |
| 166 | + ColorConsole.WriteLine($"Pinger commands:", ConsoleColor.Yellow); | |
| 167 | + ColorConsole.WriteLine($"START", ConsoleColor.Yellow,prefix:" ",suffix: " [ip address] to start/restart pinging.",bracket:"[]"); | |
| 168 | + ColorConsole.WriteLine($"STOP", ConsoleColor.Yellow, prefix: " ", suffix: " [ip address] to stop pinging.", bracket: "[]"); | |
| 169 | + ColorConsole.WriteLine($"DROP", ConsoleColor.Yellow, prefix: " ", suffix: " [ip address] to drop collected data.", bracket: "[]"); | |
| 170 | + ColorConsole.WriteLine($"SHOW", ConsoleColor.Yellow, prefix: " ", suffix: " [ip address] to start monitoring.", bracket: "[]"); | |
| 169 | 171 | ColorConsole.WriteLine($"Set [ip address] to 'ALL' or '*' for action to all ip addresses.", ConsoleColor.Yellow); |
| 170 | 172 | } |
| 171 | 173 | |
| 172 | 174 | private static void DisplayPingerParameters(XElement pingerconfigxml) |
| 173 | 175 | { |
| 176 | + ColorConsole.Clear(); | |
| 177 | + var pingertitle = "IP Pinger"; | |
| 178 | + ColorConsole.WriteLine(ColorConsole.WideString(pingertitle), ConsoleColor.Yellow); | |
| 179 | + ColorConsole.WriteLine(new string('-', 2*pingertitle.Length), ConsoleColor.Yellow); | |
| 180 | + ColorConsole.WriteLine(); | |
| 174 | 181 | ColorConsole.WriteLine($"Pinger configuration parameters:", ConsoleColor.Yellow); |
| 175 | 182 | var pconfig = new Pinger("127.0.0.1", pingerconfigxml).Configuration; |
| 176 | 183 | ColorConsole.WriteLine(pconfig.pingtimeout.ToString(), ConsoleColor.Yellow, prefix: " pingtimeout :", suffix: "ms"); |
| ... | ... | @@ -178,11 +185,14 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS |
| 178 | 185 | ColorConsole.WriteLine((pconfig.pingcyclefrequency / 1000).ToString(), ConsoleColor.Yellow, prefix: " cycle frequency:", suffix: "sec"); |
| 179 | 186 | ColorConsole.WriteLine((pconfig.pingeractivlength / 60000).ToString(), ConsoleColor.Yellow, prefix: " pinger liftime :", suffix: "min"); |
| 180 | 187 | ColorConsole.WriteLine((pconfig.pingerhistorylength / 60000).ToString(), ConsoleColor.Yellow, prefix: " history length :", suffix: "min"); |
| 181 | - ColorConsole.WriteLine($"Pinger status for the following addresses:", ConsoleColor.Yellow); | |
| 188 | + var rttlstring = (string.Join(",", pconfig.RoundTripTimeLimits)).ToString(); | |
| 189 | + ColorConsole.WriteLine(rttlstring.Substring(0, rttlstring.Length>20?20: rttlstring.Length) + (rttlstring.Length > 20 ? "..." : ""), ConsoleColor.Yellow, prefix: " roundtrip time limit values :", suffix: "ms"); | |
| 190 | + ColorConsole.WriteLine((string.Join(",", pconfig.RoundTripTimeyCategoryLimits)).ToString(), ConsoleColor.Yellow, prefix: " roundtrip time category limit values:", suffix: "ms"); | |
| 182 | 191 | } |
| 183 | 192 | private static void DisplayPingerHistory(List<Pinger> selectedpingers) |
| 184 | 193 | { |
| 185 | 194 | ColorConsole.WriteLine(); |
| 195 | + ColorConsole.WriteLine($"Pinger History:", ConsoleColor.Yellow); | |
| 186 | 196 | var cursorleftposition = ColorConsole.CursorLeft; |
| 187 | 197 | var cursortopposition = ColorConsole.CursorTop; |
| 188 | 198 | while (true) |
| ... | ... | @@ -202,8 +212,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS |
| 202 | 212 | { |
| 203 | 213 | var _h = pinger.GetHistory(); |
| 204 | 214 | if (_h == null) { return 0; } |
| 205 | - 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 | |
| 206 | - ColorConsole.Write(pinger.HostNameOrAddress, ConsoleColor.Yellow, suffix: ": "); | |
| 215 | + 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 | |
| 216 | + ColorConsole.Write(pinger.HostNameOrAddress, ConsoleColor.Yellow, suffix: ": ",prefix:" "); | |
| 207 | 217 | var pingerstatus = pinger.Operating ? "pinging" : "still"; |
| 208 | 218 | var pingerstatuscolor = pinger.Operating ? ConsoleColor.Green : ConsoleColor.Yellow; |
| 209 | 219 | ColorConsole.Write(pingerstatus.PadRight(10), pingerstatuscolor); |
| ... | ... | @@ -212,7 +222,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS |
| 212 | 222 | if (lc != null) |
| 213 | 223 | { |
| 214 | 224 | var responseinfo = lc.StatusCategory != Pinger.PingCycle.IPStatusCategory.Success ? $"{lc.StatusCategory}" : $"RT:{lc.RoundtripTime} [{lc.RoundtripTimeMin}<{lc.RoundtripTimeAverage}<{lc.RoundtripTimeMax}]ms, LP:{lc.PackagesSentCategory}"; |
| 215 | - responseinfo=responseinfo.PadRight(35)+" "; | |
| 225 | + responseinfo=responseinfo.PadRight(40)+" "; | |
| 216 | 226 | ColorConsole.Write(responseinfo, GetPingCycleDisplayColor(lc)); |
| 217 | 227 | |
| 218 | 228 | foreach (var he in h.PingStateQueue) |
| ... | ... | @@ -227,7 +237,12 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS |
| 227 | 237 | ColorConsole.WriteLine(); |
| 228 | 238 | return h.PingCycleFrequency; |
| 229 | 239 | } |
| 230 | - private static string GetPingCycleDisplayCharacter(Pinger.PingCycle he) { return he.StatusCategory != Pinger.PingCycle.IPStatusCategory.Success ? "9" : he.RoundtripTimeCategory.ToString().Substring(1); } | |
| 240 | + private static string GetPingCycleDisplayCharacter(Pinger.PingCycle he) | |
| 241 | + { | |
| 242 | + return he.StatusCategory != Pinger.PingCycle.IPStatusCategory.Success | |
| 243 | + ? "9" | |
| 244 | + : he.RoundtripTimeCategory.ToString().Substring(1); | |
| 245 | + } | |
| 231 | 246 | private static ConsoleColor GetPingCycleDisplayColor(Pinger.PingCycle pingcycle) |
| 232 | 247 | { |
| 233 | 248 | return pingcycle.StatusCategory != Pinger.PingCycle.IPStatusCategory.Success ? ConsoleColor.Red |
| ... | ... | @@ -239,13 +254,15 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS |
| 239 | 254 | } |
| 240 | 255 | private static void DisplayAllPingerStatus(XElement pingerconfigxml,List<MaintenanceToolsXmlProcessor.IPAddressParsingResult> iplist, bool suppresserroneousipaddresses=false) |
| 241 | 256 | { |
| 257 | + ColorConsole.WriteLine(); | |
| 258 | + ColorConsole.WriteLine($"Pinger status for the following addresses:", ConsoleColor.Yellow); | |
| 242 | 259 | foreach (var ip in iplist) { DisplayOnePingerStatus(ip, pingerconfigxml, suppresserroneousipaddresses); } |
| 243 | 260 | } |
| 244 | 261 | private static void DisplayOnePingerStatus(MaintenanceToolsXmlProcessor.IPAddressParsingResult ip, XElement pingerconfigxml,bool suppresserroneousipaddresses = false) |
| 245 | 262 | { |
| 246 | 263 | if (ip.GoodIP) |
| 247 | 264 | { |
| 248 | - ColorConsole.Write($"{ip.IP}", ConsoleColor.Green); | |
| 265 | + ColorConsole.Write($"{ip.IP}", ConsoleColor.Green,prefix:" "); | |
| 249 | 266 | |
| 250 | 267 | var pingerlist = PingerList.Select(x => x.HostNameOrAddress).ToList(); |
| 251 | 268 | Pinger pinger; | ... | ... |
Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
| ... | ... | @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; |
| 32 | 32 | // You can specify all the values or you can default the Build and Revision Numbers |
| 33 | 33 | // by using the '*' as shown below: |
| 34 | 34 | // [assembly: AssemblyVersion("1.0.*")] |
| 35 | -[assembly: AssemblyVersion("1.8.0.0")] | |
| 36 | -[assembly: AssemblyFileVersion("1.8.0.0")] | |
| 35 | +[assembly: AssemblyVersion("1.8.1.0")] | |
| 36 | +[assembly: AssemblyFileVersion("1.8.1.0")] | ... | ... |