No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

36 líneas
1.2 KiB

  1. #!/bin/bash
  2. # Find the first "Restricted zone" alert, update its status and operator,
  3. # then list alerts before and after.
  4. # Usage: ./alert_status.sh [status] [operator]
  5. # status - optional, default: resolved
  6. # operator - optional, default: admin
  7. # Example: ./alert_status.sh acknowledged "John Doe"
  8. # BASE_URL=http://host:port ./alert_status.sh resolved admin
  9. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  10. . "${SCRIPT_DIR}/../_common.sh"
  11. STATUS="${1:-resolved}"
  12. OPERATOR="${2:-admin}"
  13. echo "=== Alerts before update ==="
  14. ALERTS=$(curl -s -X GET "${BASE_URL}/reslevis/alerts?limit=100&offset=0")
  15. echo "$ALERTS" | jq '.'
  16. ALERT_ID=$(echo "$ALERTS" | jq -r '[.[] | select(.type == "Restricted zone")] | first | .id')
  17. if [ -z "$ALERT_ID" ] || [ "$ALERT_ID" = "null" ]; then
  18. echo "No alert with type 'Restricted zone' found."
  19. exit 1
  20. fi
  21. echo ""
  22. echo "=== Updating alert ${ALERT_ID} (status=${STATUS}, operator=${OPERATOR}) ==="
  23. curl -s -X PATCH "${BASE_URL}/reslevis/alerts/${ALERT_ID}" \
  24. -H "Content-Type: application/json" \
  25. -d "{\"status\": \"${STATUS}\", \"operator\": \"${OPERATOR}\"}"
  26. echo ""
  27. echo ""
  28. echo "=== Alerts after update ==="
  29. curl -s -X GET "${BASE_URL}/reslevis/alerts?limit=100&offset=0" | jq '.'