この投稿は、Nutanix Advent Calendar 2019(1枚目)の 11日目です。
Nutanix CE の AHV で、性能情報の一覧を REST API v2 で取得してみます。
今回の環境
- Nutanix CE のバージョン: 2019.02.11
- REST API をコールするクライアント: curl
- curl の実行元: Oracle Linux 7.7
- JSON の整形などで、jq コマンドを利用。
性能情報の取得
まず、コマンドラインをコピー&ペーストしやすいように、環境に依存する情報を変数に格納しておきます。
$ PRISM=PrismのIPアドレス $ USER=admin $ PASS='パスワード'
Nutanix クラスタの AHV の、UUID を確認しておきます。パイプのあとにある jq コマンド「 | jq ~の部分」は、API で取得した JSON 形式のデータの整形とフィルタリングで利用しています。この部分を省略して実行すると、素の JSON データを確認することができます。
ちなみに、このクラスタは 1ノード構成です。
$ curl -X GET -k -s -u "$USER:$PASS" -H "Accept: application/json" "https://$PRISM:9440/PrismGateway/services/rest/v2.0/hosts" | jq -r ".entities[] | {AHV:.name, UUID:.uuid}" { "AHV": "NTNX-7a726604-A", "UUID": "9123c38b-7ca7-432b-aa69-771cb56f4375" }
AHV の UUID も変数に格納しておきます。
$ AHV_UUID="9123c38b-7ca7-432b-aa69-771cb56f4375"
UUID をもとに、AHV の情報を取得しておきます。UUID を指定しない場合は、クラスタ内の全 AHV の情報が表示されます。
$ curl -X GET -k -s -u "$USER:$PASS" -H "Accept: application/json" "https://$PRISM:9440/PrismGateway/services/rest/v2.0/hosts/$AHV_UUID" | jq -r .
画面出力は、下記のようになります。
このうち「stats」配下が性能情報です。直前に実行したコマンドラインで jq のクエリを工夫すると、stats 配下の部分のみを表示できます。
$ curl -X GET -k -s -u "$USER:$PASS" -H "Accept: application/json" "https://$PRISM:9440/PrismGateway/services/rest/v2.0/hosts/$AHV_UUID" | jq -r ".stats" { "hypervisor_avg_io_latency_usecs": "0", "num_read_iops": "0", "hypervisor_write_io_bandwidth_kBps": "0", "timespan_usecs": "20000000", "controller_num_read_iops": "0", "read_io_ppm": "500000", "controller_num_iops": "0", "total_read_io_time_usecs": "-1", "controller_total_read_io_time_usecs": "0", "hypervisor_num_io": "0", "controller_total_transformed_usage_bytes": "-1", "hypervisor_cpu_usage_ppm": "451074", "controller_num_write_io": "0", "avg_read_io_latency_usecs": "-1", "content_cache_logical_ssd_usage_bytes": "0", "controller_total_io_time_usecs": "0", "controller_total_read_io_size_kbytes": "0", "controller_num_seq_io": "-1", "controller_read_io_ppm": "0", "content_cache_num_lookups": "5", "controller_total_io_size_kbytes": "0", "content_cache_hit_ppm": "1000000", "controller_num_io": "0", "hypervisor_avg_read_io_latency_usecs": "0", "content_cache_num_dedup_ref_count_pph": "100", "num_write_iops": "0", "controller_num_random_io": "0", "num_iops": "0", "hypervisor_num_read_io": "0", "hypervisor_total_read_io_time_usecs": "0", "controller_avg_io_latency_usecs": "0", "num_io": "2", "controller_num_read_io": "0", "hypervisor_num_write_io": "0", "controller_seq_io_ppm": "-1", "controller_read_io_bandwidth_kBps": "0", "controller_io_bandwidth_kBps": "0", "hypervisor_num_received_bytes": "0", "hypervisor_timespan_usecs": "29707717", "hypervisor_num_write_iops": "0", "total_read_io_size_kbytes": "16", "hypervisor_total_io_size_kbytes": "0", "avg_io_latency_usecs": "352402", "hypervisor_num_read_iops": "0", "content_cache_saved_ssd_usage_bytes": "0", "controller_write_io_bandwidth_kBps": "0", "controller_write_io_ppm": "0", "hypervisor_avg_write_io_latency_usecs": "0", "hypervisor_num_transmitted_bytes": "0", "hypervisor_total_read_io_size_kbytes": "0", "read_io_bandwidth_kBps": "0", "hypervisor_memory_usage_ppm": "537770", "hypervisor_num_iops": "0", "hypervisor_io_bandwidth_kBps": "0", "controller_num_write_iops": "0", "total_io_time_usecs": "704804", "content_cache_physical_ssd_usage_bytes": "0", "controller_random_io_ppm": "-1", "controller_avg_read_io_size_kbytes": "0", "total_transformed_usage_bytes": "-1", "avg_write_io_latency_usecs": "-1", "num_read_io": "1", "write_io_bandwidth_kBps": "0", "hypervisor_read_io_bandwidth_kBps": "0", "random_io_ppm": "-1", "total_untransformed_usage_bytes": "-1", "hypervisor_total_io_time_usecs": "0", "num_random_io": "-1", "controller_avg_write_io_size_kbytes": "0", "controller_avg_read_io_latency_usecs": "0", "num_write_io": "1", "total_io_size_kbytes": "28", "io_bandwidth_kBps": "1", "content_cache_physical_memory_usage_bytes": "353192412", "controller_timespan_usecs": "20000000", "num_seq_io": "-1", "content_cache_saved_memory_usage_bytes": "0", "seq_io_ppm": "-1", "write_io_ppm": "500000", "controller_avg_write_io_latency_usecs": "0", "content_cache_logical_memory_usage_bytes": "353192412" }
同様に、ストレージ使用容量の情報を取得する例です。
$ curl -X GET -k -s -u "$USER:$PASS" -H "Accept: application/json" "https://$PRISM:9440/PrismGateway/services/rest/v2.0/hosts/$AHV_UUID" | jq -r ".usage_stats" { "storage_tier.das-sata.usage_bytes": "0", "storage.capacity_bytes": "467285159084", "storage.logical_usage_bytes": "27363475456", "storage_tier.das-sata.capacity_bytes": "0", "storage.free_bytes": "441019554988", "storage_tier.ssd.usage_bytes": "26265604096", "storage_tier.ssd.capacity_bytes": "467285159084", "storage_tier.das-sata.free_bytes": "0", "storage.usage_bytes": "26265604096", "storage_tier.ssd.free_bytes": "441019554988" }
たんに性能確認だけでなく、Prism で取得できる性能情報のメトリック確認としても利用できそうかなと思いました。
以上。