feat: criaçao do template ping do sistema, e melhoria da ferramenta de valdiação dos templates
This commit is contained in:
parent
c61ea544aa
commit
8c54e5d6ee
|
|
@ -0,0 +1,282 @@
|
||||||
|
zabbix_export:
|
||||||
|
version: '7.0'
|
||||||
|
template_groups:
|
||||||
|
- uuid: 4322df9ecdf44b26b60c5bc406bc844f
|
||||||
|
name: Templates/Network devices
|
||||||
|
templates:
|
||||||
|
- uuid: a04dd94507e94e888fd2a288f7b55b9f
|
||||||
|
template: ICMP Ping
|
||||||
|
name: ICMP Ping
|
||||||
|
description: 'Template ICMP Ping (Arthur Style)
|
||||||
|
|
||||||
|
|
||||||
|
Monitoramento de disponibilidade e tempo de resposta via ICMP.
|
||||||
|
|
||||||
|
|
||||||
|
Itens:
|
||||||
|
|
||||||
|
- Status (Ping)
|
||||||
|
|
||||||
|
- Perda de Pacotes (%)
|
||||||
|
|
||||||
|
- Tempo de Resposta (s)
|
||||||
|
|
||||||
|
|
||||||
|
Triggers com design "Arthur":
|
||||||
|
|
||||||
|
- Emojis de severidade
|
||||||
|
|
||||||
|
- Instruções de Ação e Impacto
|
||||||
|
|
||||||
|
- Event Names ricos com valores
|
||||||
|
|
||||||
|
|
||||||
|
Análise Avançada:
|
||||||
|
|
||||||
|
- Detecção de Degradação (Tendência de Latência)
|
||||||
|
|
||||||
|
- Detecção de Instabilidade (Jitter percebido)
|
||||||
|
|
||||||
|
'
|
||||||
|
vendor:
|
||||||
|
name: IT Guys
|
||||||
|
version: 7.0-0
|
||||||
|
groups:
|
||||||
|
- name: Templates/Network devices
|
||||||
|
items:
|
||||||
|
- uuid: a5d833a13151456eafb79e634cd88fa0
|
||||||
|
name: Ping (Status)
|
||||||
|
type: SIMPLE
|
||||||
|
key: icmpping
|
||||||
|
description: 'Verifica a acessibilidade do host via ICMP Ping.
|
||||||
|
|
||||||
|
|
||||||
|
0 - Host inacessível (Offline)
|
||||||
|
|
||||||
|
1 - Host acessível (Online)
|
||||||
|
|
||||||
|
'
|
||||||
|
valuemap:
|
||||||
|
name: Estado do Serviço
|
||||||
|
tags:
|
||||||
|
- tag: componente
|
||||||
|
value: saude
|
||||||
|
- tag: componente
|
||||||
|
value: rede
|
||||||
|
triggers:
|
||||||
|
- uuid: 4c33295f2ce84612958bb007255ec165
|
||||||
|
expression: max(/ICMP Ping/icmpping,#3)=0
|
||||||
|
name: 🚨 Host Indisponível (Ping Down)
|
||||||
|
event_name: '🚨 Host Indisponível: {HOST.NAME} não responde a Ping (Status: Down)'
|
||||||
|
priority: HIGH
|
||||||
|
description: 'O dispositivo não está respondendo a requisições ICMP (Ping) nas últimas 3 tentativas.
|
||||||
|
|
||||||
|
|
||||||
|
Impacto: Serviços dependentes deste host estão inacessíveis.
|
||||||
|
|
||||||
|
Ação:
|
||||||
|
|
||||||
|
1. Verifique se o equipamento está ligado.
|
||||||
|
|
||||||
|
2. Verifique a conectividade física (cabos, portas de switch).
|
||||||
|
|
||||||
|
3. Verifique bloqueios de Firewall/Segurança.
|
||||||
|
|
||||||
|
'
|
||||||
|
tags:
|
||||||
|
- tag: escopo
|
||||||
|
value: disponibilidade
|
||||||
|
- uuid: 6ca8a13276864f0cac7a7132d9b192ba
|
||||||
|
name: Perda de Pacotes
|
||||||
|
type: SIMPLE
|
||||||
|
key: icmppingloss
|
||||||
|
value_type: FLOAT
|
||||||
|
units: '%'
|
||||||
|
description: Porcentagem de pacotes perdidos.
|
||||||
|
tags:
|
||||||
|
- tag: componente
|
||||||
|
value: saude
|
||||||
|
- tag: componente
|
||||||
|
value: rede
|
||||||
|
triggers:
|
||||||
|
- uuid: 81af653371c0451aa7fc2a6afa2e24ff
|
||||||
|
expression: min(/ICMP Ping/icmppingloss,5m)>{$ICMP_LOSS_WARN} and min(/ICMP Ping/icmppingloss,5m)<100
|
||||||
|
name: ⚠️ Alta Perda de Pacotes
|
||||||
|
event_name: '⚠️ Perda de Pacotes em {HOST.NAME}: {ITEM.LASTVALUE} (Limite: > {$ICMP_LOSS_WARN}%)'
|
||||||
|
opdata: 'Perda Atual: {ITEM.LASTVALUE1}'
|
||||||
|
priority: WARNING
|
||||||
|
description: 'Detectada perda de pacotes ICMP acima do limite configurado.
|
||||||
|
|
||||||
|
|
||||||
|
Impacto: Lentidão, desconexões e falhas em aplicações sensíveis.
|
||||||
|
|
||||||
|
Ação:
|
||||||
|
|
||||||
|
1. Verifique congestionamento no link de rede.
|
||||||
|
|
||||||
|
2. Verifique qualidade do cabeamento físico (erros de CRC).
|
||||||
|
|
||||||
|
3. Verifique duplex mismatch em interfaces.
|
||||||
|
|
||||||
|
'
|
||||||
|
dependencies:
|
||||||
|
- name: 🚨 Host Indisponível (Ping Down)
|
||||||
|
expression: max(/ICMP Ping/icmpping,#3)=0
|
||||||
|
tags:
|
||||||
|
- tag: escopo
|
||||||
|
value: disponibilidade
|
||||||
|
- tag: escopo
|
||||||
|
value: performance
|
||||||
|
- uuid: 9678ce4ab93642889984d75098059b13
|
||||||
|
name: Tempo de Resposta (Latência)
|
||||||
|
type: SIMPLE
|
||||||
|
key: icmppingsec
|
||||||
|
value_type: FLOAT
|
||||||
|
units: s
|
||||||
|
description: Tempo de resposta do Ping ICMP (em segundos).
|
||||||
|
tags:
|
||||||
|
- tag: componente
|
||||||
|
value: saude
|
||||||
|
- tag: componente
|
||||||
|
value: rede
|
||||||
|
triggers:
|
||||||
|
- uuid: 644c6ea04b2d4eabaafe666b86083e68
|
||||||
|
expression: avg(/ICMP Ping/icmppingsec,5m)>{$ICMP_RESPONSE_TIME_WARN}
|
||||||
|
name: 🐢 Latência Alta (Lag)
|
||||||
|
event_name: '🐢 Latência Alta em {HOST.NAME}: {ITEM.LASTVALUE} (Limite: > {$ICMP_RESPONSE_TIME_WARN}s)'
|
||||||
|
opdata: 'Latência: {ITEM.LASTVALUE1}'
|
||||||
|
priority: WARNING
|
||||||
|
description: 'O tempo médio de resposta ICMP está muito alto.
|
||||||
|
|
||||||
|
|
||||||
|
Impacto: Degradação de performance em serviços (RDP, VoIP, Banco de Dados).
|
||||||
|
|
||||||
|
Ação:
|
||||||
|
|
||||||
|
1. Verifique saturação de banda de internet/rede.
|
||||||
|
|
||||||
|
2. Verifique alta carga de CPU no roteador ou firewall.
|
||||||
|
|
||||||
|
3. Rastreie a rota (traceroute) para identificar gargalos.
|
||||||
|
|
||||||
|
'
|
||||||
|
dependencies:
|
||||||
|
- name: ⚠️ Alta Perda de Pacotes
|
||||||
|
expression: min(/ICMP Ping/icmppingloss,5m)>{$ICMP_LOSS_WARN} and min(/ICMP Ping/icmppingloss,5m)<100
|
||||||
|
- name: 🚨 Host Indisponível (Ping Down)
|
||||||
|
expression: max(/ICMP Ping/icmpping,#3)=0
|
||||||
|
tags:
|
||||||
|
- tag: escopo
|
||||||
|
value: disponibilidade
|
||||||
|
- tag: escopo
|
||||||
|
value: performance
|
||||||
|
- uuid: 776c9bb9c1044262b0ab42c9cae4d6ed
|
||||||
|
expression: avg(/ICMP Ping/icmppingsec,5m) > 1.5 * avg(/ICMP Ping/icmppingsec,1h) and avg(/ICMP Ping/icmppingsec,5m) > 0.05
|
||||||
|
name: 🐢 Possível Degradação de Link (Basineline Change)
|
||||||
|
event_name: '🐢 Possível Degradação em {HOST.NAME}: Latência subiu 50% em relação à média (Atual: {ITEM.LASTVALUE})'
|
||||||
|
opdata: 'Atual: {ITEM.LASTVALUE1} | Média 1h: {ITEM.LASTVALUE2}'
|
||||||
|
priority: INFO
|
||||||
|
description: 'A latência atual aumentou 50% em comparação com a média da última hora.
|
||||||
|
|
||||||
|
|
||||||
|
Isso pode indicar um início de congestionamento ou alteração de rota, mesmo que não tenha atingido o limite crítico ainda.
|
||||||
|
|
||||||
|
'
|
||||||
|
dependencies:
|
||||||
|
- name: 🐢 Latência Alta (Lag)
|
||||||
|
expression: avg(/ICMP Ping/icmppingsec,5m)>{$ICMP_RESPONSE_TIME_WARN}
|
||||||
|
tags:
|
||||||
|
- tag: escopo
|
||||||
|
value: performance
|
||||||
|
- tag: tipo
|
||||||
|
value: anomalia
|
||||||
|
- uuid: b23c4caf44eb4fed90250d1c3b938f39
|
||||||
|
name: Jitter (Variação de Latência)
|
||||||
|
type: CALCULATED
|
||||||
|
key: icmp.jitter
|
||||||
|
params: stddevpop(//icmppingsec,1m)
|
||||||
|
value_type: FLOAT
|
||||||
|
units: s
|
||||||
|
description: 'Desvio padrão da latência no último minuto.
|
||||||
|
|
||||||
|
Indica a estabilidade da conexão.
|
||||||
|
|
||||||
|
'
|
||||||
|
tags:
|
||||||
|
- tag: componente
|
||||||
|
value: rede
|
||||||
|
triggers:
|
||||||
|
- uuid: ff51182051234ec79b61d13b7505064a
|
||||||
|
expression: min(/ICMP Ping/icmp.jitter,5m) > 0.05
|
||||||
|
name: ⚠️ Instabilidade de Latência (Jitter Elevado)
|
||||||
|
event_name: '⚠️ Conexão Instável em {HOST.NAME}: Jitter de {ITEM.LASTVALUE}'
|
||||||
|
opdata: 'Jitter: {ITEM.LASTVALUE1}'
|
||||||
|
priority: WARNING
|
||||||
|
description: 'A variação da latência (Jitter) está muito alta (> 50ms).
|
||||||
|
|
||||||
|
|
||||||
|
Impacto: Chamadas de voz robóticas, lag em jogos/RDP.
|
||||||
|
|
||||||
|
Ação: Verificar qualidade do link ou interferência.
|
||||||
|
|
||||||
|
'
|
||||||
|
tags:
|
||||||
|
- tag: escopo
|
||||||
|
value: performance
|
||||||
|
tags:
|
||||||
|
- tag: classe
|
||||||
|
value: rede
|
||||||
|
- tag: alvo
|
||||||
|
value: icmp
|
||||||
|
macros:
|
||||||
|
- macro: '{$ICMP_LOSS_WARN}'
|
||||||
|
value: '20'
|
||||||
|
description: Limiar de alerta para perda de pacotes em %.
|
||||||
|
- macro: '{$ICMP_RESPONSE_TIME_WARN}'
|
||||||
|
value: '0.15'
|
||||||
|
description: Limiar de alerta para tempo de resposta ICMP em segundos.
|
||||||
|
valuemaps:
|
||||||
|
- uuid: ff98a96f65b847ffb8827efa21d95a93
|
||||||
|
name: Estado do Serviço
|
||||||
|
mappings:
|
||||||
|
- value: '0'
|
||||||
|
newvalue: Offline (Down)
|
||||||
|
- value: '1'
|
||||||
|
newvalue: Online (Up)
|
||||||
|
dashboards:
|
||||||
|
- uuid: f4ffe799a4c6415fb5ca0c947fa39a2a
|
||||||
|
name: Desempenho de Rede ICMP
|
||||||
|
pages:
|
||||||
|
- widgets:
|
||||||
|
- type: graph
|
||||||
|
width: '24'
|
||||||
|
height: '10'
|
||||||
|
fields:
|
||||||
|
- type: GRAPH
|
||||||
|
name: graphid
|
||||||
|
value:
|
||||||
|
host: ICMP Ping
|
||||||
|
name: 'Ping: Latência e Perda de Pacotes'
|
||||||
|
- type: INTEGER
|
||||||
|
name: show_legend
|
||||||
|
value: '1'
|
||||||
|
graphs:
|
||||||
|
- uuid: 8ca17283137d4a02b34342c88338677d
|
||||||
|
name: 'Ping: Latência e Perda de Pacotes'
|
||||||
|
width: '900'
|
||||||
|
height: '200'
|
||||||
|
yaxismax: '100'
|
||||||
|
yaxismin: '0'
|
||||||
|
ymax_type_1: FIXED
|
||||||
|
graph_items:
|
||||||
|
- color: 00C800
|
||||||
|
item:
|
||||||
|
host: ICMP Ping
|
||||||
|
key: icmppingsec
|
||||||
|
- sortorder: '1'
|
||||||
|
drawtype: GRADIENT_LINE
|
||||||
|
color: C80000
|
||||||
|
yaxisside: RIGHT
|
||||||
|
item:
|
||||||
|
host: ICMP Ping
|
||||||
|
key: icmppingloss
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
# Documentação: ICMP Ping
|
||||||
|
|
||||||
|
**Template:** ICMP Ping
|
||||||
|
**Descrição:**
|
||||||
|
Template ICMP Ping (Arthur Style)
|
||||||
|
|
||||||
|
Monitoramento de disponibilidade e tempo de resposta via ICMP.
|
||||||
|
|
||||||
|
Itens:
|
||||||
|
- Status (Ping)
|
||||||
|
- Perda de Pacotes (%)
|
||||||
|
- Tempo de Resposta (s)
|
||||||
|
|
||||||
|
Triggers com design "Arthur":
|
||||||
|
- Emojis de severidade
|
||||||
|
- Instruções de Ação e Impacto
|
||||||
|
- Event Names ricos com valores
|
||||||
|
|
||||||
|
Análise Avançada:
|
||||||
|
- Detecção de Degradação (Tendência de Latência)
|
||||||
|
- Detecção de Instabilidade (Jitter percebido)
|
||||||
|
|
||||||
|
## Itens Monitorados
|
||||||
|
|
||||||
|
### Itens Globais
|
||||||
|
- **Ping (Status)** (`icmpping`)
|
||||||
|
- **Perda de Pacotes** (`icmppingloss`)
|
||||||
|
- **Tempo de Resposta (Latência)** (`icmppingsec`)
|
||||||
|
- **Jitter (Variação de Latência)** (`icmp.jitter`)
|
||||||
|
|
||||||
|
## Alertas (Triggers)
|
||||||
|
|
||||||
|
### Triggers Globais
|
||||||
|
- [HIGH] **🚨 Host Indisponível (Ping Down)**
|
||||||
|
- [WARNING] **⚠️ Alta Perda de Pacotes**
|
||||||
|
- [WARNING] **🐢 Latência Alta (Lag)**
|
||||||
|
- [INFO] **🐢 Possível Degradação de Link (Basineline Change)**
|
||||||
|
- [WARNING] **⚠️ Instabilidade de Latência (Jitter Elevado)**
|
||||||
|
|
@ -190,6 +190,73 @@ def validate_dashboard_references(content, graph_names):
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
|
|
||||||
|
def validate_calculated_formulas(content):
|
||||||
|
"""
|
||||||
|
Check for deprecated or invalid functions in Calculated Items (Zabbix 7.0 compatibility).
|
||||||
|
e.g. 'stddev' is not valid, should be 'stddevpop' or 'stddevsamp'.
|
||||||
|
"""
|
||||||
|
errors = []
|
||||||
|
|
||||||
|
def check_formulas(node, path="root"):
|
||||||
|
if isinstance(node, dict):
|
||||||
|
# Check if it's a calculated item
|
||||||
|
if node.get('type') == 'CALCULATED' and 'params' in node:
|
||||||
|
params = node['params']
|
||||||
|
|
||||||
|
# Check for 'stddev(' -> Deprecated/Invalid in 6.0+
|
||||||
|
if 'stddev(' in params:
|
||||||
|
errors.append(f"[INVALID FORMULA] 'stddev' function usage at {path}. Use 'stddevpop' (population) or 'stddevsamp' (sample) instead.")
|
||||||
|
|
||||||
|
for k, v in node.items():
|
||||||
|
check_formulas(v, f"{path}.{k}")
|
||||||
|
elif isinstance(node, list):
|
||||||
|
for i, item in enumerate(node):
|
||||||
|
check_formulas(item, f"{path}[{i}]")
|
||||||
|
|
||||||
|
check_formulas(content)
|
||||||
|
return errors
|
||||||
|
|
||||||
|
|
||||||
|
def validate_nested_structure(content):
|
||||||
|
"""
|
||||||
|
Check for bad nesting, specifically Items nested inside Trigger lists.
|
||||||
|
This happens when indentation is wrong in YAML.
|
||||||
|
"""
|
||||||
|
errors = []
|
||||||
|
|
||||||
|
def check_structure(node, path="root", parent_context=None):
|
||||||
|
if isinstance(node, dict):
|
||||||
|
# Identify current context based on keys
|
||||||
|
is_trigger = 'expression' in node and 'priority' in node
|
||||||
|
is_item = 'key' in node and 'type' in node
|
||||||
|
|
||||||
|
if parent_context == 'triggers':
|
||||||
|
# If we are inside a 'triggers' list, we should ONLY see triggers.
|
||||||
|
# If we see an item (has 'key' and 'type'), it's a nesting error.
|
||||||
|
if is_item and not is_trigger: # Triggers don't have 'type' usually, but items do.
|
||||||
|
# Extra check: 'key' is definitely an item property, not trigger
|
||||||
|
if 'key' in node:
|
||||||
|
errors.append(f"[BAD NESTING] Found Item with key '{node.get('key')}' nested inside 'triggers' list at {path}. Check indentation.")
|
||||||
|
|
||||||
|
# Recurse
|
||||||
|
for k, v in node.items():
|
||||||
|
# Pass context if we are entering a relevant list
|
||||||
|
next_context = None
|
||||||
|
if k == 'triggers':
|
||||||
|
next_context = 'triggers'
|
||||||
|
elif k == 'items':
|
||||||
|
next_context = 'items'
|
||||||
|
|
||||||
|
check_structure(v, f"{path}.{k}", next_context)
|
||||||
|
|
||||||
|
elif isinstance(node, list):
|
||||||
|
for i, item in enumerate(node):
|
||||||
|
check_structure(item, f"{path}[{i}]", parent_context)
|
||||||
|
|
||||||
|
check_structure(content)
|
||||||
|
return errors
|
||||||
|
|
||||||
|
|
||||||
def check_duplicate_yaml_keys(file_path):
|
def check_duplicate_yaml_keys(file_path):
|
||||||
"""
|
"""
|
||||||
Check for duplicate YAML keys at the same level (e.g., two 'macros:' sections).
|
Check for duplicate YAML keys at the same level (e.g., two 'macros:' sections).
|
||||||
|
|
@ -333,7 +400,7 @@ def validate_yaml(file_path):
|
||||||
print(f" ✅ All graph item references are valid ({len(item_keys)} items found)")
|
print(f" ✅ All graph item references are valid ({len(item_keys)} items found)")
|
||||||
|
|
||||||
# ========== 4. Dashboard Graph References ==========
|
# ========== 4. Dashboard Graph References ==========
|
||||||
print("\n[4/4] Checking dashboard graph references...")
|
print("\n[4/6] Checking dashboard graph references...")
|
||||||
graph_names = collect_graph_names(content)
|
graph_names = collect_graph_names(content)
|
||||||
dashboard_ref_errors = validate_dashboard_references(content, graph_names)
|
dashboard_ref_errors = validate_dashboard_references(content, graph_names)
|
||||||
if dashboard_ref_errors:
|
if dashboard_ref_errors:
|
||||||
|
|
@ -342,6 +409,24 @@ def validate_yaml(file_path):
|
||||||
else:
|
else:
|
||||||
print(f" ✅ All dashboard graph references are valid ({len(graph_names)} graphs found)")
|
print(f" ✅ All dashboard graph references are valid ({len(graph_names)} graphs found)")
|
||||||
|
|
||||||
|
# ========== 5. Calculated Formulas Check ==========
|
||||||
|
print("\n[5/6] Checking calculated item formulas...")
|
||||||
|
formula_errors = validate_calculated_formulas(content)
|
||||||
|
if formula_errors:
|
||||||
|
all_errors.extend(formula_errors)
|
||||||
|
print(f" ❌ Found {len(formula_errors)} invalid formulas")
|
||||||
|
else:
|
||||||
|
print(" ✅ Formula syntax looks compatible")
|
||||||
|
|
||||||
|
# ========== 6. Nested Structure Check ==========
|
||||||
|
print("\n[6/6] Checking for structure nesting errors...")
|
||||||
|
nesting_errors = validate_nested_structure(content)
|
||||||
|
if nesting_errors:
|
||||||
|
all_errors.extend(nesting_errors)
|
||||||
|
print(f" ❌ Found {len(nesting_errors)} nesting errors (items inside triggers, etc)")
|
||||||
|
else:
|
||||||
|
print(" ✅ Structure nesting looks correct")
|
||||||
|
|
||||||
# ========== Summary ==========
|
# ========== Summary ==========
|
||||||
print("\n" + "=" * 60)
|
print("\n" + "=" * 60)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue