Freelance Web Engineer

zabbix グラフの文字化け対策

2011-02-27  ubuntu, zabbix

Ubuntu 10.04 ServerのaptitudeでインストールしたZabbixはバージョンが1.8.1で、現時点の最新バージョンは1.8.4なので若干古いですね。モニタリングツールは過去にmuninしか使ったことが無かったので、どのように設定したらよいのか今後試行錯誤しながら設定したいと思います。

さて今回は、Zabbixが出力するグラフの日本語が化けているのを直してみます。

今回の環境は以下の通り:

サーバ
Ubuntu 10.04.1 LTS on さくらVPS
Zabbix
1.8.1

IPAフォントのインストール

aptitudeでインストールします。

$ sudo aptitude install otf-ipafont
[sudo] password for masayuki: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading extended state information      
Initializing package states... Done
The following NEW packages will be installed:
  otf-ipafont otf-ipafont-gothic{a} otf-ipafont-mincho{a} 
The following partially installed packages will be configured:
  zabbix-agent 
0 packages upgraded, 3 newly installed, 0 to remove and 105 not upgraded.
Need to get 20.1MB of archives. After unpacking 28.9MB will be used.
Do you want to continue? [Y/n/?] Y
Writing extended state information... Done
Get:1 http://jp.archive.ubuntu.com/ubuntu/ lucid/universe otf-ipafont-gothic 00302-4 [8,559kB]
Get:2 http://jp.archive.ubuntu.com/ubuntu/ lucid/universe otf-ipafont-mincho 00302-4 [11.5MB]                                                                                                                                               
Get:3 http://jp.archive.ubuntu.com/ubuntu/ lucid/universe otf-ipafont 00302-4 [10.8kB]                                                                                                                                                      
Fetched 20.1MB in 8s (2,353kB/s)                                                                                                                                                                                                            
Selecting previously deselected package otf-ipafont-gothic.
(Reading database ... 53779 files and directories currently installed.)
Unpacking otf-ipafont-gothic (from .../otf-ipafont-gothic_00302-4_all.deb) ...
Selecting previously deselected package otf-ipafont-mincho.
Unpacking otf-ipafont-mincho (from .../otf-ipafont-mincho_00302-4_all.deb) ...
Selecting previously deselected package otf-ipafont.
Unpacking otf-ipafont (from .../otf-ipafont_00302-4_all.deb) ...
Setting up zabbix-agent (1:1.8.1-1ubuntu1) ...
 * Starting Zabbix agent zabbix_agentd
   ...done.

Setting up otf-ipafont-gothic (00302-4) ...
update-alternatives: using /usr/share/fonts/opentype/ipafont/ipag.ttf to provide /usr/share/fonts/truetype/ttf-japanese-gothic.ttf (ttf-japanese-gothic.ttf) in auto mode.

Setting up otf-ipafont-mincho (00302-4) ...
update-alternatives: using /usr/share/fonts/opentype/ipafont/ipam.ttf to provide /usr/share/fonts/truetype/ttf-japanese-mincho.ttf (ttf-japanese-mincho.ttf) in auto mode.

Setting up otf-ipafont (00302-4) ...
Reading package lists... Done             
Building dependency tree       
Reading state information... Done
Reading extended state information      
Initializing package states... Done
Writing extended state information... Done

次にZabbixのフォントディレクトリにシンボリックリンクを設定します。

$ sudo su -
# cd /usr/share/zabbix/fonts/
# sudo ln -s /usr/share/fonts/opentype/ipafont/ipag.ttf ipag.ttf
# ll
total 8
drwxr-xr-x  2 root root 4096 2011-02-27 11:50 ./
drwxr-xr-x 10 root root 4096 2011-02-09 17:10 ../
lrwxrwxrwx  1 root root   46 2011-02-09 17:10 DejaVuSans.ttf -> ../../fonts/truetype/ttf-dejavu/DejaVuSans.ttf
lrwxrwxrwx  1 root root   42 2011-02-27 11:50 ipag.ttf -> /usr/share/fonts/opentype/ipafont/ipag.ttf

Zabbix設定ファイルの修正

ipag.ttfを読み込むよう、設定ファイルを修正します。

# cd -
/usr/share/zabbix
# pwd
/usr/share/zabbix
# vi include/defines.inc.php 
//      define('ZBX_GRAPH_FONT_NAME',                   'DejaVuSans');          // font file name
        define('ZBX_GRAPH_FONT_NAME',                   'ipag');

以上で設定が完了です。Zabbixのグラフを確認すると文字化けは解消されているはずです。

comments powered by Disqus