Skip to content

Commit

Permalink
-Dump DNS -TopNDetails dd added Limit amount of output per DNS query …
Browse files Browse the repository at this point in the history
…when -details is present.
  • Loading branch information
AloisKraus committed Mar 16, 2023
1 parent b94b659 commit c35bb71
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion ETWAnalyzer/Commands/DumpCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,12 @@ class DumpCommand : ArgParser
" -Methods *Func1*;xxx.dll!FullMethodName Dump one or more methods from all or selected processes. When omitted only process total method call is printed to give an overview." + Environment.NewLine;

static readonly string DnsHelpString =
" Dns -filedir/fd Extract\\ or xxx.json [-DnsQueryFilter xxx] [-Details] [-ShowProcess] [-ShowAdapter] [-ShowReturnCode] [-TopN dd nn] [-SortBy Time/Count] [-MinMaxTotalTimeMs min [max]] [-MinMaxTimeMs min [max]] [-recursive] " + Environment.NewLine +
" Dns -filedir/fd Extract\\ or xxx.json [-DnsQueryFilter xxx] [-Details] [-ShowProcess] [-ShowAdapter] [-ShowReturnCode] [-TopN dd nn] [-TopNDetails dd nn] [-SortBy Time/Count] [-MinMaxTotalTimeMs min [max]] [-MinMaxTimeMs min [max]] [-recursive] " + Environment.NewLine +
" [-TimeFmt s,Local,LocalTime,UTC,UTCTime,Here,HereTime] [-csv xxx.csv] [-NoCSVSeparator] [-NoCmdLine] [-Clip] [-TestsPerRun dd -SkipNTests dd] [-TestRunIndex dd -TestRunCount dd] [-MinMaxMsTestTimes xx-yy ...] [-ProcessName/pn xxx.exe(pid)] " + Environment.NewLine +
" [-NewProcess 0/1/-1/-2/2] [-PlainProcessNames] [-CmdLine substring]" + Environment.NewLine +
" Print Dns summary and delay metrics. To see data you need to enable the Microsoft-Windows-DNS-Client ETW provider" + Environment.NewLine +
" -Details Display time, duration, process, resolved IP of every Dns request." + Environment.NewLine +
" -TopNDetails dd nn Limit detail list to dd elements per DNS Query." + Environment.NewLine +
" -ShowAdapter Show which network adapters were used to query Dns." + Environment.NewLine +
" -ShowReturnCode Show Dns API Win32 return code/s. Success and InvalidParameter are not shown." + Environment.NewLine +
" -ShowProcess Show for each Dns query the calling process/es in the lines above." + Environment.NewLine +
Expand Down Expand Up @@ -797,6 +798,7 @@ internal enum ZeroTimeModes
public MinMaxRange<double> MinMaxTimeMs { get; private set; } = new();
public MinMaxRange<double> MinMaxTotalTimeMs { get; private set; } = new();
public bool ShowProcess { get; set; }
public SkipTakeRange TopNDetails { get; set; } = new();


// Dump Tcp specific flags
Expand Down Expand Up @@ -971,6 +973,12 @@ public override void Parse()
Tuple<int,int> topNAndSkip = topN.GetRange(skip);
TopN = new SkipTakeRange(topNAndSkip.Item1, topNAndSkip.Item2);
break;
case "-topndetails":
string topnDetailsStr = GetNextNonArg("-topndetails");
string topnDetailSkipStr = GetNextNonArg("-topndetails", false); // skip string is optional
Tuple<int, int> topNDetailsSkip = topnDetailsStr.GetRange(topnDetailSkipStr);
TopNDetails = new SkipTakeRange(topNDetailsSkip.Item1, topNDetailsSkip.Item2);
break;
case "-topnretrans":
string topnretrans = GetNextNonArg("-topnretrans");
string skipretrans = GetNextNonArg("-topnretrans", false);
Expand Down Expand Up @@ -1946,6 +1954,7 @@ public override void Run()

NoCmdLine = NoCmdLine,
TopN = TopN,
TopNDetails = TopNDetails,
SortOrder = SortOrder,
ShowDetails = ShowDetails,
ShowAdapter = ShowAdapter,
Expand Down
4 changes: 3 additions & 1 deletion ETWAnalyzer/EventDump/DumpDns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class DumpDns : DumpFileDirBase<DumpDns.MatchData>
public bool NoCmdLine { get; set; }
public SkipTakeRange TopN { get; set; }

public SkipTakeRange TopNDetails { get; set; } = new();

public bool ShowReturnCode { get; set; }
public bool ShowAdapter { get; set; }
public DumpCommand.SortOrders SortOrder { get; internal set; }
Expand Down Expand Up @@ -157,7 +159,7 @@ private void PrintMatches(List<MatchData> lret)
ColorConsole.WriteEmbeddedColorLine($"[green]{dnsQueryTime,12} s[/green] {minTime,6} s [yellow]{maxTime,7} s[/yellow] {data.GroupQueryCount,6} [red]{timedOut,7}[/red] [yellow]{data.GroupQuery,dnsQueryWidth}[/yellow]{returnCode}{adapter}");
if (ShowDetails)
{
foreach (DnsEvent dnsEvent in data.GroupQueries.OrderBy(x => x.Start))
foreach (DnsEvent dnsEvent in data.GroupQueries.OrderBy(x => x.Start).Skip(TopNDetails.SkipN).Take(TopNDetails.TakeN))
{
string duration = $"{dnsEvent.Duration.TotalSeconds:F3}".WithWidth(6);
string timedOutServer = "";
Expand Down

0 comments on commit c35bb71

Please sign in to comment.