【BIG-IP】よく使用するCLI コマンド Version: 16.1.2

BIG-IP のソフトウェアは CentOS(Red Hat 系)をベースにしていて、Linux の bash に加えて、BIG-IP 専用のシェル tmsh(Traffic Management Shell)で BIG-IP の設定や状態確認ができます。この記事では、BIG-IP の運用や検証でよく使う CLI コマンドを、用途ごとに実際の出力と一緒にまとめます。

この記事でわかること
  1. shell モード(bash)と tmsh モードの切り替え方
  2. ページングの無効化、grep、Tab キーと help の使い方
  3. 設定の追加・削除・変更・保存(create/delete/modify/save)
  4. 設定と状態の確認(list/show):ハードウェア、ネットワーク、LTM、パフォーマンス
  5. リアルタイムの監視(tmstat/bigtop)、ログ、再起動・シャットダウン
検証環境

AWS 上の BIG-IP Virtual Edition 16.1.2 で検証しています。16.1 系はすでに F5 のサポート期間が終わっているので、これから構築する場合はサポート中のバージョンを選んでください。

実際のプロンプトは長いので、この記事では次のように省略して書きます。

[admin@bigip-1:Active:Standalone] ~ #  → #
admin@(bigip-1)(cfg-sync Standalone)(Active)(/Common)(tmos)#  → (tmos)#
  1. 基本操作
    1. shell モード
    2. tmsh モード
    3. ページングの無効化(modify cli preference pager)
    4. 出力を条件で絞り込む(grep)
  2. ヘルプ(help)
    1. Tab キー
    2. コマンドヘルプ(help)
  3. shell モードのコマンド
    1. ネットワーク診断(ping/traceroute)
    2. IPv4 アドレスの表示(ip)
    3. パケットのキャプチャ(tcpdump)
    4. ディスク使用量(df)
    5. メモリの空き状況(free)
  4. 設定の追加・削除・変更(create/delete/modify)
    1. 設定の追加(create)
    2. 設定の削除(delete)
    3. 設定の変更(modify)
    4. 設定の保存(save sys config)
  5. 設定情報の確認(list)
    1. 稼働中の設定(list/show running-config)
    2. モジュールごとの設定(list <module>)
  6. システム・ハードウェア情報(show sys)
    1. バージョン(show sys version)
    2. ライセンス(show sys license)
    3. ハードウェア(show sys hardware)
  7. ネットワーク情報(show net)
    1. インタフェース(show net interface)
    2. ARP テーブル(show net arp)
    3. ルーティングテーブル(show net route)
  8. LTM の情報(show ltm)
    1. Node(show ltm node)
    2. Pool(show ltm pool)
    3. Virtual Server(show ltm virtual)
    4. パーシステンス(show ltm persistence persist-records)
  9. パフォーマンス情報
    1. CPU 使用率(show sys cpu)
    2. メモリ使用率(show sys memory)
    3. CPU とメモリ(show sys performance system)
    4. スループット(show sys performance throughput)
    5. 接続数(show sys performance connections)
    6. 接続の一覧(show sys connection)
    7. リアルタイムの負荷状況(tmstat)
    8. リアルタイムの接続状況(bigtop)
  10. ログ
    1. ログの参照(show sys log)
    2. リアルタイムのログ参照(tail -f)
  11. 再起動・シャットダウン
    1. 再起動(reboot)
    2. シャットダウン(shutdown)
  12. まとめ

基本操作

shell モード

ログイン直後の shell モードでは bash のコマンドが使えます。/etc/redhat-release を見ると、CentOS がベースになっていることがわかります。

[admin@bigip-1:Active:Standalone] ~ # cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core)

tmsh モード

BIG-IP 専用のコマンドを使うには、tmsh と打って tmsh モードに移ります。プロンプトの最後が (tmos)# に変わります。tmsh モードで bash と打つと、shell モードに移ります。

[admin@bigip-1:Active:Standalone] ~ # tmsh
admin@(bigip-1)(cfg-sync Standalone)(Active)(/Common)(tmos)# bash
[admin@bigip-1:Active:Standalone] ~ #

shell モードのまま、コマンドの先頭に tmsh を付けて実行することもできます。1つだけ確認したいときに便利です。

[admin@bigip-1:Active:Standalone] ~ # tmsh show sys version

Sys::Version
Main Package
  Product     BIG-IP
  Version     16.1.2.1
  Build       0.0.10
  Edition     Point Release 1
  Date        Wed Dec 22 17:39:05 PST 2021
shell モード(bash)[admin@bigip-1:…] ~ #Linux のコマンドping/tcpdump/df/tail などtmsh モード…(tmos)#BIG-IP のコマンドlist/show/create/modify などtmshbashshell モードのまま tmsh を1回だけ使う:tmsh show sys version のように先頭に tmsh を付ける
図1 shell モードと tmsh モード

ページングの無効化(modify cli preference pager)

初期状態では、出力が長いと1画面ごとに止まり、キーを押してページを送ります。ログを取るときなど、まとめて出したい場合は tmsh モードでページングを無効にします。

(tmos)# modify cli preference pager disabled

元に戻すときは enabled にします。

(tmos)# modify cli preference pager enabled

出力を条件で絞り込む(grep)

tmsh の出力も、| grep で条件に合う行だけを取り出せます。次の例は、LTM のログから 10.0.2.24 を含む行だけを表示しています。

(tmos)# show sys log ltm | grep  10.0.2.24
ltm 04-23 06:42:50 notice bigip-1.hirotanoblog.local mcpd[7278]: 
Node /Common/Web-01 address 10.0.2.24 monitor status up. [ /Common/icmp: up ]  
[ was up for 0hr:0min:56sec ] 
ltm 04-23 13:31:21 notice bigip-1.hirotanoblog.local mcpd[7311]: 
Node /Common/Web-01 address 10.0.2.24 monitor status down. [ /Common/icmp: down ]  
[ was up for 0hr:1min:11sec ] 
ltm 04-23 14:36:27 notice bigip-1.hirotanoblog.local mcpd[7304]: 
Node /Common/Web-01 address 10.0.2.24 monitor status down. [ /Common/icmp: down ]  
[ was up for 0hr:1min:8sec ] 
ltm 05-08 02:22:23 notice bigip-1.hirotanoblog.local mcpd[7276]: 
Node /Common/Web-01 address 10.0.2.24 monitor status up. [ /Common/icmp: up ]  
[ was up for 0hr:0min:49sec ]

ヘルプ(help)

tmsh には、入力できる値を表示する Tab キーの補完と、コマンドのマニュアルを表示する help があります。コマンドの書き方に迷ったときに使います。

Tab キー

コマンドの途中で Tab キーを押すと、次に入力できる値の一覧が表示されます。

(tmos)# show sys  TABキーを押す 
Options:
  current-module    recursive         |                 
Modules:
  alert             disk              icall             performance       software          
  crypto            dynad             ipfix             raid              turboflex         
  diags             fpga              nethsm            sflow             
Components:
  availability      fix-connection    ip-address        pptp-call-info    tmm-traffic       
  clock             ha-group          ip-stat           proc-info         traffic           
  cluster           ha-mirror         iprep-status      provision         ucs               
  config-diff       ha-status         license           pva-traffic       version           
  connection        hardware          log               ready             
  console           host-info         mac-address       service           
  cpu               hypervisor-info   mcp-state         sync-sys-files    
  failover          icmp-stat         memory            tmm-info

コマンドヘルプ(help)

help だけを実行すると、ヘルプのある項目(General、Commands、Modules など)の一覧が表示されます。

(tmos)# help Enterキーを押す 

Help is available on the following topics

General:       
  glob                     regex                        tmsh
  grep                     time                       

Commands:      
  cd                       load                         run
  cp                       modify                       save
  create                   mv                           send-mail
  delete                   publish                      show
  edit                     pwd                          shutdown
  exit                     quit                         start
  generate                 reboot                       stop
  help                     reset-stats                  submit
  install                  restart                      uninstall
  list                     revoke                     

Modules:
  auth
  cert-ldap                password-policy              source
  ldap                     radius                       tacacs
  login-failures           radius-server                user
  partition                remote-role                
  password                 remote-user
.
.

help の後ろに続けられる値も、Tab キーで確認できます。

(tmos)# help  TABキーを押す 
Options:
  search        
Modules:
  auth          cm            mgmt          security      util          
  cli           ltm           net           sys           wom           
Commands:
  cd            exit          load          quit          run           start         
  cp            generate      modify        reboot        save          stop          
  create        help          mv            reset-stats   send-mail     submit        
  delete        install       publish       restart       show          uninstall     
  edit          list          pwd           revoke        shutdown      
General:
  glob          grep          regex         time          tmsh

たとえば help show を実行すると、show コマンドのマニュアルが表示されます。

(tmos)# help show Enterキーを押す
show(1)                                                                BIG-IP TMSH Manual                                                                show(1)

NAME
       show command - Displays statistics for and the status of specified
       components.

MODULE
       All tmsh modules.

SYNTAX
       Use the show command within a tmsh module to display statistics for and
       the status of components in that module. To display statistics for and
       the status of components in another module, use the full path to the
       component.

        show
        show [component]
        show [component] [name]
        show / [module] [component] [name]
          options:
            all-stats
            current-module
            (default | exa | gig | kil | meg | peta | raw | tera | yotta | zetta)
            (detail | global | historical)
            field-fmt
            running-config
            recursive
.
.

help の詳しい使い方は、F5 のナレッジ K20393414: Using the tmsh Help feature にまとまっています。

shell モードのコマンド

shell モードでは、Linux の一般的なコマンドが使えます。

ネットワーク診断(ping/traceroute)

# ping www.google.com
PING www.google.com (142.251.42.132) 56(84) bytes of data.
64 bytes from nrt12s45-in-f4.1e100.net (142.251.42.132): icmp_seq=1 ttl=103 time=1.20 ms
64 bytes from nrt12s45-in-f4.1e100.net (142.251.42.132): icmp_seq=2 ttl=103 time=1.35 ms
64 bytes from nrt12s45-in-f4.1e100.net (142.251.42.132): icmp_seq=3 ttl=103 time=1.14 ms
64 bytes from nrt12s45-in-f4.1e100.net (142.251.42.132): icmp_seq=4 ttl=103 time=1.32 ms
^C
--- www.google.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 1.149/1.257/1.358/0.091 ms
# traceroute www.google.com
traceroute to www.google.com (142.251.42.132), 30 hops max, 60 byte packets
 1  54.150.128.93 (54.150.128.93)  1.448 ms 54.150.128.93 (54.150.128.81)  7.486 ms 54.150.128.93 (54.150.128.19)  100.765 ms
 2  100.65.27.0 (100.65.27.0)  6.879 ms 100.65.26.160 (100.65.26.160)  7.739 ms 100.65.27.144 (100.65.27.144)  5.662 ms
 3  100.66.12.190 (100.66.12.190)  5.378 ms 100.66.12.90 (100.66.12.90)  7.664 ms 100.66.12.216 (100.66.12.216)  1.828 ms
 4  100.66.15.160 (100.66.15.160)  27.006 ms 100.66.14.232 (100.66.14.232)  59.029 ms 100.66.14.100 (100.66.14.100)  18.188 ms
・・・

IPv4 アドレスの表示(ip)

Linux から見えるインタフェースと IPv4 アドレスを表示します。mgmt は管理ポート、external は VLAN external のアドレスです。

# ip -f inet addr show        
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
    inet 127.0.0.1/24 scope host lo
       valid_lft forever preferred_lft forever
    inet 127.2.0.2/24 brd 127.2.0.255 scope host lo:1
       valid_lft forever preferred_lft forever
4: mgmt:  mtu 9001 qdisc noqueue state UP qlen 1000
    inet 10.0.0.201/24 brd 10.0.0.255 scope global mgmt
       valid_lft forever preferred_lft forever
6: tmm:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 127.1.1.254/24 brd 127.1.1.255 scope global tmm
       valid_lft forever preferred_lft forever
8: tmm_bp:  mtu 4096 qdisc pfifo_fast state UP qlen 1000
    inet 127.20.0.254/16 brd 127.20.255.255 scope global tmm_bp
       valid_lft forever preferred_lft forever
10: external:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 10.0.1.201/24 brd 10.0.1.255 scope global external
       valid_lft forever preferred_lft forever

パケットのキャプチャ(tcpdump)

次の例は、VLAN external を流れる宛先 10.0.2.24 の通信をキャプチャしています。BIG-IP の tcpdump では、-i に VLAN 名を指定できます。止めるときは Ctrl + C を押します。

# tcpdump -i  external dst 10.0.2.24
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on external, link-type EN10MB (Ethernet), capture size 65535 bytes
12:09:26.168146 IP bigip-1.hirotanoblog.local.42231 > 10.0.2.24.http: Flags [S], seq 2938028730, win 29200, options [mss 1460,sackOK,TS val 2711924503 ecr 0,nop,wscale 7], length 0 out slot1/tmm0 lis= port=1.1 trunk=
12:09:26.168752 IP bigip-1.hirotanoblog.local.42231 > 10.0.2.24.http: Flags [.], ack 1526192312, win 229, options [nop,nop,TS val 2711924504 ecr 690302613], length 0 out slot1/tmm0 lis= port=1.1 trunk=
12:09:26.168766 IP bigip-1.hirotanoblog.local.42231 > 10.0.2.24.http: Flags [P.], seq 0:9, ack 1, win 229, options [nop,nop,TS val 2711924504 ecr 690302613], length 9: HTTP: GET / out slot1/tmm0 lis= port=1.1 trunk=
12:09:26.193216 IP bigip-1.hirotanoblog.local.42231 > 10.0.2.24.http: Flags [.], ack 1449, win 251, options [nop,nop,TS val 2711924528 ecr 690302637], length 0 out slot1/tmm0 lis= port=1.1 trunk=
12:09:26.193240 IP bigip-1.hirotanoblog.local.42231 > 10.0.2.24.http: Flags [.], ack 2897, win 274, options [nop,nop,TS val 2711924528 ecr 690302637], length 0 out slot1/tmm0 lis= port=1.1 trunk=

ディスク使用量(df)

-h を付けると、容量を K/M/G の単位で読みやすく表示します。

# df -h
Filesystem                             Size  Used Avail Use% Mounted on
/dev/mapper/vg--db--vda-set.1.root     419M  246M  147M  63% /
devtmpfs                               3.9G  4.0K  3.9G   1% /dev
tmpfs                                  3.9G  2.3M  3.9G   1% /dev/shm
tmpfs                                  3.9G  2.2M  3.9G   1% /run
tmpfs                                  3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/vg--db--vda-set.1._usr     5.7G  4.5G  841M  85% /usr
/dev/mapper/vg--db--vda-set.1._var     1.5G  367M 1021M  27% /var
/dev/mapper/vg--db--vda-set.1._config  469M   14M  427M   4% /config
prompt                                 4.0M   28K  4.0M   1% /var/prompt
/dev/mapper/vg--db--vda-dat.appdata     31M  4.5M   25M  16% /appdata
none                                   3.9G   18M  3.9G   1% /var/tmstat
/dev/mapper/vg--db--vda-dat.share       15G  135M   14G   1% /shared
none                                   3.9G   33M  3.9G   1% /shared/rrd.1.2
/dev/mapper/vg--db--vda-dat.log        969M   37M  867M   4% /var/log
none                                   3.9G     0  3.9G   0% /var/loipc
tmpfs                                  799M     0  799M   0% /run/user/91
tmpfs                                  799M     0  799M   0% /run/user/0

メモリの空き状況(free)

-t を付けると、物理メモリとスワップを合計した Total の行も表示します。単位は KB です。

# free -t
              total        used        free      shared  buff/cache   available
Mem:        8175052     7752116       74736       57264      348200       53256
Swap:       1023996      327680      696316
Total:      9199048     8079796      771052

設定の追加・削除・変更(create/delete/modify)

設定の追加(create)

新しい設定は create で追加します。次は、負荷分散で使う Node、Pool、Virtual Server を追加する例です。

(tmos)# create ltm node Web-03 address 10.0.2.123
(tmos)# create ltm pool Web-Pool-1 members add  { Web-03:80 } 
(tmos)# create ltm virtual Web-VS-1 destination 10.0.1.245:http ip-protocol tcp
補足

この例の Virtual Server には Pool を指定していないので、まだ Web-Pool-1 には振り分けられません。作成時に Pool を関連付けるには、create ltm virtual Web-VS-1 destination 10.0.1.245:http ip-protocol tcp pool Web-Pool-1 のように pool を付けます。

設定の削除(delete)

設定は delete で削除します。上で追加した Virtual Server、Pool、Node を削除する例です。ほかの設定から参照されているものは削除できないので、参照している側(Virtual Server → Pool → Node)から順に削除します。

(tmos)# delete ltm virtual Web-VS-1 
(tmos)# delete ltm pool Web-Pool-1
(tmos)# delete ltm node Web-03

設定の変更(modify)

既存の設定は modify で変更します。次は、ホスト名を bigip-1.hirotanoblog.work から bigip-2.hirotanoblog.work に変える例です。

(tmos)# list sys global-settings 
sys global-settings {
    gui-setup disabled
    hostname bigip-1.hirotanoblog.work
}
(tmos)# modify sys global-settings hostname bigip-2.hirotanoblog.work 
(tmos)#
(tmos)# list sys global-settings  
sys global-settings {
    gui-setup disabled
    hostname bigip-2.hirotanoblog.work
}

設定の保存(save sys config)

GUI(Configuration Utility)で変更した内容は自動的に保存されますが、tmsh で変更した内容は保存しないと再起動で失われます。CLI で設定を変えたら、save sys config で保存します。

(tmos)# save sys config
Saving running configuration...
  /config/bigip.conf
  /config/bigip_base.conf
  /config/bigip_user.conf
Saving Ethernet map ...done
Saving PCI map ...
 - verifying checksum .../var/run/f5pcimap: OK
done
 - saving ...done
(tmos)#

設定情報の確認(list)

設定の内容は list で表示します。設定ファイルに近い形で表示されます。

稼働中の設定(list/show running-config)

list で、今動いている設定(running configuration)を表示します。

(tmos)# list
Display all 188 items? (y/n) y
auth password-policy { }
auth remote-role { }
auth remote-user { }
auth source { }
auth user admin {
    description "Admin User"
.
.

show running-config でも同じ設定が表示されます。

(tmos)# show running-config
Display all 188 items? (y/n) y
auth password-policy { }
auth remote-role { }
auth remote-user { }
auth source { }
auth user admin {
    description "Admin User"
.
.

初期値のままの項目も含めて表示したいときは、all-properties を付けます。

(tmos)# list all-properties 
Display all 188 items? (y/n) y
auth password-policy {
    description none
    expiration-warning 7
    lockout-duration 0
    max-duration 99999
    max-login-failures 0
    min-duration 0
.
.

モジュールごとの設定(list <module>)

モジュールを指定して、その範囲の設定だけを表示できます。次は LTM の設定を表示する例です。

(tmos)# list ltm
ltm default-node-monitor {
    rule none
}
ltm dns analytics global-settings { }
ltm dns cache global-settings { }
ltm global-settings connection { }
ltm global-settings general {
    share-single-mac vmw-compat
}
ltm global-settings rule { }
ltm global-settings traffic-control { }
ltm nat NATLIST-1 {
    inherited-traffic-group true
    originating-address 10.0.2.24
    traffic-group traffic-group-1
    translation-address 10.0.1.101
}
ltm node Web-01 {
    address 10.0.2.24
    monitor icmp
    session monitor-enabled
    state up
}
.
.

システム・ハードウェア情報(show sys)

状態や統計を見るときは show を使います。list が設定を表示するのに対して、show は稼働状態やカウンタを表示します。

バージョン(show sys version)

(tmos)# show sys version 
Sys::Version
Main Package
  Product     BIG-IP
  Version     16.1.2.1
  Build       0.0.10
  Edition     Point Release 1
  Date        Wed Dec 22 17:39:05 PST 2021

ライセンス(show sys license)

Registration key やライセンスの日付などを確認できます。

(tmos)# show sys license
Sys::License
Licensed Version                 14.0.0
Registration key                 XXXXX-XXXXX-XXXXX-XXXXX-XXXXXX
Licensed On                      2017/09/25
Service Check Date               2017/09/22
Platform ID                      Z100a_pc
Daily Renewal Notification Days  5
・
・

ハードウェア(show sys hardware)

CPU の型番やシリアル番号などを確認できます。Virtual Edition では、Platform に動作している環境(この例では AWS)が表示されます。

(tmos)# show sys hardware 
Sys::Hardware
Chassis Information
  Maximum MAC Count  1
  Registration Key   -

Hardware Version Information
  Name        cpus        
  Type        base-board  
  Model       Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz
  Parameters  --            --
              cache size    46080 KB
              cores         2  (physical:1)
              cpu MHz       2300.088
              cpu sockets   1
              cpu stepping  1
            
Platform
  Name  BIG-IP Virtual Edition
  BIOS Revision   
  Base MAC       xx:xx:xx:xx:xx:xx
  Hypervisor     HVM domU
  Cloud          AWS

System Information         
  Type                       Z100
  Chassis Serial             xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
  Level 200/400 Part          
  Switchboard Serial          
  Switchboard Part Revision   
  Host Board Serial           
  Host Board Part Revision

ネットワーク情報(show net)

インタフェース(show net interface)

インタフェースごとの状態、送受信の量、ドロップやエラーの数、速度とデュプレックスを確認できます。

(tmos)# show net interface

------------------------------------------------------------------
Net::Interface
Name  Status    Bits    Bits   Pkts   Pkts  Drops  Errs      Media
                  In     Out     In    Out                        
------------------------------------------------------------------
1.1       up  429.2M   94.2M  59.2K  62.3K      0     0  10000T-FD
mgmt      up   43.7M  180.5M  33.4K  32.8K      0     0   100TX-FD
表示意味
Statusインタフェースの状態(up など)
Bits/Pkts In・Out受信・送信したビット数とパケット数
Drops/Errs破棄したパケット数とエラーの数
Media速度とデュプレックス(FD は全二重)

ARP テーブル(show net arp)

(tmos)# show net arp
--------------------------------------------------------------------------------
Net::Arp
Name      Address   HWaddress          Vlan              Expire-in-sec  Status
--------------------------------------------------------------------------------
10.0.1.1  10.0.1.1  06:bd:46:50:67:6f  /Common/external  259            resolved

ルーティングテーブル(show net route)

(tmos)# show net route                  
----------------------------------------------------------------------------------
Net::Routes       
Name                Destination         Type       NextHop               Origin
----------------------------------------------------------------------------------
default-gw          default             gw         10.0.1.1              static
127.20.0.0/16       127.20.0.0/16       interface  tmm_bp                connected
10.0.1.0/24         10.0.1.0/24         interface  /Common/external      connected
127.1.1.0/24        127.1.1.0/24        interface  tmm                   connected
.
.

LTM の情報(show ltm)

Node(show ltm node)

Node ごとの状態、トラフィック量、接続数を表示します。

(tmos)# show ltm node
------------------------------------------
Ltm::Node: Web-01 (10.0.2.24)
------------------------------------------
Status               
  Availability   : available
  State          : enabled
  Reason         : Node address is available
  Monitor        : icmp
  Monitor Status : up
  Session Status : enabled
                     
Traffic                ServerSide  General
  Bits In                    1.2M        -
  Bits Out                  64.4M        -
  Packets In                 2.3K        -
  Packets Out                6.7K        -
  Current Connections           0        -
  Maximum Connections           2        -
  Total Connections           282        -
  Total Requests                -      288
  Current Sessions              -        0
.
.

Pool(show ltm pool)

Pool の状態、サーバ側(ServerSide)のトラフィック量、接続数を表示します。

(tmos)# show ltm pool
---------------------------------------------------------------------------------------
Ltm::Pool: Web-Pool                                      
---------------------------------------------------------------------------------------
Status                                                   
  Availability           : available                     
  State                  : enabled                       
  Reason                 : The pool is available         
  Monitor                : http                          
  Minimum Active Members : 0                             
  Priority Groups        : 0/0/0 (highest/current/lowest)
  Current Active Members : 2                             
  Available Members      : 2                             
  Total Members          : 2                             
  Total Requests         : 1153                          
  Current Sessions       : 0                             
                                                         
Traffic                                                    ServerSide
  Bits In                                                        5.2M
  Bits Out                                                     303.7M
  Packets In                                                    10.2K
  Packets Out                                                   30.9K
  Current Connections                                               0
  Maximum Connections                                               7
  Total Connections                                              1.1K
                                                         
Connection Queue                                                 Pool  Pool and members
  Number of connections queued now                                  0                 0
  Number of connections serviced                                    0                 0
  Queue head entry age (ms)                                         0                 0
  Maximum queue entry age ever (ms)                                 0                 0
  Maximum queue entry age recently (ms)                             0                 0
  Average queue entry age (ms)                                      0                 0
                                                         
Message Routing Framework                                          In               Out
  Message                                                           0                 0
  Request                                                           0                 0
  Response                                                          0                 0

Virtual Server(show ltm virtual)

Virtual Server の状態、クライアント側(ClientSide)のトラフィック量、接続数を表示します。

(tmos)# show ltm virtual
------------------------------------------------------------------
Ltm::Virtual Server: Web-VS    
------------------------------------------------------------------
Status                         
  Availability     : available 
  State            : enabled   
  Reason           : The virtual server is available
  CMP              : enabled   
  CMP Mode         : all-cpus  
  Destination      : 10.0.1.100:80
                               
Traffic                             ClientSide  Ephemeral  General
  Bits In                                 7.5M          0        -
  Bits Out                              308.7M          0        -
  Packets In                             15.5K          0        -
  Packets Out                            33.9K          0        -
  Current Connections                        0          0        -
  Maximum Connections                        6          0        -
  Total Connections                       1.1K          0        -
  Evicted Connections                        0          0        -
  Slow Connections Killed                    0          0        -
  Min Conn Duration/msec                     -          -      201
  Max Conn Duration/msec                     -          -   192.6K
  Mean Conn Duration/msec                    -          -      500
  Total Requests                             -          -     1.1K
                               
SYN Cookies                    
  Status                         not-activated
  Hardware SYN Cookie Instances              0
  Software SYN Cookie Instances              0
  Current SYN Cache                          0
  SYN Cache Overflow                         0
  Total Software                             0
  Total Software Accepted                    0
  Total Software Rejected                    0
  Total Hardware                             0
  Total Hardware Accepted                    0
                               
Message Routing Framework                   In        Out
  Message                                    0          0
  Request                                    0          0
  Response                                   0          0
                               
CPU Usage Ratio (%)            
  Last 5 Seconds                             0
  Last 1 Minute                              0
  Last 5 Minutes                             0

パーシステンス(show ltm persistence persist-records)

パーシステンスのレコードを表示します。次の例では、送信元アドレスによるパーシステンス(source-address)のレコードが1件あり、クライアントの接続が Virtual Server 10.0.1.100:80 から Node 10.0.2.24:80 に固定されています。クライアントのアドレスは伏せています。

(tmos)# show ltm persistence persist-records 
Sys::Persistent Connections
source-address  xx.xx.xx.xxx  10.0.1.100:80  10.0.2.24:80  (tmm: 1)
Total records returned: 1

パフォーマンス情報

CPU 使用率(show sys cpu)

(tmos)# show sys cpu

Sys::System CPU Information
-------------------------------------------------------------------
System CPU Usage(%)  Current  Average  Max(since 05/08/22 11:01:34)
-------------------------------------------------------------------
Utilization               51        3                           100
.
.

メモリ使用率(show sys memory)

(tmos)# show sys memory
Sys::System Memory Information
-----------------------------------------------------------------
Memory Used(%)     Current  Average  Max(since 05/08/22 11:03:23)
-----------------------------------------------------------------
TMM Memory Used          3        3                             3
Other Memory Used       80       80                            83
Swap Used               31       25                            31
.
.

CPU とメモリ(show sys performance system)

CPU とメモリの使用率をまとめて表示します。Current は今の値、Average は平均、Max は括弧内の時刻からの最大値です。

(tmos)# show sys performance system 

Sys::Performance System
-------------------------------------------------------------------
System CPU Usage(%)  Current  Average  Max(since 05/08/22 11:42:53)
-------------------------------------------------------------------
Utilization                1        2                            58
                   
-------------------------------------------------------------------
Memory Used(%)       Current  Average  Max(since 05/08/22 11:42:53)
-------------------------------------------------------------------
TMM Memory Used            3        3                             3
Other Memory Used         80       80                            84
Swap Used                 40       28                            40

スループット(show sys performance throughput)

1秒あたりのトラフィック量(ビット数とパケット数)や SSL のトランザクション数を表示します。

(tmos)# show sys performance throughput

Sys::Performance Throughput
-----------------------------------------------------------------------------
Throughput(bits)(bits/sec)     Current  Average  Max(since 05/08/22 11:43:26)
-----------------------------------------------------------------------------
Service                          29.5K    29.7K                         50.9K
In                               27.8K    28.2K                         48.7K
Out                               2.1K     2.2K                         14.4K                             
-----------------------------------------------------------------------------
SSL Transactions               Current  Average  Max(since 05/08/22 11:43:26)
-----------------------------------------------------------------------------
SSL TPS                              0        0                             0                             
-----------------------------------------------------------------------------
Throughput(packets)(pkts/sec)  Current  Average  Max(since 05/08/22 11:43:26)
-----------------------------------------------------------------------------
Service                              8        8                            16
In                                   4        4                             9
Out                                  4        4                            10

接続数(show sys performance connections)

アクティブな接続数、1秒あたりの新規接続数、1秒あたりの HTTP リクエスト数を表示します。

(tmos)# show sys performance connections

Sys::Performance Connections
---------------------------------------------------------------------------
Active Connections           Current  Average  Max(since 05/08/22 11:52:17)
---------------------------------------------------------------------------
Connections                        6        5                            61                           
---------------------------------------------------------------------------
Total New Connections(/sec)  Current  Average  Max(since 05/08/22 11:52:17)
---------------------------------------------------------------------------
Client Connections                 2        1                             6
Server Connections                 2        1                             6                           
---------------------------------------------------------------------------
HTTP Requests(/sec)          Current  Average  Max(since 05/08/22 11:52:17)
---------------------------------------------------------------------------
HTTP Requests                      1        0                             1

接続の一覧(show sys connection)

BIG-IP を通っている接続を、送信元と宛先のアドレス・ポートで表示します。1行が1つの接続で、左からクライアント側の送信元・宛先、サーバ側の送信元・宛先、プロトコルの順に並びます。クライアントのアドレスは伏せています。

(tmos)# show sys connection
Really display 1000 connections? (y/n) y
Sys::Connections
10.0.1.201:5623  10.0.2.71:8  10.0.1.201:63070  10.0.2.71:8   icmp  1  (tmm: 1)  none  none
any6.any         any6.any     10.0.1.201:54398  10.0.2.71:80  tcp   2  (tmm: 1)  none  none
10.0.1.201:5622     10.0.2.24:8    10.0.1.201:16495  10.0.2.24:8   icmp  3   (tmm: 0)  none  none
10.0.1.201:5618     10.0.2.24:8    10.0.1.201:47359  10.0.2.24:8   icmp  13  (tmm: 0)  none  none
xx.xx.xx.xxx:54391  10.0.1.100:80  any6.any          any6.any      tcp   5   (tmm: 0)  none  none
xx.xx.xx.xxx:54392  10.0.1.100:80  10.0.1.201:54392  10.0.2.71:80  tcp   3   (tmm: 0)  none  none
10.0.1.201:5620  10.0.2.24:8  10.0.1.201:5620  10.0.2.24:8  icmp  8  (tmm: 0)  none  none
10.0.1.201:5621  10.0.2.71:8  10.0.1.201:5621  10.0.2.71:8  icmp  6  (tmm: 1)  none  none
Total records returned: 8

show sys connection の見方は、NAT の動作確認の記事で詳しく説明しています。

リアルタイムの負荷状況(tmstat)

shell モードで tmstat を実行すると、CPU やメモリの使用状況がリアルタイムに表示され、値が自動で更新されます。Ctrl + C で止めます。

# tmstat
画面イメージについて

この記事の画面は、実際の画面ではなく、検証時の画面から見るポイントを抜き出して描いたイメージです。バージョンによって、項目の並びや表記は変わります。

tmstat の表示画面イメージ
1CPU:   0% busy     1% idle     0% sleep            Sun May  8 15:56:54 2022     Memory Allocated2 198,531,960 / 6,614,417,408 Memory Count Object  226MB    --- (total)  36MB    --- umem  23MB    --- thread stacks  17MB    --- dns cache resolver  13MB  7k xdata  12MB    --- malloc  10MB    --- ssl_compat  ⋮
図2 tmstat の画面(実際の画面ではなく、表示内容のポイントを示したイメージです。右側のパケットやインタフェースの欄は省いています)
No.表示意味
1CPU:CPU の busy/idle/sleep の割合と、現在時刻
2Memory Allocated割り当て済みのメモリ/使えるメモリ(バイト)。下にオブジェクトごとの使用量が並びます

リアルタイムの接続状況(bigtop)

bigtop は、BIG-IP 全体、Virtual Server、Node ごとのトラフィック量と接続数をリアルタイムに表示します。値は自動で更新され、Ctrl + C で止めます。

# bigtop
bigtop の表示画面イメージ
                         |  bits  since       |  bits  in prior    |  current                         |  May  8 11:20:38   |  4 seconds         |  time1BIG-IP      ACTIVE       |---In----Out---Conn-|---In----Out---Conn-|  16:00:50bigip-1.hirotanoblog.work 43.91M 919.9M  15342  14776 365024      4 2VIRTUAL ip:port          |---In----Out---Conn-|---In----Out---Conn-|-Nodes Up--/Common/10.0.1.100:http   11.55M 461.4M   1833   5352 227936      1      2 3NODE ip:port             |---In----Out---Conn-|---In----Out---Conn-|--State----/Common/Web-02:http       3.929M 232.8M    827      0      0    827 UP/Common/Web-01:http       4.267M 229.9M   1003   4072 229456   1003 UP
図3 bigtop の画面(実際の画面ではなく、表示内容のポイントを示したイメージです)
No.表示意味
1BIG-IPBIG-IP 全体の受信・送信量と接続数。左の欄は表示開始(since)からの累計、右の欄は直前の数秒間の値です
2VIRTUAL ip:portVirtual Server ごとの値。Nodes Up は Up の Node の数です
3NODE ip:portNode ごとの値と状態(UP:Node が利用できる状態)

リアルタイムではなく1回だけ表示したいときは、-once を付けます。

# bigtop -once
                         |  bits  since       |  bits  in prior    |  current
                         |  May  8 11:20:38   |  0 seconds         |  time
BIG-IP      ACTIVE       |---In----Out---Conn-|---In----Out---Conn-|  16:01:32
bigip-1.hirotanoblog.work 44.16M 925.2M  15394      0      0      0
                         
VIRTUAL ip:port          |---In----Out---Conn-|---In----Out---Conn-|-Nodes Up--
/Common/10.0.1.100:http   11.65M 465.5M   1851      0      0      0      2
                         
NODE ip:port             |---In----Out---Conn-|---In----Out---Conn-|--State----
/Common/Web-01:http       4.343M 234.0M   1021      0      0   1021 UP
/Common/Web-02:http       3.929M 232.8M    827      0      0    827 UP

ログ

ログの参照(show sys log)

show sys log でログを表示できます。たとえば LTM のログは show sys log ltm で表示します。どのログに何が記録されるかは、F5 のナレッジ K16197: Reviewing BIG-IP log files にまとまっています。

(tmos)# show sys log ltm

ltm 05-08 02:22:23 notice bigip-1.hirotanoblog.local mcpd[7276]: Virtual Address /Common/10.0.1.100 general status changed from BLUE to GREEN. 
ltm 05-08 02:22:23 notice bigip-1.hirotanoblog.local mcpd[7276]: SNMP_TRAP: Virtual /Common/Web-VS has become available 
ltm 05-08 02:22:23 notice bigip-1.hirotanoblog.local mcpd[7276]: Pool /Common/Web-Pool member /Common/Web-02:80 monitor status up. [ /Common/http: up ]  [ was up for 0hr:0min:49sec ] 
ltm 05-08 02:22:23 notice bigip-1.hirotanoblog.local mcpd[7276]: Pool /Common/Web-Pool member /Common/Web-01:80 monitor status up. [ /Common/http: up ]  [ was up for 0hr:0min:49sec ] 
ltm 05-08 02:22:23 notice bigip-1.hirotanoblog.local mcpd[7276]: Node /Common/Web-02 address 10.0.2.71 monitor status up. [ /Common/icmp: up ]  [ was up for 0hr:0min:49sec ] 
ltm 05-08 02:22:23 notice bigip-1.hirotanoblog.local mcpd[7276]: Node /Common/Web-01 address 10.0.2.24 monitor status up. [ /Common/icmp: up ]  [ was up for 0hr:0min:49sec ]

リアルタイムのログ参照(tail -f)

ログファイルは /var/log の下に保存されます。新しく出るログをリアルタイムに見るときは、shell モードで tail -f を使います。LTM のログは /var/log/ltm です。止めるときは Ctrl + C を押します。

# tail -f /var/log/ltm
May  8 15:20:29 bigip-1.hirotanoblog.local notice mcpd[7276]: 01070640:5: Node /Common/Web-02 address 10.0.2.71 monitor status down. [ /Common/icmp: down ]  [ was up for 0hr:6mins:33sec ]
May  8 15:20:29 bigip-1.hirotanoblog.local notice mcpd[7276]: 01070638:5: Pool /Common/Web-Pool member /Common/Web-02:80 monitor status down. [ /Common/http: down; last error:  ]  [ was up for 0hr:6mins:33sec ]

再起動・シャットダウン

再起動(reboot)

tmsh の reboot で再起動します。確認なしで再起動が始まるので、実行前に設定が保存されているかを確かめてください。

(tmos)# reboot
The system will be rebooted momentarily

シャットダウン(shutdown)

shutdown で機器を停止します。停止すると、リモートからは起動できない場合があります。

(tmos)# shutdown 
The system will be shutdown momentarily

まとめ

コマンドモード用途
tmsh/bashshell/tmshモードを切り替える
modify cli preference pager disabledtmshページングを無効にする
help / Tab キーtmshマニュアルや入力できる値を確認する
create/delete/modifytmsh設定を追加・削除・変更する
save sys configtmshtmsh で変えた設定を保存する
list[module]tmsh設定を表示する(all-properties で初期値も)
show sys version/license/hardwaretmshバージョン、ライセンス、ハードウェアを確認する
show net interface/arp/routetmshインタフェース、ARP、ルートを確認する
show ltm node/pool/virtualtmshLTM のオブジェクトの状態と統計を確認する
show sys performance …tmshCPU、メモリ、スループット、接続数を確認する
show sys connectiontmsh接続の一覧を確認する
show sys log ltmtmshLTM のログを表示する
tmstat/bigtopshell負荷や接続をリアルタイムに表示する
tcpdump/tail -fshellパケットキャプチャ、ログのリアルタイム表示
reboot/shutdowntmsh再起動・停止する

コメント

  1. imo より:

    はじめましてnw関係の仕事に携わっているimoと申します。

    Cisco関連の機材ですと情報が多いのですがロードバランサーとなると少なくなってしまうと感じております。そんな中でこういった記事は貴重です。
    感謝にたえません。

    もし御存知でしたら教えて頂きたいのですが、ハードウェアの障害か対抗先のインターフェースの障害か見分ける際には何処をみたら良いのでしょうか。

    Cisco機器ですと、show version
    から再起動履歴を見てpower on以外であればshow flashなどでcrash infoの生成があるか見れば瞭然でもしくはshow logから問題のインターフェースを確認しwan側経路の問題であれば回線調査を行い経路の問題かインターフェースの問題か選択肢を消していくのが正攻法かと考えています。

    ロードバランサー[big-ip]の場合、logコマンドでも複数ありますしどうすれば良いのか途方にくれてまして、もしご教示いただけたら幸いです。

    • 博田 登 博田 登 より:

      imoさん、コメントありがとうございます。

      ハードウェアやインターフェースの故障が原因かどうかを調べるには、以下の手順が一般的にはよろしいかと思います。

      1.デバイスのログを確認:
      tmsh show sys log コマンドを使用してシステムログを確認します。

      2.インターフェースとルーティングを調査:
      tmsh show net interface を使用してインターフェースの状態を確認します。
      tmsh show net route を使用してルーティング状態を確認します。

      3.物理的な接続をテスト:
      すべてのケーブルとコネクタがしっかり接続されているか、確認します。
      物理的な問題を排除するために、ケーブルを交換してみるのもよいかと思います。

      4.パフォーマンスを監視:
      tmsh show sys performance system を使用してパフォーマンス情報を確認します。

      5.設定情報を確認:
      tmsh list を使用して構成情報を確認します。

      上記の手順を実行してもハードウェアの故障が原因かどうか特定できない場合は、QKView(構成、診断情報)を取得し、サポートやメーカーに相談するのがよろしいかと思います。

      ご不明点がございましたら、コメントでお知らせください。

      • imo より:

        ご回答ありがとうございます。

        切り分けの際に役立つ情報を頂き感謝いたします。

        正直な所、あまりLBのログを見ることが少なくどの点が異常ログなのかという点はまだ理解出来ていないのですが、これからログを沢山見て理解につなげたいと考えてます。

        項番2,5でやることと言えば確かにシスコ系の器機でもshow running-configなどで設定を確認しshow interface系のコマンドで現在の状態と見比べるというのは確かにやっていたなと思い出しました(思い出してもLBでどういうコマンドが正しいかピンときていなかったのですが)。

        自分の中で何を攻めるべきか見えてきました。
        お時間割いていただいてありがとうございました。