Alerts from Sensor oid

Hey there

i need a little help, i’ve been trying and trying but cnat seem to get it to work;

i need to trigger an alert if a certain oid changes !=2.

i created a macro:
$config[‘alert’][‘macros’][‘rule’][‘Juniper Yellow Alert’] = ‘%sensors.sensor_oid=".1.3.6.1.4.1.2636.3.4.2.2.1"’;

then i do a rule:

%macros.Juniper Yellow Alert != “2”

but nothing triggers, though i have many devices with the state value 3, and in the main page of the device it even says the alarm is triggered (another solution could be to make health alarms trigger?)

Don’t use spaces in the macro name, it will possibly lead to issues.

You need to add && %sensors.sensor_current != “2” to that macro I think then %macros.macro_name = 1

hmmm i removed the spaces in the names in the macro and did the rule like this:

%macros.JuniperRedAlert = "1" && %sensors.sensor_current != "2" 

but no change, no alerts…

Run an alert capture on a device you think it should be alerting on. It will give you the mysql query. Take a look at the data in the sensors table for that device and see if it should match.

hehe i just need to be patient - now the alarms arrieves :slightly_smiling_face:

last question: how to i add to the rule, that it should only be of certain model/product?

do i do an device.

where do i do an alert capture? in the cli?

try https://docs.librenms.org/Alerting/Rules/#testing-alerts

In the webui -> click the cog and capture.

To add the rule to a certain model, create a device group using that model and associate the rule - or just add to the rule.