로컬 컴퓨터로 활동 보고서 다운로드 자동화

이 섹션의 스크립트를 사용하여 환경의 활동 보고서를 로컬 컴퓨터로 다운로드하는 프로세스를 자동화할 수 있습니다.

syncAprReports.bat를 사용하여 활동 보고서를 다운로드합니다. Windows 스케줄러를 통해 뱃치 파일을 스케줄하여 활동 보고서 다운로드를 자동화할 수 있습니다. 활동 보고서에 대한 자세한 내용은 관리자용 Oracle Enterprise Performance Management Cloud 시작하기에서 활동 보고서 및 액세스 로그로 사용량 모니터를 참조하십시오.

다음 절차에 제공된 스크립트를 복사한 다음 연결 매개변수를 업데이트하여 수동으로 syncAprReports.bat를 생성합니다. 이 스크립트는 환경을 확인하고 로컬 컴퓨터의 다운로드 디렉토리에서 사용할 수 있는 보고서보다 최신 버전인 보고서만 다운로드합니다.

주:

  • Windows 컴퓨터에서만 스크립트를 실행해야 합니다.
  • 이 스크립트는 사용자가 피드백을 제출할 때 생성되는 피드백 활동 보고서를 다운로드하지 않습니다.
  • 사용하는 비밀번호에 특수 문자가 포함된 경우 특수 문자 처리를 참조하십시오.
  1. 다음 스크립트를 포함하는 syncAprReports.bat라는 뱃치(.BAT) 파일을 생성한 후 C:\automate_scripts 등의 편리한 위치에 저장합니다.
    @echo off
    title APR
    setlocal DisableDelayedExpansion
    
    REM To hardcode the values in the script replace %1, %2, %3, and %4, with the actual values.
    REM Example:
    REM set apr_dir="C:\Oracle\apr"
    REM set username="serviceAdmin"
    REM set password="Ex@mple!"
    REM set url="https://test-example.stg-pbcs.us1.oraclecloud.com"
    set apr_dir=%1
    set username=%2
    set password=%3
    set url=%4
    setlocal EnableDelayedExpansion
    set epmautomate_dir=%cd%
    set lastfile=
    set argC=0
    for %%x in (%*) do Set /A argC+=1
    if %argC% neq 0 (
            if %argC% neq 3 (
                    if %argC% neq 4 (
                            goto :usage
                    )
            )
    )
    goto :login
    :usage
    echo.
    echo Invalid syntax. Please check the parameters. 
    echo Syntax:
    echo 1) syncAprReports.bat APR_FolderPath_on_client username password url
    echo     or 
    echo 2) set the parameters in the file and use below syntax
    echo    syncAprReports.bat
    goto :end
    
    :login
    setlocal DisableDelayedExpansion
    for /f "delims=" %%i in ('epmautomate login %username% %password% %url%') do set result=%%i
    if "Login successful" neq "%result%" (
            echo Login Failed
            goto :end
    ) 
    
    if not exist %apr_dir% (
    echo.
    echo apr folder does not exist 
    GOTO :end
    )
    cd /D %apr_dir%
    for /f "delims=" %%D in ('dir /a:d /b /o:-n') do ( 
    REM AFTER: for /f "delims=" %%D in ('dir /a-d /b /s /o:-n') do (
            set "lastFile=%%~nD"
            goto :next
    )
    
    :next
    setlocal EnableDelayedExpansion
    echo.
    echo Most Recent APR on client is %lastFile%
    
    set "output_cnt=0"
    cd /D %epmautomate_dir%
    for /F "delims=" %%f in ('epmautomate listfiles') do (
    
            cd /D !apr_dir!
            set "line=%%f"
            for /f "tokens=* delims= " %%a in ("!line!") do set line=%%a
            if "!line:~0,3!" equ "apr" (
    
                    if "!line:~4,8!" neq "Feedback" (
    
                            set isValidFile=false
                            if "!line:~-5!" equ ".html" set isValidFile=true
                            if "!line:~-5!" equ ".json" set isValidFile=true
    
                            if "!isValidFile!" equ "true" (
                                    
                                    if "%lastFile%" lss "!line:~4,19!" (
                                            
                                                    if "!line:~4,19!" neq "!dirname!" (
                                                            
                                                            set apr_dir=!apr_dir:"=!
                                                            set /a output_cnt+=1
                                                            set "output[!output_cnt!]=!apr_dir!\!line:~4,19!"
                                                            set "dirname=!line:~4,19!"
                                                            
                                                            REM start downloading
                                                            mkdir "!dirname!"
                                                            cd /D !dirname!
                                                            echo downloading !line!
                                                            set "downloadDir=!apr_dir!\!dirname!"
                                                                                    
                                                            cd /D %epmautomate_dir%
                                                            for /f "delims=" %%i in ('epmautomate downloadfile "!line!"') do set result1=%%i
                                                            move "!line:~24!" "!downloadDir!" > nul
                                                            echo !result1!
                                                            REM end downloading
                                                            
                                                    ) else (
                                                    
                                                            REM start downloading
                                                            cd /D !dirname!
                                                            echo downloading !line!
                                                            set apr_dir=!apr_dir:"=!
                                                            set "downloadDir=!apr_dir!\!dirname!"
                                                            cd /D %epmautomate_dir%
                                                            for /f "delims=" %%i in ('epmautomate downloadfile "!line!"') do set result1=%%i
                                                            move "!line:~24!" "!downloadDir!" > nul
                                                            echo !result1!
                                                            REM end downloading
                                                            
                                                    )
                                    ) else (
                                    
                                            REM TO-DO
                                            
                                    )
                            )
                    )
            )
    )
    
    echo.
    echo %output_cnt% APR's downloaded
    for /L %%n in (1 1 !output_cnt!) DO echo !output[%%n]!
    goto :end
    
    :end
    cd /D %epmautomate_dir%
    endlocal
  2. syncAprReports.bat를 수정하여 다음 표의 매개변수 값을 설정합니다. 이러한 값은 환경에 액세스하여 활동 보고서를 다운로드하는 데 사용됩니다.

    표 3-3 syncAprReports.bat에 포함할 매개변수 값

    매개변수 예상 값
    set apr_dir=%1 활동 보고서를 다운로드할 기존 디렉토리를 지정합니다.

    예: set apr_dir="C:\Oracle\apr"

    set username=%2 환경에 사인인하여 활동 보고서를 다운로드하는 데 사용되는 Oracle Enterprise Performance Management Cloud 사용자 이름입니다.

    예: set username="ServiceAdmin"

    set password=%3

    username 변수로 지정된 사용자의 암호화된 비밀번호를 저장하는 파일의 이름 및 위치입니다. 사용자의 일반 텍스트 비밀번호를 지정할 수도 있습니다(권장되지 않음). 암호화된 비밀번호 파일을 생성하는 방법에 대한 자세한 내용은 encrypt 명령을 참조하십시오.

    예:

    set password="C:\mySecuredir\password.epw"

    set password="Ex@mple1"

    set url=%4 환경의 URL입니다.

    예: set url="https://test-example.stg-pbcs.us1.oraclecloud.com"

  3. Windows 스케줄러를 사용하여 syncAprReports.bat를 스케줄합니다. 자세한 단계는 스크립트 실행 자동화를 참조하십시오.