CPU Load Notifications


Userlevel 1
I'm trying to generate CPU traps when:
  1. CPU reaches 80% for a period of 5 minutes
  2. CPU falls 20% below 80% for a period of 5 minutes
I think I can achieve the first requirement with:
/etc/snmp/snmpd.conf

load 80
monitor -r 300 -o laNames -o laErrMessage "laTable" laErrorFlag !=0

However, I'm not sure what's the most efficient way to alert when the threshold falls 20% below 80% for a period of 5 minutes.
The Cisco syntax is:
process cpu threshold type total rising 80 interval 300 falling 20 interval 300
Thanks.


4 replies

Userlevel 2
B,

I did a little testing on the high and low thresholds. Running a short term test, I was able to generate a trap for the high, and falling.

Edit the /etc/snmp/snmpd.conf file, and I used the following 10sec test. I'm not even sure you need the "load" statement, but I had mine set to 5.

monitor -r 10 -o laNames -o laErrMessage "laTable" laLoad 60 80

Running "tail -f" on /var/log/syslog I saw the following messages:

2017-01-27T14:12:48.739701-06:00 leaf01 sysmonitor: Critically high load average: 10.07 (10.007)
2017-01-27T14:13:48.707639-06:00 leaf01 sysmonitor: CPU use no longer critically high: 58%

I used VX to test and had the CPU at 99% using the "stress" app.
"stress --cpu 10"

A few good resources helped me along.
Net-SNMP Mib table to figure out which OID's I needed to monitor:
http://www.net-snmp.org/docs/mibs/ucdavis.html#laTable

Net-SNMP Man page:
http://net-snmp.sourceforge.net/docs/man/snmpd.conf.html#lbAT

snmpwalk to check the laTable
snmpwalk 192.168.0.11 -v2c -c public .1.3.6.1.4.1.2021.10

The values aren't exactly what you are trying to test, but hopefully this is a starting point.

Best Regards,
Kevin
Userlevel 1
Kevin Witherstine wrote:

B,

I did a little testing on the high and low thresholds. Running a short term test, I was able ...

Thanks Kevin, I will give it a shot!
Userlevel 1
I don't see where the "stress" package is installed by default, nor does it show up after an apt-get update. Is there a certain repository that it needs to be pulled from?
Userlevel 2
B wrote:

I don't see where the "stress" package is installed by default, nor does it show up after an apt-...

Sorry, that may have been confusing. I installed "stress" just to peg the CPU to test the traps. I just used "sudo apt-get install stress" to install, don't recall having to manipulate the sources list.

Here's a nice cheat sheet for stress.
http://www.tecmint.com/linux-cpu-load-stress-test-with-stress-ng-tool/

Reply