1 Exemplos de uso

Visão geral

Esta seção fornece exemplos de uso das etapas de pré-processamento para realização de algumas tarefas práticas.

Filtro de registros de log de eventos VMware

Usando um pré-processamento de expressão regular para filtrar eventos desnecessários do log de eventos VMWare.

1. Em um host VMWare Hypervisor funcional verifique que o item de log de evento vmware.eventlog[<url>,<mode>] esteja presente e funcionando de forma apropriada. Note que o item de log de evento pode já estar presente no hypervisor se o modelo Modelo VM VMWare foi associado durante a criação do host.

2. No host VMWare Hypervisor crie um item dependente do tipo 'Log' e defina o item de log de evento como principal.

Na aba de "Pré-processamento" do item dependente selecione a opção de validação "Corresponde à expressão regular" e preencha com o padrão, por exemplo:

".* logged in .*" - filtra todos os eventos de log no log de eventos
       "\bUser\s+\K\S+" -  filtra apenas linhas com nomes de usuário do log de eventos

Se a expressão regular não é correspondida então o item dependente se torna não suportado com uma mensagem de erro correspondente. Para evitar isto, marque a caixa de seleção "Customizado em falha" e selecione o descarte do valor não correspondido, por exemplo.

Outra abordagem que permite o uso de grupos de correspondência e controle de saída é selecionar a opção "Expressão regular" na aba de "Pré-processamento" e preencher os parâmetros, por exemplo:

padrão: ".*logged in.*", output: "\0" - filtra todos os eventos no log de eventos
       padrão: "User (.*?)(?=\ )", output: "\1" - filtra apenas nomes de usuário do log de eventos

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.