Esta seção fornece exemplos de uso das etapas de pré-processamento para realização de algumas tarefas práticas.
Usando uma expressão regular para pré-processamento e filtrar eventos desnecessários do log de eventos do VMware.
1. No host VMware Hypervisor em funcionamento, verifique se o item de log de eventos vmware.eventlog[<url>,<mode>]
está presente e funcionando corretamente. Observe que o item de log de eventos já pode estar presente no hypervisor se o Template VM VMware tiver sido vinculado durante a criação do host.
2. No host VMware Hypervisor, crie um item dependente dependent item do tipo 'Log' e defina o item de log de eventos como seu mestre.
Na aba "Preprocessing" do item dependente, selecione a opção de validação "Correspondências com expressão regular" e preencha o padrão, por exemplo:
".* logged in .*" - filters all logging events in the event log
"\bUser\s+\K\S+" - filter only lines with usernames from the event log
Se a expressão regular não for correspondida, o item dependente se tornará não suportado com uma mensagem de erro correspondente. Para evitar isso, marque a caixa "Personalizado em caso de falha" e selecione descartar 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 "Pré-processamento" e preencher os parâmetros, por exemplo:
pattern: ".*logged in.*", output: "\0" - filters all logging events in the event log
pattern "User (.*?)(?=\ )", output: "\1" - filter only usernames from the event log
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:
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.
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:
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.