You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using IcingaWeb2 with Director and the automation abilities of Director to create hosts and services.
In it's Sync Rules, Director allows to set values based on a filter and i try to use that feature to set some attributes to "$null$" when certain input values are empty. Setting attributes to $null$ has the effect that the parameters of check-commands, which correspond to that attributre, are being ignored when the command is run.
I haven't found a way so far to configure the filter so it matches an empty value, nor did i find a way to filter on a generic "non-empty" value.
Director is using the FilterExpression library of Icingaweb2, so i cannot file that issue with Director project, but with IcingaWeb2 project..
So my suggestion is to allow using regex matches in filters. The idea is to allow the user to write a filter expression like the following:
sourcefield=~^.+$~
to match on "sourcefield" having at least one character. So the regex is surronded with tildes and the FilterExpression library recognized that special char and does a "preg_match" in the background.
I identified a single file where changes would be neccessary.
`
*** FilterExpression.php_orig Fri Sep 2 12:10:27 2022
--- FilterExpression.php Fri Sep 2 12:11:33 2022
***************
*** 185,190 ****
--- 185,197 ----
}
`
I have one issue with this patch: If i use backslashes in the string, that backslash gets exchanged with two backslashes, making a regex like ^\S+$ to mach any number of non-space characters not working. I guess there is some sort of string manipulation somewhere in the Director code, but i couldn't figure out where :(
Unfortunately i have not an overview of other side-effects this little change could have, so i ask you to check...
Greetings
Andreas
The text was updated successfully, but these errors were encountered:
regex is not an option, what the PHP implementation of filters support must be supported by SQL also for example. Your use case is already possible on SQL level by using sourcefield=*. Though, the PHP implementation is missing that currently. Try #4914.
I am using IcingaWeb2 with Director and the automation abilities of Director to create hosts and services.
In it's Sync Rules, Director allows to set values based on a filter and i try to use that feature to set some attributes to "$null$" when certain input values are empty. Setting attributes to$null$ has the effect that the parameters of check-commands, which correspond to that attributre, are being ignored when the command is run.
I haven't found a way so far to configure the filter so it matches an empty value, nor did i find a way to filter on a generic "non-empty" value.
Director is using the FilterExpression library of Icingaweb2, so i cannot file that issue with Director project, but with IcingaWeb2 project..
So my suggestion is to allow using regex matches in filters. The idea is to allow the user to write a filter expression like the following:
to match on "sourcefield" having at least one character. So the regex is surronded with tildes and the FilterExpression library recognized that special char and does a "preg_match" in the background.
I identified a single file where changes would be neccessary.
`
*** FilterExpression.php_orig Fri Sep 2 12:10:27 2022
--- FilterExpression.php Fri Sep 2 12:11:33 2022
***************
*** 185,190 ****
--- 185,197 ----
}
`
I have one issue with this patch: If i use backslashes in the string, that backslash gets exchanged with two backslashes, making a regex like
^\S+$to mach any number of non-space characters not working. I guess there is some sort of string manipulation somewhere in the Director code, but i couldn't figure out where :(Unfortunately i have not an overview of other side-effects this little change could have, so i ask you to check...
Greetings
Andreas
The text was updated successfully, but these errors were encountered: