16

I wonder how I can monitor which process takes out all my I/O bandwith. The only command I know is gstat but it shows cumulative info. Are there any tools I can use to inspect the running processes for their I/O usage? The system is FreeBSD 8.3.

Mateusz Piotrowski
  • 8,029
  • 10
  • 53
  • 79
Sergey Efimov
  • 473
  • 1
  • 3
  • 16

4 Answers4

16

The answer is to use top then hit m to display IO percentage per process/thread.

Mateusz Piotrowski
  • 8,029
  • 10
  • 53
  • 79
Sergey Efimov
  • 473
  • 1
  • 3
  • 16
  • 9
    What version of 'top' is this in? On mine 'm' toggles the memory usage summary. – Daniel Kitachewsky Jun 05 '13 at 09:05
  • 2
    @DanielKitachewsky - Works on my FreeBSD: `$ top -v` gives `top: version 3.5beta12`. FreeBSD *does* use a different top than most Linux distrubitions. On my Linux boxes, 'm' toggles memory usage like you mentioned. – beatgammit Oct 22 '13 at 20:51
  • 1
    Try `shift+m` to short by memory percentage. `shift+p` for cpu and `shift+t` for time – John Veldboom Aug 14 '14 at 13:36
9

iotop is what you want. Most of linux distribution have a package for it.

Jude
  • 428
  • 4
  • 8
  • 1
    But FreeBSD doesn't (at least not in ports). I think `iotop` uses Linux's /proc, which is *not* the same on FreeBSD. – beatgammit Oct 22 '13 at 20:53
  • 1
    I wonder why is this upvoted so much and accepted, when the tool doesn't even exist on freebsd? – eis Jun 12 '17 at 06:52
  • 9
    THIS ANSWER DOES NOT WORK ON FREEBSD! Check out working answers below or use `top -m io -o total` – Allen Luce May 24 '18 at 00:29
3

You can use ktrace if you want to trace a single process:

$ ktrace -ti -p PID

Do read the manual for ktrace so you know how to disable ktrace before using. Something like:

$ ktrace -p PID -f debug.txt  
$ ktrace -C
$ kdump -f debug.txt

kdump, since the output isn't human readable.

eis
  • 51,991
  • 13
  • 150
  • 199
0

According to a quick research, for Network analysis: you can either use lsof -i or sockstat (http://www.freebsd.org/cgi/man.cgi?query=sockstat&sektion=1) to identify the sockets opened by specific processes, then you can use tcpdump to check the details of that connection (http://www.thegeekstuff.com/2010/08/tcpdump-command-examples/#more-5676). You can also try trafshow and iftop.

For Disk I/O: on Linux I use sar -q, there must be something similar.

the_marcelo_r
  • 1,847
  • 22
  • 35
  • I have no problem with network, only with high I/O of disk (as seen from gstat) – Sergey Efimov Dec 24 '12 at 13:17
  • My bad, I saw "bandwidth" in your question and got confused. Here's an interesting article: http://www.bsdnewsletter.com/bsda-book/Monitor_disk_input--output.html, hope it helps. – the_marcelo_r Dec 24 '12 at 13:24
  • Did you check this other question? http://stackoverflow.com/questions/3965821/freebsd-iostat-how-to-tell-if-theres-a-problem?rq=1 – the_marcelo_r Dec 24 '12 at 13:40