Subir archivos a "/"
This commit is contained in:
63
get_tags.bash
Normal file
63
get_tags.bash
Normal file
@ -0,0 +1,63 @@
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
# === CONFIGURACIÓN ===
|
||||
ZBX_URL="https://zabbix.seat.vwg/api_jsonrpc.php"
|
||||
API_TOKEN="508108e67eb8534e049e105d84e75ae1ac8673ac74a0a165e440a40a8e773362"
|
||||
|
||||
# Fecha UNIX de hace 90 días
|
||||
FROM_UNIX=$(( $(date +%s) - 7776000))
|
||||
|
||||
# Límite de resultados por página
|
||||
LIMIT=1000
|
||||
START=0
|
||||
PAGE=1
|
||||
TMPFILE=$(mktemp)
|
||||
|
||||
echo "⏳ Buscando triggers modificados desde: $(date -d @$FROM_UNIX)"
|
||||
echo "📄 Página $PAGE (offset $START)..."
|
||||
|
||||
read -r -d '' PAYLOAD <<EOF
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "trigger.get",
|
||||
"params": {
|
||||
"output": ["triggerid"],
|
||||
"selectTags": "extend",
|
||||
"sortfield": "lastchange",
|
||||
"sortorder": "DESC",
|
||||
"limit": $LIMIT,
|
||||
"filter": {
|
||||
"lastChangeSince": $FROM_UNIX
|
||||
}
|
||||
},
|
||||
"auth": "$API_TOKEN",
|
||||
"id": 1
|
||||
}
|
||||
EOF
|
||||
|
||||
# Petición
|
||||
response=$(curl -s -k -X POST "$ZBX_URL" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$PAYLOAD")
|
||||
|
||||
# Validación mínima
|
||||
count=$(echo "$response" | jq '.result | length')
|
||||
|
||||
if [[ "$count" -eq 0 ]]; then
|
||||
echo "❌ No se encontraron triggers modificados en los últimos 30 días."
|
||||
rm -f "$TMPFILE"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Extraer tags
|
||||
echo "$response" | jq -r '.result[].tags[]? | "\(.tag):\(.value)"' > "$TMPFILE"
|
||||
|
||||
# Mostrar resultados
|
||||
echo -e "\n✅ Tags únicos encontrados:"
|
||||
sort "$TMPFILE" | uniq
|
||||
|
||||
echo -e "\n📊 Conteo por tipo de tag:"
|
||||
cut -d: -f1 "$TMPFILE" | sort | uniq -c | sort -nr
|
||||
|
||||
rm -f "$TMPFILE"
|
||||
Reference in New Issue
Block a user