Ad Widget

Collapse

Please help with regex trigger

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Carl Fortin
    Junior Member
    • Oct 2016
    • 9

    #1

    Please help with regex trigger

    I'm trying to make this trigger work with a regex:

    I am using a UserParameter action that sends the following to Zabbix server:

    PJSIP/U_3820-0001faf7 UnixTime:1438

    I would like my trigger to return a problem if UnixTime is greater than 30.

    Here's what I have so far:

    {192.168.0.56:asterisk_check_stuck_channel.regexp( "UnixTime:.*$")}>30


    It is not working.

    Any help will be greatly appreciated
  • ovas
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Apr 2017
    • 138

    #2
    Hello!

    Please, pay attention that regexp() in trigger expression will return either 0 or 1 as per the documentation: https://www.zabbix.com/documentation...gers/functions

    Is your item a text that contain all the string "PJSIP/U_3820-0001faf7 UnixTime:1438" or a numeric that contain only "1438"? Wouldn't it be more convenient to store only numeric value and write triggers based off it?

    Comment

    • Carl Fortin
      Junior Member
      • Oct 2016
      • 9

      #3
      My item is a text that contains the whole string. I'd like to keep it that way because I want my action to send me an email containing the PJSIP/U_3820-0001faf7 part. Is there any function to cut part of the string and keep only the numeric value?

      What about regsub? https://www.zabbix.com/documentation...acro_functions
      Last edited by Carl Fortin; 20-04-2017, 14:00.

      Comment

      • ovas
        Senior Member
        Zabbix Certified Trainer
        Zabbix Certified SpecialistZabbix Certified Professional
        • Apr 2017
        • 138

        #4
        Originally posted by Carl Fortin
        Is there any function to cut part of the string and keep only the numeric value?
        Sorry, even if there is, I cannot find it.
        Originally posted by Carl Fortin
        My item is a text that contains the whole string. I'd like to keep it that way because I want my action to send me an email containing the PJSIP/U_3820-0001faf7 part.
        I can only offer to write down this text part in action message itself.

        Comment

        • Carl Fortin
          Junior Member
          • Oct 2016
          • 9

          #5
          I ended up using this that work for me:

          {192.168.0.56:asterisk_check_stuck_channel.regexp( "UnixTime: (3{1}[0-9]{1}|[0-9]{3}|[0-9]{4}|[0-9]{5})$")}=1

          It will trigger a problem if a numeric value is between 30 and 99999.

          Comment

          Working...