猫とアップルパイ

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

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つのディスカバリルールで定義されたアプリケーションプロトタイプは、同じアプリケーションを検出できない
  • アプリケーションプロトタイプは、名前がかぶった場合、最初のプロトタイプだけが成功し、残りは失敗する
  • 異なるディスカバリルールで定義されたアプリケーションプロトタイプのみが、同じアプリケーションを検出できる
あ、あれ、、であれば今回のようにちがう監視テンプレートのアプリケーション名なら大丈夫そうだけどな?
こんどくわしくしらべよう。。