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.

190 lines
5.7 KiB

  1. @echo off
  2. REM HEALTH_CHK.CMD - Retrieves some state info from the specified DC.
  3. SETLOCAL ENABLEEXTENSIONS
  4. set toollist=regdmp repadmin ntfrsutl eventdmp
  5. if NOT "%1" == "" goto :CHECK_TOOLS
  6. :USAGE
  7. echo Usage: health_chk result_dir [target_computername]
  8. echo Retrieve state info from the specified DC.
  9. echo result_dir is created if it does not exist. No trailing backslash.
  10. echo Target_ComputerName is optional. Default is current computer.
  11. echo It can be a netbios name with no leading slashes or a full dns name, xxx.yyy.zzz.com
  12. echo This script uses NTFRSUTL.EXE to gather data from FRS on the
  13. echo Target computer. This tool must be in your path and can be found
  14. echo in the resource kit. The NTFRS service must be running on the
  15. echo target computer. health_chk uses the following tools to gather information.
  16. echo %toollist%
  17. echo ----
  18. goto :QUIT
  19. :CHECK_TOOLS
  20. REM see if we have ntfrsutl.exe
  21. ntfrsutl > nul: 2> nul:
  22. if ERRORLEVEL 1 (
  23. echo ****** NTFRSUTL.EXE is not in your path. This tool can be found in the resource kit.
  24. echo ****** This tool is needed to gather all the data.
  25. goto :USAGE
  26. )
  27. REM see if we have repadmin.exe
  28. repadmin > nul: 2> nul:
  29. if ERRORLEVEL 1 (
  30. echo ****** REPADMIN.EXE is not in your path.
  31. echo ****** This tool is needed to gather all the data.
  32. goto :USAGE
  33. )
  34. REM see if we have regdmp.exe
  35. regdmp HKEY_LOCAL_MACHINE\system\currentcontrolset\services\NtFrsxxx > nul: 2> nul:
  36. if ERRORLEVEL 2 (
  37. echo ****** REGDMP.EXE is not in your path.
  38. echo ****** This tool is needed to gather all the data.
  39. goto :USAGE
  40. )
  41. REM see if we have eventdmp.exe
  42. eventdmp /? > nul: 2> nul:
  43. if ERRORLEVEL 1 (
  44. echo ****** EVENTDMP.EXE is not in your path.
  45. echo ****** This tool is needed to gather all the data.
  46. goto :USAGE
  47. )
  48. if "%2" == "" (
  49. set CHKCOMP=%COMPUTERNAME%
  50. ) else (
  51. set CHKCOMP=%2
  52. )
  53. set QA=%1\%CHKCOMP%
  54. if NOT EXIST %QA% (
  55. echo ****** Creating output directory: %QA%
  56. md %QA%
  57. )
  58. if NOT EXIST %QA% (
  59. echo ****** Failed to create output dir: %QA%
  60. echo ****** No data retrieved.
  61. goto :DONE
  62. )
  63. @echo Please WAIT....
  64. for %%x in (ds errscan inlog outlog machine reg sets version config sysvol) do (
  65. del %QA%\ntfrs_%%x.txt 1>nul: 2>nul:
  66. )
  67. for %%x in (showreps showconn) do (
  68. del %QA%\ds_%%x.txt 1>nul: 2>nul:
  69. )
  70. del %QA%\evl_*.txt 1>nul: 2>nul:
  71. echo DateTime : %DATE%, %TIME% > %QA%\ntfrs_machine.txt
  72. echo TargetComputer : %2 >> %QA%\ntfrs_machine.txt
  73. echo LocalComputername: %COMPUTERNAME% >> %QA%\ntfrs_machine.txt
  74. echo LogonServer : %LOGONSERVER% >> %QA%\ntfrs_machine.txt
  75. echo UserDomain : %USERDOMAIN% >> %QA%\ntfrs_machine.txt
  76. echo UserName : %USERNAME% >> %QA%\ntfrs_machine.txt
  77. if ("%CHKCOMP%"=="%COMPUTERNAME%") (
  78. echo Architecture : %PROCESSOR_ARCHITECTURE% >> %QA%\ntfrs_machine.txt
  79. echo NumberProcessors : %NUMBER_OF_PROCESSORS% >> %QA%\ntfrs_machine.txt
  80. echo SystemRoot : %SystemRoot% >> %QA%\ntfrs_machine.txt
  81. )
  82. echo NTFRSUTL checks are running ...
  83. ntfrsutl version %CHKCOMP% > %QA%\ntfrs_version.txt
  84. findstr /c:"ERROR" %QA%\ntfrs_version.txt
  85. if NOT ERRORLEVEL 1 (
  86. echo ****** NTFRSUTL cannot access target computer "%CHKCOMP%".
  87. echo ****** You must be an admin or run HEALTH_CHK on the target computer to gather all the data.
  88. goto :GETREG
  89. )
  90. ntfrsutl ds %CHKCOMP% > %QA%\ntfrs_ds.txt
  91. ntfrsutl sets %CHKCOMP% > %QA%\ntfrs_sets.txt
  92. ntfrsutl configtable %CHKCOMP% > %QA%\ntfrs_config.txt
  93. echo Dumping FRS inbound and outbound logs ...
  94. ntfrsutl inlog %CHKCOMP% > %QA%\ntfrs_inlog.txt
  95. ntfrsutl outlog %CHKCOMP% > %QA%\ntfrs_outlog.txt
  96. :GETREG
  97. echo Dumping FRS registry parameters ...
  98. regdmp -m \\%CHKCOMP% HKEY_LOCAL_MACHINE\system\currentcontrolset\services\NtFrs > %QA%\ntfrs_reg.txt
  99. echo SYSVOL check is running
  100. dir \\%CHKCOMP%\sysvol /s > %QA%\ntfrs_sysvol.txt
  101. REM
  102. REM For DS replication
  103. REM
  104. echo repadmin /showreps %CHKCOMP% is running
  105. repadmin /showreps %CHKCOMP% > %QA%\ds_showreps.txt
  106. echo repadmin /showconn %CHKCOMP% is running
  107. repadmin /showconn %CHKCOMP% > %QA%\ds_showconn.txt
  108. REM
  109. REM Do a simple dump of the 400 most recent records in the event logs.
  110. REM
  111. echo Scanning eventlogs ...
  112. eventdmp /n:400 /l:ntfrs /r:%CHKCOMP% > %QA%\evl_ntfrs.txt
  113. eventdmp /n:400 /l:application /r:%CHKCOMP% > %QA%\evl_application.txt
  114. eventdmp /n:400 /l:system /r:%CHKCOMP% > %QA%\evl_system.txt
  115. eventdmp /n:400 /l:ds /r:%CHKCOMP% > %QA%\evl_ds.txt
  116. eventdmp /n:400 /l:DNS /r:%CHKCOMP% > %QA%\evl_dns.txt
  117. echo Scanning FRS debug logs for error/warning info ...
  118. set XCOMP=%windir%\debug
  119. if /i "%CHKCOMP%" EQU "%COMPUTERNAME%" goto :FOUND
  120. set XCOMP=\\%CHKCOMP%\debug
  121. dir %XCOMP%\ntfrs_*.log 1>nul: 2>nul:
  122. if NOT ERRORLEVEL 1 goto :FOUND
  123. set XCOMP=\\%CHKCOMP%\admin$\debug
  124. dir %XCOMP%\ntfrs_*.log 1>nul: 2>nul:
  125. if NOT ERRORLEVEL 1 goto :FOUND
  126. set XCOMP=\\%CHKCOMP%\C$\winnt\debug
  127. :FOUND
  128. dir %XCOMP%\ntfrs_*.log > %QA%\ntfrs_errscan.txt
  129. if ERRORLEVEL 1 (
  130. echo ****** HEALTH_CHK cannot access the FRS log files on "%XCOMP%".
  131. echo ****** You must be an admin or run HEALTH_CHK on the target computer to gather all the data.
  132. del %QA%\ntfrs_errscan.txt
  133. goto :DONE
  134. )
  135. findstr /i ":SO: :H: error invalid fail abort warn" %XCOMP%\ntfrs_*.log | findstr /v "IO_PEND ERROR_SUCCESS PrintThreadIds FrsErrorSuccess" >> %QA%\ntfrs_errscan.txt
  136. :DONE
  137. echo Done ...
  138. :QUIT