• Monitoring a single process

    From Stefan Monnier@21:1/5 to All on Tue Jan 7 15:10:01 2025
    Is there a tool somewhere that lets me monitor a single process?

    Something I'd run, passing it a PID and which would display a regularly refreshed status of what the process is doing: MB/s read from the
    filesystem, MB/s written to the filesystem, maybe even with more detail
    (actual file name(s) accessed maybe summarized as directories if there
    are too many), same thing for the network, amount of CPU being used,
    ideally even some indication of "where" that CPU time is spent
    (e.g. among the mmaped files containing code, which one contains the
    code where we're spending most of the time?).
    Also, percentage of time spent waiting (and if so, waiting for what
    kind of resource, ...)?

    `strace` gives enough data to compute at least part of the above info,
    so it seems doable, but I haven't seen any reference to such a tool pass
    by my desk over the years. What am I missing?


    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael Stone@21:1/5 to Stefan Monnier on Tue Jan 7 16:30:02 2025
    On Tue, Jan 07, 2025 at 09:08:52AM -0500, Stefan Monnier wrote:
    Is there a tool somewhere that lets me monitor a single process?

    Look at pidstat in the sysstat package. I think you'll need multiple
    tools to get everything you're looking for, e.g., maybe lsof.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Frank Guthausen@21:1/5 to Stefan Monnier on Tue Jan 7 16:20:01 2025
    On Tue, 07 Jan 2025 09:08:52 -0500
    Stefan Monnier <monnier@iro.umontreal.ca> wrote:

    Is there a tool somewhere that lets me monitor a single process?

    [...]

    `strace` gives enough data to compute at least part of the above info,
    so it seems doable, but I haven't seen any reference to such a tool
    pass by my desk over the years. What am I missing?

    Without a solution, but at least an idea:

    You could write your own customized shell script to extract any
    information you'd like to have, and then run this script with a
    wrapper tool like ``watch''.
    --
    kind regards
    Frank

    -----BEGIN PGP SIGNATURE-----

    iQGzBAEBCgAdFiEE86z15c6qwvuAkhy+zDIN/uu9BloFAmd9RW0ACgkQzDIN/uu9 BlpJnQv+ORtL8uBVAo7A6fZvtb4tvDNOKAq+StyBxXl8a3w3O2VbMiWwdMolL9OB zaKMWLTp6QDfc15c0rL3KQfL7zOVLGHY4+CZRV43i+t/m5qWsaYbXCnmiKApBHku 2s0fcNBtQQgFn187Z5yXoxu0T6GnkQ8HycaZaNvBY6lzvNCXFuf1JmHClKMpXAgQ s+zP6r0ZYxE20i5vn2gWxYJA6biuKDvgg/u/wIHQgwhgo0mweA0yOjGGJZIIumSt IxTFF0QorkNJC2X9h9eJnaZnSATQ+i9XrMvTSal5g35lr0peHfiriBxhvw0TIFTM 9Ob+gBh0sWAraGLchJNxU5MRkTsP7CWklAgS+mI+prvGyoHbwTqpkbqsszCCLOzv ui/lQQql/MeJS8KdQ3ttOGamucxcsYh3ti1+KDU4Agfyjl6UJ6n/LjUfBYltIczZ c3XFX33u+A/dheMseZT38e9nhibjdTZds8lFovH6QmsKXiPaEyUI25mD5xyLtQ1+
    YStEM2ZK
    =gVwV
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael Stone@21:1/5 to Michael Stone on Tue Jan 7 16:40:01 2025
    On Tue, Jan 07, 2025 at 10:25:02AM -0500, Michael Stone wrote:
    On Tue, Jan 07, 2025 at 09:08:52AM -0500, Stefan Monnier wrote:
    Is there a tool somewhere that lets me monitor a single process?

    Look at pidstat in the sysstat package. I think you'll need multiple
    tools to get everything you're looking for, e.g., maybe lsof.

    look at fatrace also

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Ritter@21:1/5 to Stefan Monnier on Wed Jan 8 04:40:01 2025
    Stefan Monnier wrote:
    Is there a tool somewhere that lets me monitor a single process?

    Something I'd run, passing it a PID and which would display a regularly refreshed status of what the process is doing: MB/s read from the
    filesystem, MB/s written to the filesystem, maybe even with more detail (actual file name(s) accessed maybe summarized as directories if there
    are too many), same thing for the network, amount of CPU being used,
    ideally even some indication of "where" that CPU time is spent
    (e.g. among the mmaped files containing code, which one contains the
    code where we're spending most of the time?).
    Also, percentage of time spent waiting (and if so, waiting for what
    kind of resource, ...)?

    htop is in Stable and can be narrowed down to one user or one
    process ID via command line flags.

    -dsr-

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Monnier@21:1/5 to All on Fri Jan 17 06:00:01 2025
    Thank you for all your answers, this pointed me to tools I was not aware
    of and to options I was not aware of in tools I knew.

    `lsof` seems able to give me a lot of info, but has so many options that
    I haven't yet found a way to give me something more or less useful.
    But at least I now know that it can do a lot more than tell me who's
    preventing me from unmounting a filesystem. 🙂

    `pidstat`, `htop`, and `iotop` are closer to what I was imagining, but
    they're also coarser. And AFAICT none of them give me info about the
    network activity, focusing on CPU/MEM/DISK only.

    One of my main uses is when a tool is sitting there without giving me
    any feedback and I'm wondering what it is that it's doing.
    E.g. recently this occurred with `bup`, where I wanted to see if it was
    mostly talking to the remote `bup`, or mostly reading local files or
    writing local files (so as to guess in which phase
    it is, and whether it's making progress), or none of the above
    (e.g. because the network connection got stuck).


    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michel Verdier@21:1/5 to Stefan Monnier on Fri Jan 17 10:00:02 2025
    On 2025-01-16, Stefan Monnier wrote:

    E.g. recently this occurred with `bup`, where I wanted to see if it was mostly talking to the remote `bup`, or mostly reading local files or
    writing local files (so as to guess in which phase
    it is, and whether it's making progress), or none of the above
    (e.g. because the network connection got stuck).

    For activity perhaps :
    watch ip stats show dev eth0 group link

    For freeze somewhere on the road :
    ping -n www.debian.org
    or more detailed
    mtr -n www.debian.org

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)