This is the documentation page for an unsupported version of Zabbix.
Is this not what you were looking for? Switch to the current version or choose one from the drop-down menu.

1 使用例

概要

このセクションでは、保存前処理のステップを使用していくつかの実用的なタスクを実行する例を紹介します。

VMwareのイベントログをフィルタリングする

正規表現の保存前処理を使用して、VMWareイベントログの不要なイベントをフィルタリングします。

1. 動作中のVMWare Hypervisorホストで、イベントログのアイテムvmware.eventlog[<url>,<mode>]`が存在し、正しく動作していることを確認します。Template VM VMWare テンプレートがホストの作成時にリンクされている場合、イベントログアイテムはハイパーバイザー上に既に存在する可能性があることに注意してください。

2. VMWare Hypervisorホストで、依存アイテムに'ログ'タイプを作成してイベントログをマスターに設定します。

依存アイテムの"保存前処理"タブで、"正規表現と一致する"という検証オプションを選択し、パターンを記入します。

".* logged in .*" - イベントログのすべてのログインイベントをフィルタリングします
       "\bUser\s+\K\S+" - イベントログからユーザー名を含む行のみをフィルタリングします

正規表現が一致しない場合、依存アイテムはサポートされなくなり、対応するエラーメッセージが表示されます。 これを回避するには、"失敗時のカスタマイズ"チェックボックスをオンにし、一致しない値を破棄するように選択します。

マッチンググループと出力制御を使用できる別の方法は、"保存前処理"タブで"正規表現"オプションを選択し、以下のようにパラメーターを入力することです。

パターン: ".*logged in.*"、出力: "\0" - イベントログのすべてのログイベントをフィルタリングします。
       パターン: "User (.*?)(?=\ )"、出力: "\1" - イベントログからユーザー名のみをフィルタリングします。

Checking retrieved value type

This example uses the Custom multiplier preprocessing step to check if the retrieved item value type is numeric.

In the Preprocessing tab of an item, select the "Custom multiplier" preprocessing step and set the following parameter:

# Multiplies the retrieved value by 1:
       number: 1

If preprocessing fails (e.g., input is not numeric), then the item becomes unsupported with a corresponding error message. To avoid this, mark the "Custom on fail" checkbox and select an option such as discarding the value or setting a custom one.

Checking for not supported value

This example uses the Check for not supported value preprocessing step to check if the item value could not be retrieved.

When a Zabbix server/proxy poller process attempts to collect an item value, it may:

  • Return a valid result.
  • Return a result that initially seems valid but may become unsupported later (e.g., due to a value type mismatch after preprocessing).
  • Return an error of collecting the value, causing the item to become unsupported. Common causes include:
    • Unknown item key (for Zabbix agent, Simple check, or Zabbix internal items)
    • Unknown OID (SNMP agent), unknown sensor (IPMI agent), or no JMX metric (JMX agent)
    • Cannot read trap file (SNMP trap)
    • Script not found (External check)
    • No such URL (HTTP agent)
    • Login failed (SSH agent, TELNET agent)
    • Invalid formula syntax (Calculated), JavaScript syntax error (Script), or invalid SQL (Database monitor)

To detect and handle errors of collecting item values, you can use the "Check for not supported value" preprocessing step. Note that this step is always executed first and only detects errors that occur before preprocessing begins.

In the Preprocessing tab of an item, select the "Check for not supported value" preprocessing step.

Then, use the Custom on fail option to discard the value (in this case, the error), set a custom value, or return a custom error message. Please note that discarded values are not stored in the database; as a result, triggers are not evaluated and trend data is not generated.