Alert for CPU and memory usage

Hello, I searched in the FAQ and in the documents provided by LibreNMS but I didn’t found what I want. So I want to create an alert rule for CPU usage and memory too if they are equal to or greater then 80% but only send an email if this rule it’s true for 5 minutes. Like if it’s equal or greater then 80% during 5 minutes, send an email, else if it’s just 2 minutes, don’t send an email.
I know how to send an email, I know how to do the rules for cpu if it’s equal or greater, but what it’s missing is the 5 minutes.
I looked how the macros “macros.past_5m” work, but it doesn’t send me anything : eventlog.timestamp = macros.past_5m

I also do override SQL like so :

SELECT * FROM WHERE (devices.device_id = ?) AND (DATE_SUB(NOW(),INTERVAL 5 MINUTE)) = processors.processor_usage >= "80

And when I look into “capture debug information” of my device it says “matches” but it didn’t send me an email or an alert.

I’m new with it, I really appreciate your help. Also sorry if my english is not good.

can you post the alert you are working on?

Yes sure.

Thanks for replying.

I made some mistakes in the alert like there is no “s” at the end of “timestamp” and also “timestamp” is not a type,sorry I am still trying to understand. I’m now testing to make an alert just for when the memory or the cpu is gonna reach the 80% and with these alert, I’m gonna use the timestamp in the eventlog of the device and use the macros.

That wont work. You are mixing a sensor with eventlog entries.

What do you want exactly with that rule?

Sometimes, the CPU or the memory only reach over the 80% for one minute or less when we open an application for example and it send me an email everytimes. I only want an alert (and an email) when it reach 80% or greater for 5 minute or more. Thanks you

Then use the delay field in alert rule

I was thinking about it but, if I put the delay to 5 minutes and the rules match, does it recheck before sending an emails? Or it’s just waiting 5 minutes without rechecking to send an email. I also saw a topic that saying it didn’t recheck :

And it depends on the poller too. Or maybe I don’t really understand what they were saying.

Device will be cheked BEFORE sending the notification after delay time.

Thank you, I’m gonna make some other tests to make sure but it seems to work. thank you for being so patient with me. :slight_smile: :smiley: