アクティビティ・レポートのローカル・コンピュータへのダウンロード自動化

この項のスクリプトを使用して、環境からローカル・コンピュータへのアクティビティ・レポートのダウンロードを自動化します。

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をスケジュールします。詳細なステップは、スクリプトの実行の自動化を参照してください。