0

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
  • 3
    Have you considered running a real monitoring system, like Munin (in the ports tree)?
    – Chris S
    Mar 7, 2014 at 4:54
  • Or monit? Which, is a nice light tool.
    – Zoredache
    Mar 7, 2014 at 5:09
  • It is not easy to write this script in bash. Quick example on perl: gist.github.com/citrin/9411934
    – citrin
    Mar 7, 2014 at 13:57

2 Answers 2

3

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).

1

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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .