shm_leak_audit.sh.in 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!@BASHPATH@
  2. service corosync status >/dev/null
  3. CS_STATUS=$?
  4. if [ $CS_STATUS -eq 0 ]
  5. then
  6. # corosync running
  7. active=$(corosync-cmapctl runtime.connections.active | cut -d= -f2)
  8. if [ $active -lt 2 ]
  9. then
  10. FILES=$(ls /dev/shm/qb-*)
  11. for f in $FILES
  12. do
  13. if [[ "$f" =~ "blackbox" ]]
  14. then
  15. true
  16. else
  17. echo $f
  18. fi
  19. done
  20. else
  21. pids=$(corosync-cmapctl runtime.connections. | grep client_pid | cut -d= -f2)
  22. FILES=$(ls /dev/shm/qb-*)
  23. for f in $FILES
  24. do
  25. found=0
  26. for p in $pids
  27. do
  28. if [[ "$f" =~ "$p" ]]
  29. then
  30. found=1
  31. elif [[ "$f" =~ "blackbox" ]]
  32. then
  33. found=1
  34. fi
  35. done
  36. if [ $found -eq 0 ]
  37. then
  38. echo $f
  39. fi
  40. done
  41. fi
  42. else
  43. FILES=$(ls /dev/shm/qb-*)
  44. for f in $FILES
  45. do
  46. echo $f
  47. done
  48. fi
  49. exit 0