Ad Widget

Collapse

regexp preprocessing with conditional return value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • trta
    Junior Member
    • Jul 2010
    • 18

    #1

    regexp preprocessing with conditional return value

    I can get these values from item:

    Code:
    OK LOGIN Completed
    or
    Code:
    NO LOGIN Error message
    I would like to regexp that by something like
    Code:
    .*(OK|NO) LOGIN(.*)
    and want to get

    Code:
    if ok return value \1, if NO then return value \2 (that Error mesage)
    At now, I can get "OK" or "NO" easilly but I don't know how to create something like "if"

    How can I make it please?
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    JS preprocessing, I think... regular regex will not do it for you...

    Comment

    • Hamardaban
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • May 2019
      • 2713

      #3
      In preprocessing:
      step 1) "Matches regular expression​" compare with "^NO LOGIN.*". Check the option "Custom on fail​" and output the value "OK".
      step 2) "Regular expression​" "^NO LOGIN(.*)"- output the first group \1.

      Comment

      • cyber
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Dec 2006
        • 4807

        #4
        Right... 2 steps... stupid me...

        Comment

        Working...