Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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).

share|improve this answer

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.

share|improve this answer
There is no sar on the FreeBSD systems. – Lucas Mar 7 '14 at 14:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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