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.

166 lines
3.6 KiB

  1. @rem = '
  2. @goto endofperl
  3. ';
  4. $USAGE = "
  5. Usage: $0 datafile
  6. topchk-mkdsx takes the output of \"mkdsx dump\" commands and summarizes the topology.
  7. ";
  8. die $USAGE unless @ARGV;
  9. printf("\n\n");
  10. $linenumber = 0;
  11. $InFile = "";
  12. $bx = 0;
  13. $hx = 0;
  14. $remx = 0;
  15. $cxtion = "";
  16. $hostsite = "unknown";
  17. $hostsrv = "unknown";
  18. $fromsite = "unknown";
  19. $fromsrv = "unknown";
  20. $schedule = "none";
  21. $enable = "unknown";
  22. $replhours = 0;
  23. $cxtioncnt = 1;
  24. $errorcount = 0;
  25. while (<>) {
  26. if ($InFile ne $ARGV) {
  27. $InFile = $ARGV;
  28. printf("Processing file %s \n\n", $InFile);
  29. $infilelist = $infilelist . " " . $InFile;
  30. $linenumber = 0;
  31. }
  32. $linenumber++;
  33. chop;
  34. ($func, @a) = split(":");
  35. if (($func eq "") || ($func =~ m/^#/)) {next;}
  36. #
  37. # /rem <text>
  38. #
  39. if ($func =~ m/\Computer DNS Name/) {
  40. printf("%s\n", $_);
  41. next;
  42. }
  43. if ($func =~ m/^Dn/) {
  44. #printf("%s\n", $_);
  45. #printf("\ncxtion is %s\n", $cxtion);
  46. if ($cxtion ne "") {
  47. printf("cxtion: %-36s host:%20s\\%-16s from:%20s\\%-16s RepHrs: %3d Sched: %-24s enabled: %5s\n",
  48. $cxtion, $hostsite, $hostsrv, $fromsite, $fromsrv, $replhours, $schedule, $enable);
  49. $cxtion = "";
  50. $hostsite = "unknown";
  51. $hostsrv = "unknown";
  52. $fromsite = "unknown";
  53. $fromsrv = "unknown";
  54. $schedule = "none";
  55. $enable = "unknown";
  56. $replhours = 0;
  57. }
  58. #Dn:CN=ZW003COversZA8733000,CN=NTDS Settings,CN=ZA8733000,CN=Servers,CN=S-8733,CN=Sites,CN=Configuration,DC=mma,DC=fr
  59. ($cxtion, $hostsrv, $hostsite) = m/CN=(.*),cn=ntds settings,cn=(.*),cn=servers,cn=(.*),cn=sites/i;
  60. next;
  61. }
  62. if ($func =~ m/enabledCxtion/) {
  63. #printf("%s\n", $_);
  64. $enable = $a[0];
  65. next;
  66. }
  67. if ($func =~ m/fromServer/) {
  68. #printf("%s\n", $_);
  69. # fromServer:CN=NTDS Settings,CN=ZW003CO,CN=Servers,CN=DMZ-Administration,CN=Sites,CN=Configuration,DC=mma,DC=fr
  70. ($fromsrv, $fromsite) = m/cn=ntds settings,cn=(.*),cn=servers,cn=(.*),cn=sites/i;
  71. $from = $fromsite . "\\" . $fromsrv;
  72. $host = $hostsite . "\\" . $hostsrv;
  73. $fromlist{uc($from)}++;
  74. $hostlist{uc($host)}++;
  75. next;
  76. }
  77. #
  78. # Day 2: 010000000000010000000000 THis is monday.
  79. #
  80. if (m/Day 2\:/) {
  81. #printf("%s\n", $_);
  82. ($junk, $junk2, $schedule) = split;
  83. }
  84. #
  85. # Count the number of non-zero hours
  86. #
  87. if (m/Day .\:/) {
  88. ($junk, $junk2, $scvector) = split;
  89. for ($i=0; $i < 24; $i++) {
  90. if (substr($scvector, $i, 1) ne "0") {$replhours++;}
  91. }
  92. }
  93. }
  94. if ($cxtion ne "") {
  95. printf("cxtion: %-36s host:%20s\\%-16s from:%20s\\%-16s RepHrs: %3d Sched: %-24s enabled: %5s\n",
  96. $cxtion, $hostsite, $hostsrv, $fromsite, $fromsrv, $replhours, $schedule, $enable);
  97. $cxtion = "";
  98. $hostsite = "unknown";
  99. $hostsrv = "unknown";
  100. $fromsite = "unknown";
  101. $fromsrv = "unknown";
  102. $schedule = "none";
  103. $enable = "unknown";
  104. $replhours = 0;
  105. }
  106. printf("\n\n Servers referenced from cxtions (From List) \n\n");
  107. foreach $param (sort keys(%fromlist)) {
  108. printf("%-25s %5d %5d\n", $param, $fromlist{$param}, $hostlist{$param});
  109. }
  110. printf("\n\n Servers hosting cxtions (Host List) \n\n");
  111. foreach $param (sort keys(%hostlist)) {
  112. printf("%-25s %5d %5d\n", $param, $hostlist{$param}, $fromlist{$param});
  113. }
  114. exit;
  115. __END__
  116. :endofperl
  117. @perl %~dpn0.cmd %*