cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 9

Alert/Trigger - update Custom Property value - sql/regex help needed

Already using the method of an alert that triggers when an interface's (WAN link) speed change event is issued.

We use that event to trigger an update to the Interface's owning Node Custom Property (Bandwidth) - so when the WAN link is upgraded from (say) 10 Mbs to 100 Mbs, it is auto detected and the new value appears in the Node details view and (more importantly) in the popup when you hover over the Node link.

 

Now, every interface that is a Telco WAN link has a description like 'GigabitEthernet0/1/0 - Telco WAN Link - FxxxxxxN' where FxxxxxxN is the Telco line/circuit number.

We have a Custom Property field for the Node (TelcoCircuit) that is (currently) populated manually.

What we would like to do is use the Alert/Trigger/Update CP mechanism to auto populate the Node CP (similar to the Bandwidth CP described above).

 

Due to a lack of standards and different people configuring the routers/interfaces, as well as the circuit number format(s) not always standard, this has gotten complex.

 

Any ideas if/how (in the Trigger condition) I can use regex to pull the Circuit number out to plug into the Node CP?

 

And if that is possible (I could not work out if so, or how), any chance someone could provide info/example of how to pull the FxxxxxxxN string out of the example above? (If I can get actually do this, and get an example, I can then tweak the regex to cater for the variable Circuit Number formats - my biggest issue is can I even execute regex in the Trigger Condition dialog - cannot seem to resolve this).

 

Any and all help is appreciated.

 

0 Kudos
1 Reply

Orion does all the alert logic using ms sql, which doesn't exactly have a regex engine but it has a like operator and some functions that can usually accomplish the most typical examples of string parsing. So for the alert condition you probably will want to do a custom sql condition for interfaces
where isnull(nodes.telcocircuit,'') not like substring(patindex('%F_______N%', interfaces.caption),1,9)
Then your alert action would be to set the node property to a custom variable using the same sql to extract the circuit id.
I typed this from my phone so hopefully its mostly accurate, but you can see documentation of the functions to get you the rest of the way here
https://www.w3schools.com/sql/func_sqlserver_substring.asp
https://www.w3schools.com/sql/func_sqlserver_patindex.asp
https://codingsight.com/t-sql-regular-expression-like-operator-and-its-use-cases/
https://www.w3schools.com/sql/sql_isnull.asp

- Marc Netterfield, Github
0 Kudos