dbus_quota_watch.sh 1.0 KB

123456789101112131415161718192021
  1. #!/bin/bash
  2. # Logs what the session bus holds while a wallpaper is paused behind a fullscreen window: the broker's memory, how many
  3. # cursor calls KWin sends the engine per second and how often the broker kicked programs off the bus.
  4. # Usage: tools/dbus_quota_watch.sh [interval seconds, default 10]
  5. interval=${1:-10}
  6. broker=$(pgrep -u "$(id -u)" -xo dbus-broker)
  7. if [ -z "$broker" ]; then
  8. echo "no dbus-broker running for this user" >&2
  9. exit 1
  10. fi
  11. while true; do
  12. calls=$(timeout 5 dbus-monitor --session "type='method_call',member='OnCursorMoved'" 2>/dev/null | grep -c 'member=OnCursorMoved')
  13. rss=$(ps -o rss= -p "$broker" | tr -d ' ')
  14. kicked=$(journalctl --user -b --no-pager 2>/dev/null | grep -c 'being disconnected as it does not have the resources')
  15. quota=$(journalctl --user -b --no-pager 2>/dev/null | grep -c "exceeded its 'bytes' quota")
  16. printf '%s broker_rss_kb=%s cursor_calls_per_5s=%s kicked_peers=%s quota_hits=%s\n' "$(date +%T)" "$rss" "$calls" "$kicked" "$quota"
  17. sleep "$interval"
  18. done