Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

253 lines
8.1 KiB

  1. @rem = '
  2. @goto endofperl
  3. ';
  4. use Getopt::Long;
  5. use Time::Local;
  6. $USAGE = "
  7. Usage: $0 [-sort=xxx] datafile
  8. Process the output of \"ntfrsutl sets\" and summarize the connection state.
  9. -sort=send -- sort outbound connections by the send delta
  10. -sort=clean -- sort outbound connections by the cleanup delta
  11. -sort=name -- sort outbound connections by the server name
  12. -sort=lmt -- sort outbound connections by the leading minus trailing index value.
  13. -sort=lastjointime -- sort outbound connections by the last join time. (default)
  14. -sort=lastvvjoin -- sort outbound connections by the last version vector join time.
  15. ";
  16. die $USAGE unless @ARGV;
  17. printf("\n\n");
  18. $cstatename[0] = "Init";
  19. $cstatename[1] = "Unjoined";
  20. $cstatename[2] = "Start";
  21. $cstatename[3] = "Starting";
  22. $cstatename[4] = "Scanning";
  23. $cstatename[5] = "SendJoin";
  24. $cstatename[6] = "WaitJoin";
  25. $cstatename[7] = "Joined";
  26. $cstatename[8] = "Unjoining";
  27. $cstatename[9] = "Deleted";
  28. $vvjoinmode = " ";
  29. $InFile = "";
  30. $HaveData = 0;
  31. $argsort = "lastjointime";
  32. &GetOptions("sort=s" => \$argsort);
  33. $argsort = lc($argsort);
  34. if (!($argsort =~ m/send|clean|name|lmt|lastjointime|lastvvjoin/)) {
  35. print "Error: Invalid -sort param: $argsort using name\n";
  36. $argsort = "name";
  37. }
  38. printf "Report generated at %s\n\n", scalar localtime;
  39. printf "Outbound connections sorted by: %s\n\n", $argsort;
  40. while (<>) {
  41. if ($InFile ne $ARGV) {
  42. $InFile = $ARGV;
  43. $modtime = (stat $InFile)[9];
  44. printf("Processing file %s Modify Time: %s\n\n", $InFile, scalar localtime($modtime));
  45. $infilelist = $infilelist . " " . $InFile;
  46. $linenumber = 0;
  47. }
  48. $linenumber++;
  49. chop;
  50. ($func, @a) = split(":");
  51. if (($func eq "") || ($func =~ m/^#/)) {next;}
  52. if ($func =~ m/^ DNS Name/) {
  53. printf("%s\n", $_);
  54. next;
  55. }
  56. if ($func =~ m/^ Replica/) {
  57. #
  58. # start of new Replica set. Print out prev data.
  59. #
  60. if ($HaveData) {&PrintData();}
  61. if ($replica ne "") {
  62. #output any summary state for previous replica and reset
  63. &PrintSummary();
  64. }
  65. ($junk, $replica) = split;
  66. printf("%s\n", $_);
  67. next;
  68. }
  69. if ($func =~ m/^ Member/) {($junk, $junk2, $member) = split; next; }
  70. if ($func =~ m/^ ServiceState/) {($junk, $servicestate) = split(":"); next;}
  71. if ($func =~ m/^ CnfFlags/) {($CnfFlags) = m/\[(.*)\]/; next;}
  72. if ($func =~ m/^ Root /) {($RootPath) = m/\: (.*)/; next;}
  73. if ($func =~ m/^ Stage /) {($StagePath) = m/\: (.*)/; next;}
  74. if ($func =~ m/^ FileFilter /) {($FileFilter) = m/\: (.*)/; next;}
  75. if ($func =~ m/^ DirFilter /) {($DirFilter) = m/\: (.*)/; next;}
  76. if ($func =~ m/^ OutLogSeq/) {($junk, $outlogseq) = split(":"); next;}
  77. if ($func =~ m/^ OutLogJTx/) {($junk, $outlogjtx) = split(":"); next; }
  78. if ($func =~ m/PartSrvName/) {($junk, $PartSrvName) = split(":"); $HaveData = 1; next;}
  79. if ($func =~ m/^ State/) {($junk, $cstate) = split(":"); next;}
  80. if ($func =~ m/Inbound/) {($junk, $Inbound) = split(":"); $Inbound = ($Inbound eq " FALSE") ? "Out" : "In "; next;}
  81. if ($func =~ m/PartnerMinor/) {($junk, $PartnerMinor) = split(":"); next;}
  82. if ($func =~ m/LastJoinTime/) {($junk, $LastJoinTime) = split(" : "); next;}
  83. if ($func =~ m/^ State/) {($junk, $olstate) = split(":"); next;}
  84. if ($func =~ m/^ CoTx /) {($junk, $junk2, $cotx) = split; next;}
  85. if ($func =~ m/^ CoLx /) {($junk, $junk2, $colx) = split; next;}
  86. if ($func =~ m/^ Flags/) {if (m/VvjoinMode/) {$vvjoinmode = "-vv";} next;}
  87. if ($func =~ m/^ OutstandingCos/) {($junk, $junk2, $OutstandingCos) = split; next;}
  88. if ($func =~ m/AckVersion/) {($junk, $AckVersion) = split(" : "); next;}
  89. #
  90. # start of new connection. Print out prev data.
  91. #
  92. if ($func =~ m/^ Cxtion/) {if ($HaveData) {&PrintData();} next; }
  93. next;
  94. }
  95. #
  96. # output last record
  97. #
  98. if ($HaveData) {&PrintData();}
  99. if ($replica ne "") {
  100. #output any summary state for previous replica and reset
  101. &PrintSummary();
  102. }
  103. exit;
  104. sub PrintData {
  105. my $outstr, $instr, $i, $key, $mon, $day, $year, $datestr, $hr, $min, $sec;
  106. #
  107. # Index the output result by the sort key. Zero extend the key.
  108. # Default is to sort by name.
  109. #
  110. $key = "0000000000";
  111. $datestr = "none";
  112. if ($Inbound eq "In ") {
  113. $instr = sprintf("%-20s %3s %-9s%3s %2s %26s\n",
  114. $PartSrvName, $Inbound, $cstatename[$cstate], $vvjoinmode, $PartnerMinor, $LastJoinTime);
  115. if ($argsort eq "lastjointime") {$datestr = $LastJoinTime;};
  116. } else {
  117. $outstr = sprintf("%-20s %3s %-9s%3s %2s %26s %-14s %8s %-6d %8s %-6d %3d %2s %26s\n",
  118. $PartSrvName, $Inbound, $cstatename[$cstate], $vvjoinmode, $PartnerMinor, $LastJoinTime,
  119. $olstate, $colx, $outlogseq-$colx, $cotx, $cotx-$outlogjtx, $colx-$cotx,
  120. $OutstandingCos, $AckVersion);
  121. if ($argsort eq "send") {$i = $outlogseq-$colx; $key = substr("0000000000".$i, -10);}
  122. if ($argsort eq "clean") {$i = $cotx-$outlogjtx; $key = substr("0000000000".$i, -10);}
  123. if ($argsort eq "lmt") {$i = $colx-$cotx; $key = substr("0000000000".$i, -10);}
  124. if ($argsort eq "lastjointime") {$datestr = $LastJoinTime;};
  125. if ($argsort eq "lastvvjoin") {$datestr = $AckVersion;};
  126. }
  127. #
  128. # sort by date applies to both the inbound and outbound connections.
  129. #
  130. if ($datestr ne "none") {
  131. # Oct 18, 2000
  132. ($mon, $day, $year) = lc($datestr) =~ m/(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\s*(\d*).*(\d\d\d\d)/;
  133. ($hr, $min, $sec) = $datestr =~ m/(\d\d):(\d\d):(\d\d)/;
  134. $i = 0;
  135. if ($mon ne "") {
  136. $mon = index("janfebmaraprmayjunjulaugsepoctnovdec", $mon) / 3;
  137. if ($year eq "1601") {$year = 1900;}
  138. $i = timelocal($sec, $min, $hr, $day, $mon, $year-1900);
  139. }
  140. $key = substr("000000000000".$i, -12);
  141. }
  142. #
  143. # combine key with name to distinguish duplicates.
  144. #
  145. if ($Inbound eq "In ") {
  146. if ($argsort ne "lastjointime") {$key = "0000000000";}
  147. $inhash{$key . $PartSrvName} = $instr;
  148. } else {
  149. $outhash{$key . $PartSrvName} = $outstr;
  150. }
  151. $HaveData = 0;
  152. $Inbound = "";
  153. $vvjoinmode = " ";
  154. }
  155. sub PrintSummary {
  156. my $i;
  157. $i = 0;
  158. &PrintHeader();
  159. #
  160. # Print the summary report and free the storage for the next replica set.
  161. #
  162. foreach $param (sort keys(%inhash)) {
  163. printf("%s", $inhash{$param});
  164. $i++;
  165. }
  166. undef %inhash;
  167. if ($i >= 20) {printf "\f"; &PrintHeader();}
  168. foreach $param (sort keys(%outhash)) {
  169. printf("%s", $outhash{$param});
  170. $i++;
  171. }
  172. if ($i >= 40) {printf "\f";}
  173. print ("\n\n");
  174. undef %outhash;
  175. }
  176. sub PrintHeader {
  177. printf(" Member: %-12s ServiceState: %-16s OutLogSeqNum: %-8s OutlogCleanup: %-8s Delta: %-8d\n",
  178. $member, $servicestate, $outlogseq, $outlogjtx, $outlogseq-$outlogjtx);
  179. printf(" Config Flags: %s\n", $CnfFlags);
  180. printf(" Root Path : %s\n", $RootPath);
  181. printf(" Staging Path: %s\n", $StagePath);
  182. printf(" File Filter : %s\n", $FileFilter);
  183. printf(" Dir Filter : %s\n\n",$DirFilter);
  184. printf(" Send Cleanup Cos \n");
  185. printf(" Partner I/O State Rev LastJoinTime OLog State Leadx Delta Trailx Delta LMT Out Last VVJoin\n\n");
  186. # A0ZONA1\A0004100$ Out Joined 3 OLP_AT_QUOTA 422352 146 422225 7552 127 7 Wed Oct 18, 2000 06:00:00
  187. }
  188. # Rev history-
  189. # 1/19/01 - allow inbound connection sort by LastJoinTime.
  190. # - special case year 1601.
  191. __END__
  192. :endofperl
  193. @perl %~dpn0.cmd %*