Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- UMBRAL=60
- USUARIO="root"
- echo "Buscando consultas que superen los $UMBRAL segundos..."
- mysql -u "$USUARIO" -p -e "SHOW FULL PROCESSLIST;" | while read id usuario host bd comando tiempo estado info
- do
- if [[ "$tiempo" =~ ^[0-9]+$ ]] && [ "$tiempo" -ge "$UMBRAL" ]; then
- echo "========================================="
- echo "[ALERTA] Consulta de larga duración"
- echo "ID: $id"
- echo "Usuario: $usuario"
- echo "Base de datos: $bd"
- echo "Tiempo: $tiempo segundos"
- echo "Estado: $estado"
- echo "Consulta: $info"
- echo
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment