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.

Lucas
  • 163
  • 3
  • 10

2 Answers2

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

voretaq7
  • 79,879
  • 17
  • 130
  • 214
citrin
  • 469
  • 2
  • 5
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.

Sayajin
  • 169
  • 2
  • 10