Solved

REGEX - problem when entering

  • 1 November 2023
  • 5 replies
  • 182 views

Badge +1
  • Steward *
  • 3 replies

To check “Traffic-Generic-Name” I need to exclude interface "lo" from checking. This can be done using regex '^(?!lo$)':

The problem occurs when entering via GUI. It will autocomplete the expression and the command is not executable.

I haven't found anywhere a description of how to write the expression to be interpreted correctly.


Thank you for your advice.

icon

Best answer by Thibault 9 November 2023, 11:49

View original

5 replies

Badge +4

Hi,

Remove the “$” in your INTERFACENAME value maybe? No need to have two end of string following each other.

Or replace it by “\b”?

Badge +1

I don't know how to remove the "$" character. Centreon automatically adds " '^ " at the beginning and " $' " at the end of the entered expression in the GUI. I know the problem is with the last "$" in the expression, but I can't get rid of it.

Userlevel 3
Badge +5

Hello,

the “Traffic-Generic-Name” template is meant to be used to monitor a single interface (on top of the service discovery feature), this is why the default regex has ^$ in it. So in your case you’ll have to set ‘eth0’ in the INTERFACENAME macro.

If you want to monitor several interfaces and then filter them with regex, it’s better to use the “Traffic-Global” template

But the best practice is to have one service per interface (so you won’t miss any alert if you have issues on several interfaces at the same time) ;-)

Badge +1

In that case, I don't understand why the "lo" interface is automatically included. But your answer gave me a solution. Thank you very much.

Badge +4

I don't know how to remove the "$" character. Centreon automatically adds " '^ " at the beginning and " $' " at the end of the entered expression in the GUI. I know the problem is with the last "$" in the expression, but I can't get rid of it.

I mean to remove the “$” you put in your INTERFACENAME value. So, “(?!lo$)” became “(?!lo)” or “(?!lo\b)”.

 

But if Thibault’s answer suits you, it’s fine.

Reply