Is there a command for FreeBSD (except the top -P) I could use to monitor my dedicated server CPU usage? I am in progress of writting my bash script which will notify me as soon as any of the CPU core will be reaching 100% usage.

Thats why I need some other command than top -P because it takes some time for the top to calculate the usage on the first run and than wouldnt work for per usage command.

  • 3
    Have you considered running a real monitoring system, like Munin (in the ports tree)? – Chris S Mar 7 '14 at 4:54
  • Or monit? Which, is a nice light tool. – Zoredache Mar 7 '14 at 5:09
  • It is not easy to write this script in bash. Quick example on perl: – citrin Mar 7 '14 at 13:57
up vote 3 down vote accepted

CPU load information can be obtained in shell script from sysctl kern.cp_times. This is commulative counters, and to get load in % you need derivative, e. g. get kern.cp_times with 1 minute interval and divide counters by 60.

But more easy to use existing monitoring systems like Nagios (there are many monitoring systems, but no perfect and I can't suggest best system).

You could always install sysstat

Then do the following: sar -u | grep 'Average' | awk '{print 100-$8}'

Which will take 100 & remove the idle percent.

  • There is no sar on the FreeBSD systems. – Lucas Mar 7 '14 at 14:21

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.