Ad Widget

Collapse

pre-processing regex based on macro or variable in item prototye

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tamas-p
    Junior Member
    • Aug 2018
    • 15

    #1

    pre-processing regex based on macro or variable in item prototye

    Hi,

    Is there any way to pre-process a return value on some dynamic way in item prototypes?

    So I've got a api query which return about disks and bunch of properties.
    I have regex to cut out the desired value from the line, but it each item required to have a the ID in the regex to know which device it belongs to...

    Exaple regex:

    (\S{1,10})\W\W(propertyName).*[.](1)\s[=]\s.{1,10}\W\s(\d{1,16}|[a-zA-Z 0-9]{1,16})

    So in each item the red number would represent the disk id and group 4 would return a the actual value of propertyName
    I have managed to chuck this into a discovery so it does find the disks and create the items, but currently without manual intervention, it would record the property of each disks in each item (as text).. If I could parameter up a regex in the item prototype, I could cut of the desired value, but I would need to insert in at least the discovered diskID in there.

    Is there way with macro or whatever to do that?

    Thanks again
  • tamas-p
    Junior Member
    • Aug 2018
    • 15

    #2
    Ok, just to answer my own question, it simply can use the discovery values as of

    (\S{1,10})\W\W(propertyName).*[.]({#DISKID})\s[=]\s.{1,10}\W\s(\d{1,16}|[a-zA-Z 0-9]{1,16})

    Also to add that the the discovery rule was based on JSON return, which returns like:
    { "{#DISKID}":"1" },
    { "{#DISKID}":"2" },
    { "{#DISKID}":"3" },
    etc....

    Comment

    Working...