Create: 2013/01/16
LastUpdate: 2013/01/21
ここでは、XenServerのパフォーマンス統計値をRRDToolでグラフ化してみます。
1.パフォーマンス統計値の取得
XenServerでは、CPU使用率などのパフォーマンス統計値を、RRDtool(ラウンドロビンデータベースツール)で提供されるRRD(ラウンドロビンデータベース)に記録しており、XenCenterのパフォーマンスグラフの表示で利用しています。
このRRDに保存されたパフォーマンス統計値は、未圧縮のXMLファイルとしてホストサーバに保存されていて、以下のように、HTTPを使用してダウンロードできます。
- XenServerホストの全てのパフォーマンス統計値を取得する場合
http://<username:password>@host/host_rrd
- 仮想マシンの全てのパフォーマンス統計値を取得する場合
http://<username:password>@host/vm_rrd?uuid=<vm_uuid>
この取得したXMLファイルに含まれる個々のパフォーマンス統計値には、どのような項目があるのか知りたい場合は、xe コマンドで調べます。コントロール・ドメイン(Dom0)で、以下のようにxeコマンドを実行します。
「name_label」タグはそれぞれのパフォーマンス統計値のラベル、「name_description」タグはそれぞれのパフォーマンス統計値の概要を示します。なお、「enable」タグが「true」となっているものが取得できます。
# xe host-data-source-list host=<ホスト名>
name_label : memory_total_kib
name_description: Total amount of memory in use
enabled: true
standard: true
min: 0.000
max: nan
units: KiB
name_label : memory_free_kib
name_description: Total amount of free memory
enabled: true
standard: true
min: 0.000
max: nan
units: KiB
name_label : xapi_memory_usage_kib
name_description: Total memory allocated used by xapi daemon
enabled: true
standard: true
min: 0.000
max: nan
units: KiB
name_label : xapi_free_memory_kib
name_description: Free memory available to the xapi daemon
enabled: true
standard: true
min: 0.000
max: nan
units: KiB
name_label : xapi_live_memory_kib
name_description: Live memory used by xapi daemon
enabled: true
standard: true
min: 0.000
max: nan
units: KiB
name_label : xapi_allocation_kib
name_description: Memory allocation done by the xapi daemon
enabled: true
standard: true
min: 0.000
max: nan
units: KiB
name_label : pif_aggr_rx
name_description: Bytes per second received on all physical interfaces
enabled: true
standard: true
min: 0.000
max: nan
units: B/s
name_label : pif_aggr_tx
name_description: Bytes per second sent on all physical interfaces
enabled: true
standard: true
min: 0.000
max: nan
units: B/s
name_label : pif_lo_rx
name_description: Bytes per second received on physical interface lo
enabled: true
standard: true
min: 0.000
max: nan
units: B/s
name_label : pif_lo_tx
name_description: Bytes per second sent on physical interface lo
enabled: true
standard: true
min: 0.000
max: nan
units: B/s
name_label : pif_lo_rx_errors
name_description: Receive errors per second on physical interface lo
enabled: false
standard: false
min: 0.000
max: nan
units: err/s
name_label : pif_lo_tx_errors
name_description: Transmit errors per second on physical interface lo
enabled: false
standard: false
min: 0.000
max: nan
units: err/s
name_label : pif_eth0_rx
name_description: Bytes per second received on physical interface eth0
enabled: true
standard: true
min: 0.000
max: nan
units: B/s
name_label : pif_eth0_tx
name_description: Bytes per second sent on physical interface eth0
enabled: true
standard: true
min: 0.000
max: nan
units: B/s
name_label : pif_eth0_rx_errors
name_description: Receive errors per second on physical interface eth0
enabled: false
standard: false
min: 0.000
max: nan
units: err/s
name_label : pif_eth0_tx_errors
name_description: Transmit errors per second on physical interface eth0
enabled: false
standard: false
min: 0.000
max: nan
units: err/s
name_label : cpu_avg
name_description: Average physical cpu usage
enabled: true
standard: true
min: 0.000
max: 1.000
units: (fraction)
name_label : cpu1
name_description: Physical cpu usage for cpu 1
enabled: true
standard: true
min: 0.000
max: 1.000
units: (fraction)
name_label : cpu0
name_description: Physical cpu usage for cpu 0
enabled: true
standard: true
min: 0.000
max: 1.000
units: (fraction)
name_label : loadavg
name_description: Domain0 loadavg
enabled: true
standard: true
min: nan
max: nan
units: (fraction)
2.パフォーマンス統計値のグラフ化
ここでの作業は、CentOS6を使用しています。まず、グラフの作成には、RRDTool が必要なので、以下のようにしてインストールします。
# yum install rrdtool次に、上記1で取得したパフォーマンス統計値(XMLファイル)からRRDデータ(.rrd)に変換します。
以下のように wget コマンドでパフォーマンス統計値を取得して、rrdtool コマンドで変換します。
# wget http://root:password@10.34.195.100/host_rrd # rrdtool restore host_rrd host_rrd.rrdこの RRDデータから、グラフとして表示する期間の情報を取得します。以下のように、グラフ化する期間の最初と最後の時間をUNIX時間(UTCでの1970年1月1日0時0分0秒からの経過時間)で表示します。
# rrdtool first ./host_rrd.rrd --rraindex 1 <== 最初の時間 1358381220 # rrdtool last ./host_rrd.rrd <== 最後の時間 1358388369以上の情報を基に、RRDtoolでグラフ画像を作成します。グラフ化する各パフォーマンス統計値、データ統合関数(MIN, AVERAGE, MAX)は、RRDtoolの「DEF」文にて定義します。以下の例は、XenServerホストの eth0の入出力である「pif_eth0_rx」と「pif_eth0_tx」のAVERAGE統計値をグラフ化します。
# rrdtool graph ./cpuaverage.png --start 1358381220 --end 1358388369 DEF:pif_eth0_rx_ave=host_rrd.rrd:pif_eth0_rx:AVERAGE DEF:pif_eth0_tx_ave=host_rrd.rrd:pif_eth0_tx:AVERAGE LINE1:pif_eth0_rx_ave#0000ff:received LINE2:pif_eth0_tx_ave#ff0000:sent --upper-limit 100000 --lower-limit 0 --title "Network(eth0) Stats (Average)"作成されたグラフ画像は、下図のとおり。
上記では、RRDTool のコマンドを実行してグラフを作成しましたが、RRDToolのフロントエンドとなる Cacti を使うと、ブラウザからグラフを作成することができます。Cacti でグラフを作成する手順について「 [CentOS6][Cacti] 既存のRRDファイルからグラフを作成する 」を参照してください。