ansibleを使って、iperfでalway free間のネットワークスループットを計測する

Oracle Cloud always free Advent Calendar 2019の9日目です。

 

本日は、iperfでalway free間のネットワークスループットを計測してみます。
2台でiperfのインストール、firewalldのポート開放などがあるので、ansibleでやってみます。

 

〇セキュリティリストの確認
oracle cloudコンソールから
ネットワーキング-仮想クラウド・ネットワーク-VirtualCloudNetwork-XXXXXXXを選択
パブリック・パブリックサブネットをクリック
Default Security List for VirtualCloudNetwork-XXXXXXXXXをクリック

イングレス・ルールに以下があることを確認
ソース 10.0.0.0/24
IPプロトコル すべて

 

#作業用ディレクトリの作成
[opc@docker ~]$ mkdir iperf3
[opc@docker ~]$ cd iperf3
[opc@docker iperf3]$

 

#hostsファイルの作成
#iperfのサーバ、クライアントのIPを変数化
export iperfserver="10.0.0.3"
export iperfclient="10.0.0.5"

 

#ansible hostファイルの作成
#ここでSSHポート(54222)、秘密鍵の指定
cat <<EOF > hosts
[iperfserver]
$iperfserver
[iperfclient]
$iperfclient

[all:vars]
ansible_port=54222
ansible_user=opc
ansible_ssh_private_key_file=~/id_rsa2
EOF

 

 

#ansible-playbookの作成
cat <<EOF > iperf.yml
- hosts: all
  become: yes
  tasks:
  - name: install iperf3
    yum:
        name:
        - iperf3

  - name: firewalld 5201/tcp
    firewalld:
      port: 5201/udp
      permanent: yes
      state: enabled
      immediate: true

  - name: firewalld 5201/udp
    firewalld:
      port: 5201/tcp
      permanent: yes
      state: enabled
      immediate: true

 

- hosts: iperfserver
  become: yes
  tasks:
  - name: start server iperf
    shell: iperf3 --server --one-off --daemon

 

- hosts: iperfclient
  become: yes
  tasks:
  - name: start client iperf
    shell: iperf3 --client {{ hostvars[groups['iperfserver'][0]]['ansible_ens3']['ipv4']['address'] }} --time 60
    register: iperf_result

  - debug: var=iperf_result.stdout_lines
EOF

 

 

#ansible-playbookの実行
[opc@docker iperf3]$ ansible-playbook -i hosts iperf.yml
PLAY [all] ***********************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************
ok: [10.0.0.5]
ok: [10.0.0.3]
・・・
TASK [start client iperf] ********************************************************************************************************************************
changed: [10.0.0.5]

TASK [debug] *********************************************************************************************************************************************
ok: [10.0.0.5] => {
"iperf_result.stdout_lines": [
"Connecting to host 10.0.0.3, port 5201",
"[ 4] local 10.0.0.5 port 29044 connected to 10.0.0.3 port 5201",
"[ ID] Interval Transfer Bandwidth Retr Cwnd",
"[ 4] 0.00-1.00 sec 88.4 MBytes 741 Mbits/sec 1067 332 KBytes ",
"[ 4] 1.00-2.00 sec 56.2 MBytes 472 Mbits/sec 692 393 KBytes ",
"[ 4] 2.00-3.00 sec 57.5 MBytes 482 Mbits/sec 895 131 KBytes ",
"[ 4] 3.00-4.00 sec 56.2 MBytes 472 Mbits/sec 615 43.7 KBytes ",
"[ 4] 4.00-5.00 sec 47.5 MBytes 398 Mbits/sec 461 280 KBytes ",
"[ 4] 5.00-6.00 sec 36.2 MBytes 304 Mbits/sec 367 568 KBytes ",
"[ 4] 6.00-7.00 sec 80.0 MBytes 671 Mbits/sec 1370 78.6 KBytes ",
"[ 4] 7.00-8.00 sec 46.2 MBytes 388 Mbits/sec 415 17.5 KBytes ",
"[ 4] 8.00-9.00 sec 63.8 MBytes 535 Mbits/sec 1060 78.6 KBytes ",
"[ 4] 9.00-10.00 sec 55.0 MBytes 461 Mbits/sec 500 96.1 KBytes ",
"[ 4] 10.00-11.00 sec 51.2 MBytes 430 Mbits/sec 425 315 KBytes ",
"[ 4] 11.00-12.00 sec 61.2 MBytes 514 Mbits/sec 676 603 KBytes ",
"[ 4] 12.00-13.00 sec 61.2 MBytes 514 Mbits/sec 674 1.08 MBytes ",
"[ 4] 13.00-14.00 sec 50.0 MBytes 419 Mbits/sec 760 175 KBytes ",
"[ 4] 14.00-15.00 sec 55.0 MBytes 461 Mbits/sec 464 61.2 KBytes ",
"[ 4] 15.00-16.00 sec 65.0 MBytes 545 Mbits/sec 793 848 KBytes ",
"[ 4] 16.00-17.00 sec 53.8 MBytes 451 Mbits/sec 591 69.9 KBytes ",
"[ 4] 17.00-18.00 sec 52.5 MBytes 440 Mbits/sec 819 166 KBytes ",
"[ 4] 18.00-19.00 sec 67.5 MBytes 566 Mbits/sec 691 8.74 KBytes ",
"[ 4] 19.00-20.00 sec 57.5 MBytes 482 Mbits/sec 483 87.4 KBytes ",
"[ 4] 20.00-21.00 sec 53.8 MBytes 451 Mbits/sec 369 874 KBytes ",
"[ 4] 21.00-22.00 sec 47.5 MBytes 398 Mbits/sec 661 8.74 KBytes ",
"[ 4] 22.00-23.00 sec 68.8 MBytes 577 Mbits/sec 673 35.0 KBytes ",
"[ 4] 23.00-24.00 sec 57.5 MBytes 481 Mbits/sec 584 463 KBytes ",
"[ 4] 24.00-25.00 sec 56.2 MBytes 473 Mbits/sec 720 140 KBytes ",
"[ 4] 25.00-26.00 sec 56.2 MBytes 472 Mbits/sec 773 35.0 KBytes ",
"[ 4] 26.00-27.00 sec 51.2 MBytes 430 Mbits/sec 437 629 KBytes ",
"[ 4] 27.00-28.00 sec 62.5 MBytes 524 Mbits/sec 734 114 KBytes ",
"[ 4] 28.00-29.00 sec 48.8 MBytes 409 Mbits/sec 617 184 KBytes ",
"[ 4] 29.00-30.00 sec 57.5 MBytes 482 Mbits/sec 561 489 KBytes ",
"[ 4] 30.00-31.00 sec 65.0 MBytes 545 Mbits/sec 717 43.7 KBytes ",
"[ 4] 31.00-32.00 sec 51.2 MBytes 430 Mbits/sec 529 61.2 KBytes ",
"[ 4] 32.00-33.00 sec 61.2 MBytes 514 Mbits/sec 764 26.2 KBytes ",
"[ 4] 33.00-34.00 sec 52.5 MBytes 440 Mbits/sec 352 778 KBytes ",
"[ 4] 34.00-35.00 sec 61.2 MBytes 514 Mbits/sec 534 253 KBytes ",
"[ 4] 35.00-36.00 sec 56.2 MBytes 472 Mbits/sec 917 114 KBytes ",
"[ 4] 36.00-37.00 sec 52.5 MBytes 440 Mbits/sec 769 69.9 KBytes ",
"[ 4] 37.00-38.00 sec 53.8 MBytes 451 Mbits/sec 520 481 KBytes ",
"[ 4] 38.00-39.00 sec 52.5 MBytes 440 Mbits/sec 613 638 KBytes ",
"[ 4] 39.00-40.00 sec 67.5 MBytes 566 Mbits/sec 771 1.20 MBytes ",
"[ 4] 40.00-41.00 sec 56.2 MBytes 472 Mbits/sec 686 1014 KBytes ",
"[ 4] 41.00-42.00 sec 56.2 MBytes 472 Mbits/sec 665 78.6 KBytes ",
"[ 4] 42.00-43.00 sec 60.0 MBytes 503 Mbits/sec 778 26.2 KBytes ",
"[ 4] 43.00-44.00 sec 45.0 MBytes 377 Mbits/sec 384 8.74 KBytes ",
"[ 4] 44.00-45.00 sec 67.5 MBytes 566 Mbits/sec 384 1.38 MBytes ",
"[ 4] 45.00-46.00 sec 56.2 MBytes 471 Mbits/sec 896 35.0 KBytes ",
"[ 4] 46.00-47.00 sec 56.2 MBytes 473 Mbits/sec 540 96.1 KBytes ",
"[ 4] 47.00-48.00 sec 57.5 MBytes 482 Mbits/sec 487 253 KBytes ",
"[ 4] 48.00-49.00 sec 53.8 MBytes 451 Mbits/sec 578 61.2 KBytes ",
"[ 4] 49.00-50.00 sec 51.2 MBytes 430 Mbits/sec 595 533 KBytes ",
"[ 4] 50.00-51.00 sec 60.0 MBytes 503 Mbits/sec 730 1.12 MBytes ",
"[ 4] 51.00-52.00 sec 62.5 MBytes 524 Mbits/sec 1042 551 KBytes ",
"[ 4] 52.00-53.00 sec 57.5 MBytes 482 Mbits/sec 646 69.9 KBytes ",
"[ 4] 53.00-54.00 sec 56.2 MBytes 472 Mbits/sec 473 87.4 KBytes ",
"[ 4] 54.00-55.00 sec 53.8 MBytes 451 Mbits/sec 563 944 KBytes ",
"[ 4] 55.00-56.00 sec 55.0 MBytes 461 Mbits/sec 531 78.6 KBytes ",
"[ 4] 56.00-57.00 sec 55.0 MBytes 462 Mbits/sec 274 52.4 KBytes ",
"[ 4] 57.00-58.00 sec 51.2 MBytes 430 Mbits/sec 687 245 KBytes ",
"[ 4] 58.00-59.00 sec 68.8 MBytes 577 Mbits/sec 746 166 KBytes ",
"[ 4] 59.00-60.00 sec 51.2 MBytes 430 Mbits/sec 398 717 KBytes ",
"- - - - - - - - - - - - - - - - - - - - - - - - -",
"[ ID] Interval Transfer Bandwidth Retr",
"[ 4] 0.00-60.00 sec 3.35 GBytes 479 Mbits/sec 38516 sender",
"[ 4] 0.00-60.00 sec 3.34 GBytes 479 Mbits/sec receiver",
"",
"iperf Done."
]
}

PLAY RECAP ***********************************************************************************************************************************************
10.0.0.3 : ok=6 changed=3 unreachable=0 failed=0
10.0.0.5 : ok=7 changed=3 unreachable=0 failed=0

 


Bandwidthがsender/receiverともに479 Mbits/secとなっています。
https://docs.oracle.com/cd/E97706_01/Content/Compute/References/computeshapes.htm
によるとVM.Standard.E2.1.Microのネットワーク帯域幅は480 Mbpsなので、そのままの結果になったと思います。