Conservative SmartOS global-zone memory pressure guard with dry-run-first policy and SMF integration.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

53 lignes
2.0 KiB

  1. #!/bin/sh
  2. set -eu
  3. manifest=smf/o6h-memory-guard.xml
  4. config=etc/o6h-memory-guard.conf
  5. if grep -Fq -- '--force-dry-run' "$manifest"; then
  6. echo 'FAIL SMF manifest must not force dry-run' >&2
  7. exit 1
  8. fi
  9. test "$(grep -Fxc ' exec="/opt/custom/bin/o6h-memory-guard --daemon --config /opt/custom/etc/o6h-memory-guard.conf"' "$manifest")" -eq 1
  10. test "$(grep -Fxc ' <common_name><loctext xml:lang="C">o6h memory pressure guard</loctext></common_name>' "$manifest")" -eq 1
  11. test "$(grep -Fxc 'ACTION_MODE dry-run' "$config")" -eq 1
  12. test "$(grep -Fxc 'SYSLOG_ENABLED yes' "$config")" -eq 1
  13. test "$(grep -Fxc 'SYSLOG_FACILITY local5' "$config")" -eq 1
  14. while IFS= read -r setting; do
  15. test "$(grep -Fxc "$setting" "$config")" -eq 1
  16. done <<'EOF'
  17. PRE_SECONDS 1
  18. PRESSURE_SECONDS 2
  19. CRITICAL_SECONDS 2
  20. RECOVERY_SECONDS 15
  21. CRITICAL_TERM_GRACE_SECONDS 5
  22. EMERGENCY_TERM_GRACE_SECONDS 1
  23. FLOOR_KILL_DELAY_SECONDS 0
  24. MAX_CACHED_CANDIDATE_AGE_SECONDS 15
  25. MAX_VICTIMS_EPISODE 4
  26. MAX_VICTIMS_MINUTE 4
  27. MAX_EMERGENCY_VICTIMS_EPISODE 8
  28. MAX_FLOOR_VICTIMS_EPISODE 12
  29. EOF
  30. grep -Fq -- '"--force-dry-run"' src/main.c
  31. grep -Fq 'openlog(ident, LOG_PID | LOG_NDELAY' src/support.c
  32. grep -Fq 'syslog(priority, "%s", message)' src/support.c
  33. grep -Fq 'closelog()' src/support.c
  34. if grep -Eq '(system|popen|execl|execv)[[:space:]]*\(' src/support.c; then
  35. echo 'FAIL syslog backend must not invoke commands or a shell' >&2
  36. exit 1
  37. fi
  38. grep -Fq '#define CACHED_CANDIDATES 16' src/main.c
  39. grep -Fq '#define EVENT_QUEUE_SIZE 512' src/main.c
  40. grep -Fq 'pthread_mutex_trylock(&event_mutex)' src/main.c
  41. grep -Fq 'pthread_mutex_trylock(&scan_mutex)' src/main.c
  42. signal_line=$(grep -n ' platform_dispatch' src/main.c | cut -d: -f1)
  43. commit_line=$(grep -n 'action_commit(&controller' src/main.c | cut -d: -f1)
  44. enqueue_line=$(grep -n 'enqueue_start = monotime' src/main.c | cut -d: -f1)
  45. test "$signal_line" -lt "$commit_line"
  46. test "$commit_line" -lt "$enqueue_line"
  47. echo 'PASS distribution defaults to ACTION_MODE dry-run; production SMF does not force it'