SOLVED: Check for empty device note?

Hello,

I’d like to set an alert rule depending on some string in the devices.notes.

The idea is to mark devices which are not always on (these have a “_NOTALWAYSON” in their device notes)
and add a condition to my “Device down” alert rule.
I don’t want to see any “Device down” alert for these, but any other alert for them,
when these are up. So ‘ignore’ or ‘disable’ is not an option for me.

I found out, that
%devices.notes !~ “_NOTALWAYSON” &&
does not work as I expected:

This statement is only true for devices that do have a device note, which does not contain “_NOTALWAYSON”.
It is not true for any empty ( null ) device notes (most of my devices don’t have one).

Is this a wanted behavior?

Can somebody give me a hint how to get around this?
How can I check for an empty “device note” (to include this into the alert rule condition)?

Thank you!

  • awaum

You can’t check for null fields like that. You need to use a macro:

Put this in config.php

$config['alert']['macros']['rule']['null_notes'] = "(notes IS NULL OR notes != '_NOTALWAYSON')";

Then add this to your rule: && %macros.null_notes = "1"

Works like a charm!
Thanks a lot for your help!

Best regards,

  • awaum