1.1.4.1. ログ収集サーバーに、curlがインストールされていることを確認する

ログ収集サーバーに、APIの利用に必要となるcurlがインストールされていることを確認します。
SDPFクラウド/サーバーのCentOSには、初期状態でcurlがインストールされているため、確認のみ実施します。
  1. 以下のコマンドを実行し、curlのバージョンが表示されることを確認します。

    # curl --version
    

1.1.4.2. ログを収集するシェルスクリプトを作成する

下記の「表: シェルスクリプト一覧」に記載のシェルスクリプトを作成し、cronにより定期実行してログを収集します。

表: シェルスクリプト一覧
名称 説明
/usr/local/sbin/sdpf-token-create.sh APIの実行に必要となるトークンを生成します。
/usr/local/sbin/show-fic-ocn-traffic.sh
Flexible InterConnectの下記のAPIを利用してログを取得します。
Flexible InterConnect Support-Monitoring API
/usr/local/sbin/show-ocn-traffic-bps-trend.sh
Super OCN Flexible Connectの下記のAPIを利用してログを取得します。
Routings Traffic bps Trend API

/usr/local/sbin/sdpf-token-create.shの作成

注釈

  • シェルスクリプト内の「API鍵」および「API秘密鍵」、「テナントID」は、ご利用の環境にあわせて修正してください。
  1. 以下のコマンドを実行し、シェルスクリプトを作成します。

    # cd /usr/local/sbin
    # touch sdpf-token-create.sh
    # chmod 700 sdpf-token-create.sh
    # vi sdpf-token-create.sh
    #!/bin/bash
    
    curl -s -i \
    -H “content-type: application/json” \
    -d ‘
    {
     “auth”: {
           “identity”: {
                      “methods”: [
                                  “password”
                      ],
                                  “password”: {
                                       “user”: {
                                             “domain”: {
                                                  “id”: “default”
                                             },
                                               “name”: “API鍵”,
                                           “password”: “API秘密鍵”
                                       }
                                  }
           },
           “scope”: {
              “project”: {
                   “id”: “テナントID”
              }
           }
     }
    }’ https://api.ntt.com/keystone/v3/auth/tokens
    

/usr/local/sbin/show-fic-ocn-traffic.shの作成

注釈

  • シェルスクリプト内の「テナントID」および「コネクション」は、ご利用の環境にあわせて修正してください。
  1. 以下のコマンドを実行し、シェルスクリプトを作成します。

    # cd /usr/local/sbin
    # touch show-fic-ocn-traffic.sh
    # chmod 700 show-fic-ocn-traffic.sh
    # vi show-fic-ocn-traffic.sh
    #!/bin/bash
    TOKEN=`/usr/local/sbin/sdpf-token-create.sh | grep x-subject-token | awk ‘{print $2}`
    
    curl -s \
    -X GET \
    -H “x-auth-token: ${TOKEN}\
    -H “content-type: application/json” \
    https://api.ntt.com/fic-monitoring/v1/flexible-ic/tenants/テナントID/connections/コネクションID/counts
    

/usr/local/sbin/show-ocn-traffic-bps-trend.shの作成

注釈

  • シェルスクリプト内の「テナントID」は、ご利用の環境にあわせて修正してください。
  1. 以下のコマンドを実行し、シェルスクリプトを作成します。

    # cd /usr/local/sbin
    # touch show-ocn-traffic-bps-trend.sh
    # chmod 700 show-ocn-traffic-bps-trend.sh
    # vi show-ocn-traffic-bps-trend.sh
    #!/bin/bash
    TOKEN=`/usr/local/sbin/sdpf-token-create.sh | grep x-subject-token | awk ‘{print $2}`
    
    curl -s \
    -X GET \
    -H “x-auth-token: ${TOKEN}\
    -H “content-type: application/json” \
    https://api.ntt.com/ocnx-transit/v1/tenants/テナントID/monitorings/traffic-trends/routings