executable_alerta-close 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #! /usr/bin/env cached-nix-shell
  2. #! nix-shell -i bash -p python3 python3Packages.alerta
  3. set -x
  4. case "$1" in
  5. apache)
  6. for severity in major critical; do
  7. for id in $(alerta query --filter severity=$severity | grep apache2-php | awk '{ print $1 }'); do
  8. alerta close --ids "$id"
  9. done
  10. done
  11. for id in $(alerta query --filter severity=major | awk '/IdleWorkers: 0/ { print $1 }'); do
  12. alerta close --ids "$id"
  13. done
  14. ;;
  15. chef)
  16. for id in $(alerta query --filter severity=critical | awk '/chef cookbook/ { print $1 }'); do
  17. alerta close --ids "$id"
  18. done
  19. ;;
  20. domain)
  21. for id in $(alerta query --filter severity=informational \
  22. | grep 'Домен должен быть делегирован на наши\|A-запись домена не соответствует серверу\|Обновление архива' \
  23. | awk '{ print $1 }'); do
  24. alerta delete --ids "$id"
  25. done
  26. ;;
  27. rss)
  28. for id in $(alerta query --filter severity=major | awk '/file-rss:/ { print $1 }'); do
  29. alerta close --ids "$id"
  30. done
  31. ;;
  32. ssh)
  33. for id in $(alerta query --filter severity=major | awk '/Linux container ssh-guest-room is down/ { print $1 }'); do
  34. alerta close --ids "$id"
  35. done
  36. ;;
  37. task)
  38. alerta delete --filter status=open --filter event=task.finished
  39. ;;
  40. trace)
  41. for id in $(alerta query --filter severity=critical | awk '/Call Trace:/ { print $1 }'); do
  42. alerta close --ids "$id"
  43. done
  44. ;;
  45. *)
  46. for id in $(alerta query | awk "/$message/ { print \$1 }"); do
  47. alerta close --ids "$id"
  48. done
  49. esac