db_main.cmd 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. @Echo off
  2. SetLocal EnableDelayedExpansion
  3. SetLocal EnableExtensions
  4. rem Setting working directory
  5. echo !CT_TMP!
  6. set "CT_OUTPUT=!CT_TMP!"
  7. set "CT_TMP_DB=!CT_TMP!CTDB"
  8. if not exist "%CT_TMP_DB%" ( mkdir "%CT_TMP_DB%" )
  9. rem if not exist "%CT_OUTPUT%" ( mkdir "%CT_OUTPUT%" )
  10. set "CT_HOME=%CD%"
  11. set "CT_EXEC_HOME=%CT_HOME%\..\resources\util\db"
  12. rem Copying sql and cmd files
  13. copy "%CT_EXEC_HOME%"\*.sql "%CT_TMP_DB%"
  14. copy "%CT_EXEC_HOME%"\*.cmd "%CT_TMP_DB%"
  15. set "SQLSCRIPT=db_conn_coll_main.sql"
  16. set "REMOTE_DB=!REMOTE_DB!"
  17. set "DB_CT_BUILD_VERSION=!CT_BUILD_VERSION!"
  18. set "DBLICAGREE=!LICAGREE!"
  19. if "%DBLICAGREE%" == "True" ( set "DBLICAGREE=YES" ) else (
  20. set "DBLICAGREE=NO" )
  21. set "DBALLPRODLIST=!ALLPRODLIST!"
  22. IF /i "%DBALLPRODLIST:EBS=%"=="%DBALLPRODLIST%" ( set "DBALLPRODLIST=DB" ) else ( set "DBALLPRODLIST=EBS~DB" )
  23. set "current_dir=%CT_OUTPUT%"
  24. set "working_dir=%CT_TMP_DB%"
  25. set "DB_output_dir=%CT_OUTPUT%DB"
  26. set "EBS_output_dir=%CT_OUTPUT%EBS"
  27. set "DBA_FUS_output_dir=%CT_OUTPUT%DBA_FUS"
  28. set "logs_output_dir=%CT_OUTPUT%logs"
  29. if not exist "%logs_output_dir%" ( mkdir "%logs_output_dir%" )
  30. if exist "%logs_output_dir%\DB_*.log" ( del "%logs_output_dir%\DB_*.log")
  31. if exist "%logs_output_dir%\EBS_*.log" ( del "%logs_output_dir%\EBS_*.log")
  32. cd /d "%working_dir%"
  33. set "mypath=%cd%"
  34. if exist db_con_coll.log (type db_con_coll.log >>db_con_coll.temp )
  35. if exist *.txt (del *.txt)
  36. if exist *.log (del *.log)
  37. echo Script version= %DB_CT_BUILD_VERSION% >> db_con_coll.log
  38. echo %COMPUTERNAME%>>db_con_coll.log
  39. call look_for_running_sids.cmd %SQLSCRIPT% %DBLICAGREE% %DBALLPRODLIST%
  40. call db_conn_coll.cmd y db_list.csv
  41. dir /s >> db_con_coll.log
  42. call logcolstat.cmd DB YES
  43. if exist "%mypath%\DB" (
  44. cd DB
  45. if not exist "%DB_output_dir%" ( mkdir "%DB_output_dir%" )
  46. for /f "delims=" %%a in ( 'dir /ad /b /s' ) do (
  47. for /f "delims=" %%F in ("%%a") do (
  48. if exist "%DB_output_dir%\%%~nxF" ( rd /S /Q "%DB_output_dir%\%%~nxF" )
  49. move "%%a" "%DB_output_dir%"
  50. )
  51. )
  52. cd ..
  53. )
  54. if exist "%mypath%\DBA_FUS" (
  55. cd DBA_FUS
  56. if not exist "%DBA_FUS_output_dir%" ( mkdir "%DBA_FUS_output_dir%" )
  57. for /f "delims=" %%a in ( 'dir /ad /b /s' ) do (
  58. for /f "delims=" %%F in ("%%a") do (
  59. if exist "%DBA_FUS_output_dir%\%%~nxF" ( rd /S /Q "%DBA_FUS_output_dir%\%%~nxF" )
  60. move "%%a" "%DBA_FUS_output_dir%"
  61. )
  62. )
  63. cd ..
  64. )
  65. if exist "%mypath%\EBS" ( cd EBS
  66. if not exist "%EBS_output_dir%" ( mkdir "%EBS_output_dir%" )
  67. for /f "delims=" %%a in ( 'dir /ad /b /s' ) do (
  68. for /f "delims=" %%F in ("%%a") do (
  69. if exist "%EBS_output_dir%\%%~nxF" ( rd /S /Q "%EBS_output_dir%\%%~nxF" )
  70. move "%%a" "%EBS_output_dir%"
  71. )
  72. )
  73. cd ..
  74. )
  75. rem remove deplicates
  76. if exist DB_errors.log ( if exist DB_collected.log (
  77. for /F "tokens=5" %%a in (DB_collected.log) do (
  78. type DB_errors.log | findstr /V /I /C:" %%a " > err_tmp.log
  79. )
  80. )
  81. move err_tmp.log DB_errors.log
  82. )
  83. dir /s %current_dir%DB %current_dir%DBA_FUS %current_dir%EBS >> db_con_coll.log
  84. type db_con_coll.log >> db_con_coll.temp
  85. copy db_con_coll.temp db_con_coll.log
  86. del db_con_coll.temp
  87. copy db_con_coll.log "!logs_output_dir!"
  88. copy db_list.csv "!logs_output_dir!"
  89. del db_list.csv
  90. copy *.csv %DB_output_dir%
  91. if exist DB_collected.log (copy DB_collected.log "!logs_output_dir!" )
  92. if exist DB_errors.log (copy DB_errors.log "!logs_output_dir!" )
  93. if exist DB_warnings.log (copy DB_warnings.log "!logs_output_dir!" )
  94. if exist EBS_collected.log (copy EBS_collected.log "!logs_output_dir!" )
  95. if exist EBS_errors.log (copy EBS_errors.log "!logs_output_dir!" )
  96. if exist EBS_warnings.log (copy EBS_warnings.log "!logs_output_dir!" )
  97. del checkconn.txt
  98. cd /d "%current_dir%"
  99. echo %cd%
  100. echo %CT_TMP_DB%
  101. rd /S /Q %CT_TMP_DB%
  102. EndLocal