Nagios 2.11 のグラフを日本語で表示させる
Nagiosでは日本語の文字コードはEUCになっておりグラフ表示に利用しているGDがEUCに対応している必要があります。
対応させるにはコンパイル時に「-DJISX0208」オプションを付けて行います。
もしこのオプションを付けずにインストールを行っている場合は再インストールします。
portsのjapanese/gdを利用してインストールした場合は既にこのオプションが付加されていますので再コンパイルの必要はありません。
あと、日本語を含んだ画像を生成する際にフォントファイルが必要になりますのでこれを用意します。
Nagiosでは現時点において「さざなみフォント」で最適化されていますので以下のサイトからダウンロードして適当なところにアップロードします。
(ここではNagiosの設定ファイルと同じディレクトリに置いていると仮定して話を進めます)
・書体関係 Wiki - さざなみフォント
対応させるにはコンパイル時に「-DJISX0208」オプションを付けて行います。
もしこのオプションを付けずにインストールを行っている場合は再インストールします。
portsのjapanese/gdを利用してインストールした場合は既にこのオプションが付加されていますので再コンパイルの必要はありません。
(色分け:入力値、コマンドライン、コメント)
■再インストール
# portupgrade -f japanese/gd
■新規インストール
# portinstall japanese/gd
===> Vulnerability check disabled, database not found
===> Found saved configuration for ja-gd-2.0.35,1
===> Extracting for ja-gd-2.0.35,1
===> Vulnerability check disabled, database not found
===> Found saved configuration for ja-gd-2.0.35,1
=> MD5 Checksum OK for gd-2.0.35.tar.bz2.
=> SHA256 Checksum OK for gd-2.0.35.tar.bz2.
===> ja-gd-2.0.35,1 depends on file: /usr/local/sbin/pkg_info -
found
GD_FONTS can be set to specify an alternative list of .bdf files
===> Patching for ja-gd-2.0.35,1
===> Applying FreeBSD patches for ja-gd-2.0.35,1
===> ja-gd-2.0.35,1 depends on shared library: jpeg.9 - found
===> ja-gd-2.0.35,1 depends on shared library: png.5 - found
===> ja-gd-2.0.35,1 depends on shared library: freetype.9 - found
===> Configuring for ja-gd-2.0.35,1
GD_FONTS can be set to specify an alternative list of .bdf files
See /usr/ports/japanese/gd/../../graphics/gd/files/configure for de
tails...
...(中略)...
install -o root -g wheel -m 444 /var/tmp/usr/ports/japanese/gd/work
/gd-2.0.35/gdfx.h /var/tmp/usr/ports/japanese/gd/work/gd-2.0.35/gdhe
lpers.h /usr/local/include/
install -o root -g wheel -m 555 /var/tmp/usr/ports/japanese/gd/work
/gdlib-config /usr/local/bin/
install -o root -g wheel -m 444 /var/tmp/usr/ports/japanese/gd/work
/gd-2.0.35/index.html /usr/local/share/doc/gd
===> Running ldconfig
/sbin/ldconfig -m /usr/local/lib
===> Registering installation for ja-gd-2.0.35,1
===> Cleaning for ja-gd-2.0.35,1
---> Installation of japanese/gd ended at: Sat, 29 Mar 2008 18:41:28
+0900 (consumed 00:00:08)
---> Saving the log as '/var/log/ports/portupgrade-japanese::gd.log'
---> Fresh installation of japanese/gd ended at: Sat, 29 Mar 2008 18
:41:28 +0900 (consumed 00:00:29)
---> ** Install tasks 1: 1 done, 0 ignored, 0 skipped and 0 failed
---> Listing the results (+:done / -:ignored / *:skipped / !:failed)
+ japanese/gd
---> Packages processed: 1 done, 0 ignored, 0 skipped and 0 failed
---> Saving the results to '/var/ports/result'
---> Session ended at: Sat, 29 Mar 2008 18:41:28 +0900 (consumed 00:
00:35)
Nagiosでは現時点において「さざなみフォント」で最適化されていますので以下のサイトからダウンロードして適当なところにアップロードします。
(ここではNagiosの設定ファイルと同じディレクトリに置いていると仮定して話を進めます)
・書体関係 Wiki - さざなみフォント
日本語に関する設定を行います。
"/usr/local/etc/nagios/cgi.cfg"
(色分け:書換、追記、コメント)
278: # TRUE TYPE FONT FILE (JAPANESE FONT ONLY)
279: # The font file used for the text of the image outputted by GD
280: # is specified. The path of the file to specify is absolutely
281: # performed by specification.
282:
283: ttf_file=/usr/local/etc/nagios/sazanami-gothic.ttf
コメントアウトされているので有効にしてフォントを置いているパスを指定します。
ここでは日本語でグラフを表示するための設定を行います。
作成日:2008.3.30
更新日:2008.5.07