# Monitoring disk I/O on FreeBSD



## Bren (Jul 31, 2020)

We use FreeBSD for our storage servers. One thing I've noticed is that there doesn't appear to be any way to programmatically get disk I/O statistics on FreeBSD like you can with Linux and others (e.g. `/proc/diskstats` on Linux). I'm assuming this is why our current monitoring system (CheckMK) doesn't monitor disk I/O on FreeBSD. Looking at moving to Prometheus and its node exporter doesn't support disk stats on FreeBSD either. Does anyone know why this is? I've always been curious about this.

We have had to just live without disk I/O stats on FreeBSD. That said, I've been really thinking about this lately and I think I have a way to use iostat and/or DTrace to get detailed I/O stats into our monitoring system.

How do you monitor disk I/O on FreeBSD?


----------



## ralphbsz (Jul 31, 2020)

I use iostat. When I was tracking down why my ZFS scrubs were causing the disks to hang, I actually had some scripts ready to go, with just the right parameters, but a moment ago I couldn't find them. I probably stored them in /tmp and called them "monitor.sh" or something dumb like that. The key to iostat is to spend 10 minutes fiddling with options and parameters, until you get the output you want. Or just run it with as much output as possible, and post-process the chatter for the summaries you like.

The other thing is: run "zpool iostat" (typically some variants, like -v) in a loop, and take differences of the numbers (pretty simple in an awk script).


----------



## Lamia (Jul 31, 2020)

systat -iostat


----------



## Bren (Jul 31, 2020)

ralphbsz said:


> I use iostat.



Yeah I use iostat etc. regularly. I'm talking more about enterprise / long term monitoring and alerting. Now that I say this, I'm wondering if net-mgmt/net-snmp has the OIDs I'm looking for. If I recall, I tested this before and disk I/O wasn't there either.


----------



## Phishfry (Jul 31, 2020)

Jerry said:


> How do you monitor disk I/O on FreeBSD?


gstat(8)





						TIB AV-Portal
					






					av.tib.eu
				











						GitHub - tykling/gstat_exporter: Prometheus exporter for FreeBSD gstat data
					

Prometheus exporter for FreeBSD gstat data. Contribute to tykling/gstat_exporter development by creating an account on GitHub.




					github.com


----------



## Bren (Jul 31, 2020)

gpb said:


> Also look if Netdata provides it for FreeBSD.



I actually just installed netdata again and it looks like it _does_ support more advanced disk stats on FreeBSD. The last time I checked it did not. They now have a free cloud component to aggregate all your servers too (though I'm not sure I'm 100% in love with that idea just yet).



Phishfry said:


> gstat(8)



Awesome. Just what I was looking for. Thanks!


----------



## Mjölnir (Jul 31, 2020)

`apropos accounting` RTFM sa(8)
`pkg search monitor` `make -C /usr/ports search key=monitor | egrep '^(Port|Info):' | less`


----------



## Alain De Vos (Jul 31, 2020)

I use "iostat -c 3"


----------

