ZABBIX マップの文字化け対策
http://extstrg.asabiya.net/pukiwiki/index.php?ZABBIX%20%A5%DE%A5%C3%A5%D7%A4%CE%CA%B8%BB%FA%B2%BD%A4%B1%C2%D0%BA%F6目次
修正手順 †
初期状態ではユーザの言語を日本語に変更するとマップで文字化けが発生する。
正常に日本語を表示するには日本語フォントを準備し、map.phpを修正する必要がある。
- 日本語フォント取得(SAZANAMIフォント)
wget http://globalbase.dl.sourceforge.jp/efont/10087/sazanami-20040629.tar.bz2 bzip2 -d sazanami-20040629.tar.bz2 tar xfv sazanami-20040629.tar cd sazanami-20040629 cp sazanami-* /usr/share/fonts/
/usr/share/fonts配下に日本語フォントがインストールされる。
ZABBIX 1.4系 †
- map.phpの修正
260行目を以下のように変更。
- 変更前
ImageString($im, 2, $x_info, $y_info, $info_line,$color);
- 変更後
//ImageString($im, 2, $x_info, $y_info, $info_line,$color); ImageTTFText($im, 8, 0, $x_info+5, $y_info+10, $color, "/usr/share/fonts/sazanami-gothic.ttf", $info_line);
ZABBIX 1.6系 †
- map.phpの修正
1.6系からは文字列が小文字になったため、以下の行で検索する。
- 変更前
imagestring($im, 2, $x_info, $y_info, $info_line,$color);
- 変更後
//imagestring($im, 2, $x_info, $y_info, $info_line,$color); ImageTTFText($im, 8, 0, $x_info+5, $y_info+10, $color, "/usr/share/fonts/sazanami-gothic.ttf", $info_line);
ZABBIX 1.8系、2.0系 †
1.8系からはフロントエンド内にフォントを保管する領域が準備されているため、これを使用する。
sazanami-gothic.ttf(/usr/share/fonts/japanese/TrueType/sazanami-gothic.ttf)を使用するためには、この既定フォルダ内にシンボリックリンクを生成し、./include/defines.inc.phpにフォント名を指定する。
- 手順(さざなみフォント)
cd ./fonts ln -s /usr/share/fonts/japanese/TrueType/sazanami-gothic.ttf sazanami-gothic.ttf cd ../ vi ./include/defines.inc.php
- 変更前(defines.inc.php)
define('ZBX_GRAPH_FONT_NAME', 'DejaVuSans');
- 変更後(defines.inc.php)
define('ZBX_GRAPH_FONT_NAME', 'sazanami-gothic');
最近のLinuxではIPAのフォントが搭載されているため、こちらの方が綺麗に描画することができる。
さざなみフォントではグラフのメモリが潰れてしまうため、IPAゴシックが推奨。
- 手順(IPAフォント)
cd ./fonts ln -s /usr/share/fonts/ipa-gothic/ipag.ttf ipag.ttf cd ../ vi ./include/defines.inc.php
- 変更前(defines.inc.php)
define('ZBX_GRAPH_FONT_NAME', 'DejaVuSans');
- 変更後(defines.inc.php)
define('ZBX_GRAPH_FONT_NAME', 'ipag.ttf');
Last-modified: 2013-11-14 (木) 01:15:27 (3817d)