Commit e9ee2f8b120b5210e16d824fe60fe896048deb8e
1 parent
7e23fb05
v1.8.4
- IP Pinger felület fejlesztése
Showing
4 changed files
with
105 additions
and
23 deletions
Show diff stats
Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - ColorConsole.cs
@@ -116,7 +116,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ColorConsoleNS | @@ -116,7 +116,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ColorConsoleNS | ||
116 | { | 116 | { |
117 | int currentLineCursor = Console.CursorTop; | 117 | int currentLineCursor = Console.CursorTop; |
118 | int currentColCursor = Console.CursorLeft; | 118 | int currentColCursor = Console.CursorLeft; |
119 | - if (height == 0) { height = Console.WindowHeight; } | 119 | + if (height == 0) { height = Console.WindowHeight- Console.CursorTop; } |
120 | for (var i=0;i<height;i++) | 120 | for (var i=0;i<height;i++) |
121 | { | 121 | { |
122 | ClearLine(width, fillchar); | 122 | ClearLine(width, fillchar); |
Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs
@@ -113,6 +113,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | @@ -113,6 +113,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | ||
113 | var suppresserroneousipaddresses = false; | 113 | var suppresserroneousipaddresses = false; |
114 | while (true) | 114 | while (true) |
115 | { | 115 | { |
116 | + DisplayPingerScreenTitle(); | ||
116 | DisplayPingerParameters(pingerconfigxml); | 117 | DisplayPingerParameters(pingerconfigxml); |
117 | var cc = ColorConsole.CursorLeft; | 118 | var cc = ColorConsole.CursorLeft; |
118 | var cr = ColorConsole.CursorTop; | 119 | var cr = ColorConsole.CursorTop; |
@@ -120,7 +121,6 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | @@ -120,7 +121,6 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | ||
120 | DisplayAllPingerStatus(pingerconfigxml, iplist, firstrun, suppresserroneousipaddresses); | 121 | DisplayAllPingerStatus(pingerconfigxml, iplist, firstrun, suppresserroneousipaddresses); |
121 | if (!firstrun) | 122 | if (!firstrun) |
122 | { | 123 | { |
123 | - | ||
124 | DisplayPingerCommands(); | 124 | DisplayPingerCommands(); |
125 | } | 125 | } |
126 | 126 | ||
@@ -177,32 +177,78 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | @@ -177,32 +177,78 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | ||
177 | ColorConsole.WriteLine($"Set [ip address] to 'ALL' or '*' for action to all ip addresses.", ConsoleColor.Yellow); | 177 | ColorConsole.WriteLine($"Set [ip address] to 'ALL' or '*' for action to all ip addresses.", ConsoleColor.Yellow); |
178 | } | 178 | } |
179 | 179 | ||
180 | - private static void DisplayPingerParameters(XElement pingerconfigxml) | 180 | + private static string MARKQ1 = new string((char)9608, 1); |
181 | + private static string MARKQ2 = new string((char)9619, 1); | ||
182 | + private static string MARKQ3 = new string((char)9618, 1); | ||
183 | + private static string MARKQ4 = new string((char)9617, 1); | ||
184 | + private static ConsoleColor CEXCELLENT = ConsoleColor.DarkGreen; | ||
185 | + private static ConsoleColor CGOOD = ConsoleColor.Green; | ||
186 | + private static ConsoleColor CACCEPTABLE = ConsoleColor.DarkYellow; | ||
187 | + private static ConsoleColor CBAD = ConsoleColor.Yellow; | ||
188 | + private static ConsoleColor CFATAL = ConsoleColor.Red; | ||
189 | + private static void DisplayPingerScreenTitle() | ||
181 | { | 190 | { |
182 | ColorConsole.Clear(); | 191 | ColorConsole.Clear(); |
183 | var pingertitle = "IP Pinger"; | 192 | var pingertitle = "IP Pinger"; |
184 | ColorConsole.WriteLine(ColorConsole.WideString(pingertitle), ConsoleColor.Yellow); | 193 | ColorConsole.WriteLine(ColorConsole.WideString(pingertitle), ConsoleColor.Yellow); |
185 | - ColorConsole.WriteLine(new string('-', 2*pingertitle.Length), ConsoleColor.Yellow); | 194 | + ColorConsole.WriteLine(new string('-', 2 * pingertitle.Length), ConsoleColor.Yellow); |
195 | + } | ||
196 | + private static void DisplayPingerParameters(XElement pingerconfigxml) | ||
197 | + { | ||
186 | ColorConsole.WriteLine(); | 198 | ColorConsole.WriteLine(); |
187 | ColorConsole.WriteLine($"Pinger configuration parameters:", ConsoleColor.Yellow); | 199 | ColorConsole.WriteLine($"Pinger configuration parameters:", ConsoleColor.Yellow); |
188 | var pconfig = new Pinger("127.0.0.1", pingerconfigxml).Configuration; | 200 | var pconfig = new Pinger("127.0.0.1", pingerconfigxml).Configuration; |
189 | - ColorConsole.WriteLine(pconfig.pingtimeout.ToString(), ConsoleColor.Yellow, prefix: " pingtimeout :", suffix: "ms"); | ||
190 | - ColorConsole.WriteLine(pconfig.pingcyclenumofpackages.ToString(), ConsoleColor.Yellow, prefix: " pings per cycle:", suffix: "pings"); | ||
191 | - ColorConsole.WriteLine((pconfig.pingcyclefrequency / 1000).ToString(), ConsoleColor.Yellow, prefix: " cycle frequency:", suffix: "sec"); | ||
192 | - ColorConsole.WriteLine((pconfig.pingeractivlength / 60000).ToString(), ConsoleColor.Yellow, prefix: " pinger liftime :", suffix: "min"); | ||
193 | - ColorConsole.WriteLine((pconfig.pingerhistorylength / 60000).ToString(), ConsoleColor.Yellow, prefix: " history length :", suffix: "min"); | ||
194 | - ColorConsole.WriteLine((pconfig.optimizehistorylength).ToString(), ConsoleColor.Yellow, prefix: " optimize history length :", suffix: ""); | 201 | + ColorConsole.WriteLine(pconfig.pingtimeout.ToString(), ConsoleColor.Yellow, prefix: " pingtimeout :", suffix: " ms"); |
202 | + ColorConsole.WriteLine(pconfig.pingcyclenumofpackages.ToString(), ConsoleColor.Yellow, prefix: " pings per cycle:", suffix: " pings"); | ||
203 | + ColorConsole.WriteLine((pconfig.pingcyclefrequency / 1000).ToString(), ConsoleColor.Yellow, prefix: " cycle frequency:", suffix: " sec"); | ||
204 | + ColorConsole.WriteLine((pconfig.pingeractivlength / 60000).ToString(), ConsoleColor.Yellow, prefix: " pinger liftime :", suffix: " min"); | ||
205 | + | ||
206 | + ColorConsole.Write((pconfig.pingerhistorylength / 60000).ToString(), ConsoleColor.Yellow, prefix: " history length :", suffix: " min"); | ||
207 | + ColorConsole.Write((pconfig.optimizehistorylength).ToString(), ConsoleColor.Yellow, prefix: " (optimized: ", suffix: ")"); | ||
208 | + ColorConsole.WriteLine(); | ||
209 | + | ||
210 | + DisplayRoundTripTimeIntervalLimitsAndCategories(pconfig); | ||
211 | + | ||
212 | + ColorConsole.WriteLine(); | ||
213 | + ColorConsole.WriteLine($"Pinger history color codes for roundtrip time categories and lost package categories:", ConsoleColor.Yellow); | ||
214 | + ColorConsole.WriteLine(new string((char)9608, 1), CFATAL,prefix: " TimeOut/no answer/all packages lost :"); | ||
215 | + ColorConsole.WriteLine( " Roundtrip time categories:Q1 Q2 Q3 Q4", ConsoleColor.Yellow); | ||
216 | + DisplayHistoryMarksForOneLostPackageCategory(pconfig, CEXCELLENT, " Excellent (lost packages below 10%) :"); | ||
217 | + DisplayHistoryMarksForOneLostPackageCategory(pconfig, CGOOD, " Good (lost packages between 10-20%):"); | ||
218 | + DisplayHistoryMarksForOneLostPackageCategory(pconfig, CACCEPTABLE, " Acceptable (lost packages between 20-30%):"); | ||
219 | + DisplayHistoryMarksForOneLostPackageCategory(pconfig, CBAD, " Bad (lost packages over 30%) :"); | ||
220 | + } | ||
221 | + private static void DisplayRoundTripTimeIntervalLimitsAndCategories(Pinger.PingerConfig pconfig) | ||
222 | + { | ||
195 | var rttlstring = (string.Join(",", pconfig.RoundTripTimeLimits)).ToString(); | 223 | var rttlstring = (string.Join(",", pconfig.RoundTripTimeLimits)).ToString(); |
196 | - ColorConsole.WriteLine(rttlstring.Substring(0, rttlstring.Length>20?20: rttlstring.Length) + (rttlstring.Length > 20 ? "..." : ""), ConsoleColor.Yellow, prefix: " roundtrip time limit values :", suffix: "ms"); | ||
197 | - ColorConsole.WriteLine((string.Join(",", pconfig.RoundTripTimeyCategoryLimits)).ToString(), ConsoleColor.Yellow, prefix: " roundtrip time category limit values:", suffix: "ms"); | 224 | + ColorConsole.WriteLine(rttlstring.Substring(0, rttlstring.Length > 40 ? 40 : rttlstring.Length) + (rttlstring.Length > 40 ? "..." : ""), ConsoleColor.Yellow, prefix: " roundtrip time interval limit values:", suffix: " ms"); |
225 | + ColorConsole.Write("", ConsoleColor.Yellow, prefix: " roundtrip time category limit values:"); | ||
226 | + ColorConsole.Write(pconfig.RoundTripTimeyCategoryLimits.ElementAt(0).ToString(), ConsoleColor.Yellow, suffix: "ms <= "); | ||
227 | + ColorConsole.Write("Q1", ConsoleColor.Yellow, suffix: " < "); | ||
228 | + ColorConsole.Write(pconfig.RoundTripTimeyCategoryLimits.ElementAt(1).ToString(), ConsoleColor.Yellow, suffix: "ms <= "); | ||
229 | + ColorConsole.Write("Q2", ConsoleColor.Yellow, suffix: " < "); | ||
230 | + ColorConsole.Write(pconfig.RoundTripTimeyCategoryLimits.ElementAt(2).ToString(), ConsoleColor.Yellow, suffix: "ms <= "); | ||
231 | + ColorConsole.Write("Q3", ConsoleColor.Yellow, suffix: " < "); | ||
232 | + ColorConsole.Write(pconfig.RoundTripTimeyCategoryLimits.ElementAt(3).ToString(), ConsoleColor.Yellow, suffix: "ms <= "); | ||
233 | + ColorConsole.Write("Q4", ConsoleColor.Yellow, suffix: ""); | ||
234 | + ColorConsole.WriteLine(); | ||
235 | + } | ||
236 | + private static void DisplayHistoryMarksForOneLostPackageCategory(Pinger.PingerConfig pconfig, ConsoleColor c, string text) | ||
237 | + { | ||
238 | + ColorConsole.Write("", ConsoleColor.Yellow, prefix: text); | ||
239 | + ColorConsole.Write(MARKQ1, c, suffix: " "); | ||
240 | + ColorConsole.Write(MARKQ2, c, suffix: " "); | ||
241 | + ColorConsole.Write(MARKQ3, c, suffix: " "); | ||
242 | + ColorConsole.Write(MARKQ4, c, suffix: " "); | ||
243 | + ColorConsole.WriteLine(); | ||
198 | } | 244 | } |
199 | private static void DisplayPingerHistory(List<Pinger> selectedpingers,int firstrow,int cc) | 245 | private static void DisplayPingerHistory(List<Pinger> selectedpingers,int firstrow,int cc) |
200 | { | 246 | { |
201 | if (selectedpingers == null || !selectedpingers.Any()) { return; } | 247 | if (selectedpingers == null || !selectedpingers.Any()) { return; } |
202 | ColorConsole.SetCursorPosition(cc, firstrow); | 248 | ColorConsole.SetCursorPosition(cc, firstrow); |
203 | - | ||
204 | - ColorConsole.ClearLine();ColorConsole.WriteLine(); | ||
205 | - ColorConsole.ClearLine();ColorConsole.WriteLine($"Pinger History:", ConsoleColor.Yellow); | 249 | + ColorConsole.ClearArea(0, selectedpingers.Count+ 10); |
250 | + ColorConsole.WriteLine(); | ||
251 | + ColorConsole.WriteLine($"Pinger History:", ConsoleColor.Yellow); | ||
206 | var cursorleftposition = ColorConsole.CursorLeft; | 252 | var cursorleftposition = ColorConsole.CursorLeft; |
207 | var cursortopposition = ColorConsole.CursorTop; | 253 | var cursortopposition = ColorConsole.CursorTop; |
208 | while (true) | 254 | while (true) |
@@ -213,8 +259,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | @@ -213,8 +259,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | ||
213 | foreach (var pinger in selectedpingers) { pingcyclefrequency=DisplayOnePingerHistory(pinger); if (ColorConsole.KeyAvailable) { goto finishdisplayhistory; };} | 259 | foreach (var pinger in selectedpingers) { pingcyclefrequency=DisplayOnePingerHistory(pinger); if (ColorConsole.KeyAvailable) { goto finishdisplayhistory; };} |
214 | var elapsed = DateTime.Now.Subtract(monitorcyclestart).TotalMilliseconds; | 260 | var elapsed = DateTime.Now.Subtract(monitorcyclestart).TotalMilliseconds; |
215 | if (elapsed < pingcyclefrequency) { Thread.Sleep((int)((double)pingcyclefrequency - elapsed)); } | 261 | if (elapsed < pingcyclefrequency) { Thread.Sleep((int)((double)pingcyclefrequency - elapsed)); } |
216 | - ColorConsole.ClearLine(); ColorConsole.WriteLine(); | ||
217 | - ColorConsole.ClearLine(); ColorConsole.WriteLine($"Press any key to exit from monitoring...", ConsoleColor.Yellow); | 262 | + ColorConsole.WriteLine(); |
263 | + ColorConsole.WriteLine($"Press any key to exit from monitoring...", ConsoleColor.Yellow); | ||
218 | } | 264 | } |
219 | finishdisplayhistory:; | 265 | finishdisplayhistory:; |
220 | } | 266 | } |
@@ -249,10 +295,14 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | @@ -249,10 +295,14 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | ||
249 | return h.PingCycleFrequency; | 295 | return h.PingCycleFrequency; |
250 | } | 296 | } |
251 | private static string GetPingCycleDisplayCharacter(Pinger.PingCycle he) | 297 | private static string GetPingCycleDisplayCharacter(Pinger.PingCycle he) |
252 | - { | ||
253 | - return he.StatusCategory != Pinger.PingCycle.IPStatusCategory.Success | ||
254 | - ? "9" | ||
255 | - : he.RoundtripTimeCategory.ToString().Substring(1); | 298 | + { |
299 | + return he.StatusCategory != Pinger.PingCycle.IPStatusCategory.Success | ||
300 | + ? MARKQ1 //"9" | ||
301 | + : he.RoundtripTimeCategory == Pinger.PingCycle.RoundTripTimeCategory.Q1 ? MARKQ1 | ||
302 | + : he.RoundtripTimeCategory == Pinger.PingCycle.RoundTripTimeCategory.Q2 ? MARKQ2 | ||
303 | + : he.RoundtripTimeCategory == Pinger.PingCycle.RoundTripTimeCategory.Q3 ? MARKQ3 | ||
304 | + : he.RoundtripTimeCategory == Pinger.PingCycle.RoundTripTimeCategory.Q4 ? MARKQ4 | ||
305 | + : ""; | ||
256 | } | 306 | } |
257 | private static ConsoleColor GetPingCycleDisplayColor(Pinger.PingCycle pingcycle) | 307 | private static ConsoleColor GetPingCycleDisplayColor(Pinger.PingCycle pingcycle) |
258 | { | 308 | { |
Vrh.Log4Pro.MaintenanceConsole/Program.cs
@@ -35,6 +35,38 @@ namespace Vrh.Log4Pro.MaintenanceConsole | @@ -35,6 +35,38 @@ namespace Vrh.Log4Pro.MaintenanceConsole | ||
35 | { | 35 | { |
36 | static void Main(string[] args) | 36 | static void Main(string[] args) |
37 | { | 37 | { |
38 | + //while (true) | ||
39 | + //{ | ||
40 | + // Console.Clear(); | ||
41 | + // Console.Write("Enter string:"); var cp1 = Console.ReadLine(); | ||
42 | + // Console.WriteLine(); | ||
43 | + // Console.ForegroundColor = ConsoleColor.Red; | ||
44 | + // Console.Write(cp1); foreach (char c in cp1) { Console.Write(c); Console.Write(" => "); var i = (int)c; Console.Write(i); Console.Write(" => "); Console.Write((char)i); Console.WriteLine(); } | ||
45 | + // Console.ForegroundColor = ConsoleColor.DarkGreen; | ||
46 | + // Console.Write(cp1); foreach (char c in cp1) { Console.Write(c); Console.Write(" => "); var i = (int)c; Console.Write(i); Console.Write(" => "); Console.Write((char)i); Console.WriteLine(); } | ||
47 | + // Console.ForegroundColor = ConsoleColor.Green; | ||
48 | + // Console.Write(cp1); foreach (char c in cp1) { Console.Write(c); Console.Write(" => "); var i = (int)c; Console.Write(i); Console.Write(" => "); Console.Write((char)i); Console.WriteLine(); } | ||
49 | + // Console.ForegroundColor = ConsoleColor.DarkYellow; | ||
50 | + // Console.Write(cp1); foreach (char c in cp1) { Console.Write(c); Console.Write(" => "); var i = (int)c; Console.Write(i); Console.Write(" => "); Console.Write((char)i); Console.WriteLine(); } | ||
51 | + // Console.ForegroundColor = ConsoleColor.Yellow; | ||
52 | + // Console.Write(cp1); foreach (char c in cp1) { Console.Write(c); Console.Write(" => "); var i = (int)c; Console.Write(i); Console.Write(" => "); Console.Write((char)i); Console.WriteLine(); } | ||
53 | + // Console.ReadKey(); | ||
54 | + // Console.Clear(); | ||
55 | + // Console.Write("Enter Code page:"); var cp = Console.ReadLine(); | ||
56 | + // try | ||
57 | + // { | ||
58 | + // Console.OutputEncoding = System.Text.Encoding.GetEncoding(int.Parse(cp)); | ||
59 | + // for (int i = 0; i < 256; i++) | ||
60 | + // { | ||
61 | + // Console.Write((i).ToString().PadLeft(3) + "=> [" + (char)(i) + "] "); | ||
62 | + // if (i % 6 == 5) { Console.WriteLine(); } | ||
63 | + // //Console.Write((char)(i*j)); | ||
64 | + // } | ||
65 | + // } | ||
66 | + // catch { Console.WriteLine("Code page is not supported!"); } | ||
67 | + // Console.ReadKey(); | ||
68 | + //} | ||
69 | + | ||
38 | var forcedmodulekey = CommandLine.GetCommandLineArgument(args, CLP.CMD_MODULE); | 70 | var forcedmodulekey = CommandLine.GetCommandLineArgument(args, CLP.CMD_MODULE); |
39 | var commandmode = !string.IsNullOrEmpty(forcedmodulekey); | 71 | var commandmode = !string.IsNullOrEmpty(forcedmodulekey); |
40 | var silentmode = commandmode && !string.IsNullOrEmpty(CommandLine.GetCommandLineArgument(args, CLP.CMD_SILENT, switchtype: true)); | 72 | var silentmode = commandmode && !string.IsNullOrEmpty(CommandLine.GetCommandLineArgument(args, CLP.CMD_SILENT, switchtype: true)); |
Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices; | @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; | ||
32 | // You can specify all the values or you can default the Build and Revision Numbers | 32 | // You can specify all the values or you can default the Build and Revision Numbers |
33 | // by using the '*' as shown below: | 33 | // by using the '*' as shown below: |
34 | // [assembly: AssemblyVersion("1.0.*")] | 34 | // [assembly: AssemblyVersion("1.0.*")] |
35 | -[assembly: AssemblyVersion("1.8.3.0")] | ||
36 | -[assembly: AssemblyFileVersion("1.8.3.0")] | 35 | +[assembly: AssemblyVersion("1.8.4.0")] |
36 | +[assembly: AssemblyFileVersion("1.8.4.0")] |