shm_leak_audit.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  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. found=1
  33. fi
  34. done
  35. if [ $found -eq 0 ]
  36. then
  37. echo $f
  38. fi
  39. done
  40. fi
  41. else
  42. FILES=$(ls /dev/shm/qb-*)
  43. for f in $FILES
  44. do
  45. echo $f
  46. done
  47. fi
  48. exit 0