BSD monitoring

I run FreeBSD 13 on a VM and occasionally CPU maxes out and never goes back to something useful. This started after my upgrade to 13.2 from 13.1. I know that CPU maxes out from my VM provider. When cpu is high, I can't ssh to the box and figure out what is causing the issue. Eg I'm completely in the dark wrt what is causing the CPU spikes.
I thought about installing bsdsar but that's not available anymore, what are my option to
- have something that looks regularly at what is consuming cpu and records that on disk
- let's me see said data after a reboot (whihc is my current solution).

Ludo
 
As a light solution I am aware of top but I don't think you can use it in a script, otherwise it's the big tools like those in the following link:
 
Just use cron
Run every few minutes and save somewhere the output of required tools (top, gstat, netstat, etc.).

Example:
Code:
top -n > /tmp/top-`date "+%Y%m%d-%H%M"`

You will have a chance to review a lot of text files with all required info.
 
I know that CPU maxes out from my VM provider.
Are in those logs timestamps recorded, if yes, check out if this high CPU usages take place at the same time (assuming the high usages is temporary)?

Could be something from /etc/periodic/daily/.

When cpu is high, I can't ssh to the box and figure out what is causing the issue.
Do you mean the system is totally frozen or just sluggish? If the system is frozen, and the file system can't be accessed to write on, that would make logging not very likely.

Does the high CPU usage dissipate in time or does it stay indefinitely?
I thought about installing bsdsar but that's not available anymore, what are my option to
- have something that looks regularly at what is consuming cpu and records that on disk
You could create an crontab(5) to run top(1) in "batch" mode (-b , also, besides other options, -q could be of use) at certain intervals and redirect (append) the output to a log file.


How is the VM configured, RAM, number of CPU's,
 
Back
Top