猫とアップルパイ

インフラエンジニアをやってます!エンジニアってむずかしいよね。

zabbix のディスカバリルールを使用するときはアプリケーションプロトタイプ名にご用心

zabbix に新規サーバを監視対象として追加したところ、

一部の監視項目が正常にデータ取得できていなかった。

新規追加したアイテム情報が取得できない

新規でディスカバリルールを使用して redis の監視テンプレートを追加したところ
redis の memory 項目が取得できていなかった。
監視テンプレート側の設定ミスかと思いきや、
 
zabbix サーバから zabbix_get コマンドで問題のキーを指定したところ正常に情報は取得できる。
監視テンプレート側のキー設定の不備ではない。。 

zabbix DB が Duplicate entory

じゃあなんだろう~~?
調査すると、下記のエラーメッセージが zabbix サーバのログに出力されていた。
zabbix_server [16457]: ERROR [file:lld_item.c,line:2896] Something impossible has just happened.
16457:20170526:195315.261 [Z3005] query failed: [1062] Duplicate entry '10129-memory' for key 'applications_2' [insert into applications (applicationid,hostid,name,flags) values (791,10129,'command',4),(792,10129,'keys',4),(793,10129,'clients',4),(794,10129,'memory',4);
 
Duplicate entry で zabbix DB に値を入力できないため、対象のアイテムが表示されていない様子。
何が Duplicate entry になっているの。。
 
hostid: 10129 で、 memory というアプリケーション名がいけないようす。
hostid: 10129 のホストに適用したテンプレートを見てみると、
Template_Redis で、
  • アプリケーション名:Redis
  • アプリケーションプロトタイプ:memory
と指定していたのだが、
このアプリケーションプロトタイプ名が、Template_OS のアプリケーション名 Memory とかぶっていたためエラーになっていた。
(DBはMySQLなので大文字小文字は区別しない)
 
Template_Redis のほうのアプリケーションプロトタイプから memory を削除したところ正常に値が取得できるようになった!!!

アプリケーションプロトタイプってなに

アプリケーションプロトタイプって単純に、アプリケーション名の小項目みたいに考えていたんだけど違うの?

3 Low-level discovery [Zabbix Documentation 3.2]

マニュアルによると:
You may define a new application prototype.
In application prototypes you can use low-level discovery macros that, after discovery, will be substituted with real values to create applications that are specific for the discovered entity. See also application discovery notes for more specific information.
 
Application prototypes defined by one discovery rule can't discover the same application. In this situation only the first prototype discovery will succeed, the rest will report appropriate LLD error. Only application prototypes defined in different discovery rules can result in discovering the same application.
 
  • 1つのディスカバリルールで定義されたアプリケーションプロトタイプは、同じアプリケーションを検出できない
  • アプリケーションプロトタイプは、名前がかぶった場合、最初のプロトタイプだけが成功し、残りは失敗する
  • 異なるディスカバリルールで定義されたアプリケーションプロトタイプのみが、同じアプリケーションを検出できる
あ、あれ、、であれば今回のようにちがう監視テンプレートのアプリケーション名なら大丈夫そうだけどな?
こんどくわしくしらべよう。。
 
 
 
 
 

zabbix の日本語文字化けを直す

こんにちは。まおぱんです。
みんな大好き zabbix 。
しかし zabbix は標準だと日本語が表示されません。
zabbix のグラフを web UI で見ると、日本語がうまく表示できなかったり文字化けしちゃってzabbix 豆腐事件の発生です。
 
とゆうことで zabbix のグラフで日本語が文字化けする問題を解決したメモ。
今回は zabbix をソースからインストールした場合。

 環境

やりかた

1. zabbix で現在使用してる font を確認する
# ll /usr/local/zabbix/fonts/
total 704
-rw-r--r-- 1 root root 720012 Dec 25  2012 DejaVuSans.ttf
2. OS で現在使用可能な font を確認

現在使用できるフォントはこのディレクトリ配下のものだけなので、ここにほしいものがなかったらインストールする必要がある。

# ll /usr/share/fonts/
total 116
drwxr-xr-x. 2 root root 4096 Dec 25  2012 abyssinica
drwxr-xr-x. 2 root root 4096 Dec 25  2012 bitmap
drwxr-xr-x. 2 root root 4096 Dec 25  2012 cjkuni-uming
drwxr-xr-x. 4 root root 4096 Dec 25  2012 default
drwxr-xr-x. 2 root root 4096 Dec 25  2012 dejavu
drwxr-xr-x. 2 root root 4096 Dec 25  2012 jomolhari
drwxr-xr-x. 2 root root 4096 Dec 25  2012 khmeros
drwxr-xr-x. 2 root root 4096 Dec 25  2012 kurdit-unikurd-web
drwxr-xr-x. 2 root root 4096 Dec 25  2012 liberation
drwxr-xr-x. 2 root root 4096 Dec 25  2012 lklug
drwxr-xr-x. 2 root root 4096 Dec 25  2012 lohit-assamese
drwxr-xr-x. 2 root root 4096 Dec 25  2012 lohit-bengali
3. ipa-pgothic-fonts をインストールする
日本語を表示するためには「IPAゴシックフォント」が必要なので OS に入っていなければインストールする。
# yum install ipa-pgothic-fonts
4. zabbix で使用するフォントに IPA ゴシックフォントを設定する
// zabbix で使用するフォント確認
# alternatives --display zabbix-web-font
※ 何も表示されないので何も設定されていない
 
// IPA ゴシックフォントのパスを確認
# ll /usr/share/fonts/ipa-pgothic/
total 6092
-rw-r--r-- 1 root root 6234432 Nov 11  2009 ipagp.ttf
 
// IPA ゴシックフォントを zabbix フォントに登録 
alternatives --install /usr/local/zabbix/fonts/graphfont.ttf zabbix-web-font /usr/share/fonts/ipa-pgothic/ipagp.ttf 100
 
// 確認
# alternatives --display zabbix-web-font
zabbix-web-font - status is manual.
 link currently points to /usr/share/fonts/ipa-pgothic/ipagp.ttf
/usr/share/fonts/ipa-pgothic/ipagp.ttf - priority 100
Current `best' version is /usr/share/fonts/ipa-pgothic/ipagp.ttf.
 
# ll /usr/local/zabbix/fonts/
total 704
-rw-r--r-- 1 root root 720012 Dec 25  2012 DejaVuSans.ttf
lrwxrwxrwx 1 root root     33 Aug 24 14:23 graphfont.ttf -> /etc/alternatives/zabbix-web-font
5. zabbix の フォント設定ファイルを編集
// 下記のように修正
vim /usr/local/zabbix/include/defines.inc.php
-------------------
define('ZBX_GRAPH_FONT_NAME', 'graphfont'); // font file name
--------------------
 
// zabbix 再起動
service zabbix_server restart
 

amazon linux の場合

amazon linux だと IPAPゴシックがインストールできなかった・・・
しょうがないので IPA ゴシックいれた
# yum install ipa-gothic-fonts