Ad Widget

Collapse

Trigger checking for returned string - Web Scenario

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lpossamai
    Senior Member
    • Jun 2018
    • 119

    #1

    Trigger checking for returned string - Web Scenario

    Hi all,

    I've got a Zabbix Server 3.4 with a Web Scenario setup. The Web scenario looks like:

    Code:
    Headers: 
    Content-Type => text/xml
    Required string => "APIcheckTest1" status="up"
    Required status codes => 200
    URL: https://api.example.com/Ping/1.1
    That works fine and I have created a trigger like:
    Code:
    {webserver.example.com:web.test.rspcode[API_example.com,API - APIcheckTest1].[B]min([/B]5m[B])[/B]}<>200
    however, I also need another trigger for the Required string. If the required string returns anything but ("APIcheckTest1" status="up"), then triggers an alert.

    Already tried this thread but it does not work for me.

    Any tips?
    Thanks in advance!
  • kernbug
    Senior Member
    • Feb 2013
    • 330

    #2
    Originally posted by lpossamai
    Hi all,

    I've got a Zabbix Server 3.4 with a Web Scenario setup. The Web scenario looks like:

    Code:
    Headers:
    Content-Type => text/xml
    Required string => "APIcheckTest1" status="up"
    Required status codes => 200
    URL: https://api.example.com/Ping/1.1
    That works fine and I have created a trigger like:
    Code:
    {webserver.example.com:web.test.rspcode[API_example.com,API - APIcheckTest1].[B]min([/B]5m[B])[/B]}<>200
    however, I also need another trigger for the Required string. If the required string returns anything but ("APIcheckTest1" status="up"), then triggers an alert.

    Already tried this thread but it does not work for me.

    Any tips?
    Thanks in advance!
    Hello
    I think '.regex' time for web monitoring: https://www.zabbix.com/documentation...ar_expressions
    Search string: (status)(=)("up") or this one ((?:[a-z][a-z]+))(.)(("up").

    Comment

    • lpossamai
      Senior Member
      • Jun 2018
      • 119

      #3
      Originally posted by kernbug

      Hello
      I think '.regex' time for web monitoring: https://www.zabbix.com/documentation...ar_expressions
      Search string: (status)(=)("up") or this one ((?:[a-z][a-z]+))(.)(("up").
      Do you mean "web.page.regexp[]"?

      So it would be something like???
      Code:
      {webserver.example.com:web.page.regexp[https://api.example.com,/Ping/1.1,443,(status)(=)("up")]}
      Cheers!

      EDIT 1:

      Tried to simulate that and I get an error from the Zabbix Server:
      Code:
      zabbix_get -s webserver.example.com -k "web.page.regexp[api.example.com,/Ping/1.1,443,(status)(=)("up"),10]"
      
      ZBX_NOTSUPPORTED: HTTP get error: cannot connect to [[webserver.example.com]:443]: [4] Interrupted system call
      Last edited by lpossamai; 21-06-2018, 02:00.

      Comment

      • kernbug
        Senior Member
        • Feb 2013
        • 330

        #4
        Originally posted by lpossamai


        Tried to simulate that and I get an error from the Zabbix Server:
        Code:
        zabbix_get -s webserver.example.com -k "web.page.regexp[api.example.com,/Ping/1.1,443,(status)(=)("up"),10]"
        
        ZBX_NOTSUPPORTED: HTTP get error: cannot connect to [[webserver.example.com]:443]: [4] Interrupted system call
        Hello

        Code:
        zabbix_get -s webserver.example.com
        Hello

        In your example: webserver.example.com - whose is this address?

        Comment


        • lpossamai
          lpossamai commented
          Editing a comment
          That is same server as api.example.com.. sorry my mistake.
      • kernbug
        Senior Member
        • Feb 2013
        • 330

        #5
        Do you have Zabbix Agent on this web server?

        Comment


        • lpossamai
          lpossamai commented
          Editing a comment
          yes... i do!
      • lpossamai
        Senior Member
        • Jun 2018
        • 119

        #6
        Does anyone have any tips here? Still trying to figure this out....

        Cheers!

        Comment

        • lpossamai
          Senior Member
          • Jun 2018
          • 119

          #7
          UPDATE:

          test.xml:
          Code:
          <?xml version="1.0" encoding="UTF-8"?><ping><service name="APITest1" status="up"/><service name="APIcheck1" status="down"/></ping>

          Tried with (from the webserver itself):
          Code:
          zabbix_agentd -t 'web.page.regexp[localhost,test.xml,80,\"APITest1\"]'
          Returns: [s|"APITest1"]
          
          zabbix_agentd -t 'web.page.regexp[localhost,test.xml,80,/"APITest1" status="up"\/>/]'
          Returns: web.page.regexp[localhost,test.xml,80,/"APITest1" status="up"\/>/] [s|]

          Comment

          • kernbug
            Senior Member
            • Feb 2013
            • 330

            #8
            Hi,

            Code:
             
             zabbix_agentd -t 'web.page.regexp[localhost,test.xml,80,[COLOR=#FF0000]\"APITest1\"[/COLOR]]' Returns: [s|"APITest1"]
            Yep, correct.

            Code:
            <?xml version="1.0" encoding="UTF-8"?><ping><service name="APITest1" status="up"/><service name[COLOR=#FF0000]="A[/COLOR]PIcheck1" [COLOR=#FF0000]status="down"[/COLOR]/></ping>
            
            zabbix_agentd -t 'web.page.regexp[localhost,test.xml,80,[COLOR=#FF0000]/"[/COLOR]APITest1[COLOR=#FF0000]"[/COLOR] status=[COLOR=#FF0000]"up"[/COLOR]\/>/]'
            Returns: web.page.regexp[localhost,test.xml,80,/"APITest1" status="up"\/>/] [s|]
            Highlighted in red, if you are trying to find exact string, specify exact string to find

            Also tested on my test setup:
            Code:
            [root@z34t]# zabbix_agentd -t 'web.page.regexp[www.apache.org,/foundation/how-it-works.html,80,[COLOR=#008000]themselves the "Apache Group"[/COLOR]]'
            
            web.page.regexp[www.apache.org,/foundation/how-it-works.html,80,themselves the "Apache Group"] [COLOR=#0000FF][s|themselves the "Apache Group"][/COLOR]
            
            [root@z34t]# zabbix_agentd -t 'web.page.regexp[www.apache.org,/foundation/how-it-works.html,80,[COLOR=#008000]themselves the "[/COLOR][COLOR=#FF0000]_[/COLOR][COLOR=#008000]Apache Group[/COLOR]"]'
            
            web.page.regexp[www.apache.org,/foundation/how-it-works.html,80,themselves the "_Apache Group"] [COLOR=#0000FF][s|][/COLOR]

            Comment

            • Semiadmin
              Senior Member
              • Oct 2014
              • 1625

              #9
              Hi, lpossamai

              Try a trigger like this one:

              {webserver.example.com:web.test.error[API_example.com,API - APIcheckTest1].regexp("required pattern")}=1 and {webserver.example.com:web.test.fail[API_example.com,API - APIcheckTest1].last()}>0

              Comment

              • lpossamai
                Senior Member
                • Jun 2018
                • 119

                #10
                Originally posted by kernbug
                Hi,

                Code:
                zabbix_agentd -t 'web.page.regexp[localhost,test.xml,80,[COLOR=#FF0000]\"APITest1\"[/COLOR]]' Returns: [s|"APITest1"]
                Yep, correct.

                Code:
                <?xml version="1.0" encoding="UTF-8"?><ping><service name="APITest1" status="up"/><service name[COLOR=#FF0000]="A[/COLOR]PIcheck1" [COLOR=#FF0000]status="down"[/COLOR]/></ping>
                
                zabbix_agentd -t 'web.page.regexp[localhost,test.xml,80,[COLOR=#FF0000]/"[/COLOR]APITest1[COLOR=#FF0000]"[/COLOR] status=[COLOR=#FF0000]"up"[/COLOR]\/>/]'
                Returns: web.page.regexp[localhost,test.xml,80,/"APITest1" status="up"\/>/] [s|]
                Highlighted in red, if you are trying to find exact string, specify exact string to find

                Also tested on my test setup:
                Code:
                [root@z34t]# zabbix_agentd -t 'web.page.regexp[www.apache.org,/foundation/how-it-works.html,80,[COLOR=#008000]themselves the "Apache Group"[/COLOR]]'
                
                web.page.regexp[www.apache.org,/foundation/how-it-works.html,80,themselves the "Apache Group"] [COLOR=#0000FF][s|themselves the "Apache Group"][/COLOR]
                
                [root@z34t]# zabbix_agentd -t 'web.page.regexp[www.apache.org,/foundation/how-it-works.html,80,[COLOR=#008000]themselves the "[/COLOR][COLOR=#FF0000]_[/COLOR][COLOR=#008000]Apache Group[/COLOR]"]'
                
                web.page.regexp[www.apache.org,/foundation/how-it-works.html,80,themselves the "_Apache Group"] [COLOR=#0000FF][s|][/COLOR]
                Hi,

                umm... so how can I know if it is the correct regexp? When it returns this?

                Code:
                [B][root@zabbix ~]# [/B]zabbix_agentd -t 'web.page.regexp[api.example.com,/Ping/1.1,443,\"APITest1\" status="up"]'
                web.page.regexp[api.example.com,/Ping/1.1,443,\"APITest1\" status="up"] [s|]
                If that is correct and the expression is
                Code:
                \"APITest1\" status="up"
                , then on my Web Monitoring scenario where should I put it? In the "Required string" field?

                Comment

                • lpossamai
                  Senior Member
                  • Jun 2018
                  • 119

                  #11
                  Originally posted by Semiadmin
                  Hi, lpossamai

                  Try a trigger like this one:

                  {webserver.example.com:web.test.error[API_example.com,API - APIcheckTest1].regexp("required pattern")}=1 and {webserver.example.com:web.test.fail[API_example.com,API - APIcheckTest1].last()}>0
                  Thanks but I first need to find out the correct regexp for it.

                  Comment

                  • Semiadmin
                    Senior Member
                    • Oct 2014
                    • 1625

                    #12
                    Originally posted by lpossamai

                    Thanks but I first need to find out the correct regexp for it.
                    regexp("required pattern") is your regexp, because there is this text in "Last error message of scenario ..." item if required string not found:
                    required pattern "APIcheckTest1" status="up" was not found on ....

                    Comment

                    • lpossamai
                      Senior Member
                      • Jun 2018
                      • 119

                      #13
                      okay.. got it...

                      The expression is:

                      Code:
                       [TABLE]
                      [TR]
                      [TD]\"APITest1\" status="up"[/TD]
                       		[/TR]
                      [/TABLE]
                      I changed my test.xml to status="down" and it is working. It is giving me an error that could not find the string.

                      Now I need to figure out the trigger.
                      Last edited by lpossamai; 29-06-2018, 00:15.

                      Comment

                      • lpossamai
                        Senior Member
                        • Jun 2018
                        • 119

                        #14
                        Originally posted by Semiadmin
                        Hi, lpossamai

                        Try a trigger like this one:

                        {webserver.example.com:web.test.error[API_example.com,API - APIcheckTest1].regexp("required pattern")}=1 and {webserver.example.com:web.test.fail[API_example.com,API - APIcheckTest1].last()}>0
                        Hi,

                        I managed to get the trigger working like this:
                        Code:
                        {webserver.example.com:web.test.error[Scenario].strlen()}>0 and {webserver.example.com:web.test.fail[Scenario].last()}>0
                        Reference: https://www.zabbix.com/documentation...nitoring/items

                        Thanks guys for the help!

                        Comment

                        • lpossamai
                          Senior Member
                          • Jun 2018
                          • 119

                          #15
                          Is there a way to get the Web Scenario Step name on the trigger?

                          I.e: Failed step {STEP.NAME} on host {HOST.NAME}

                          Assuming by https://www.zabbix.com/forum/zabbix-...rigger-message this feature has not been implemented yet? Does anyone have a workaround this?

                          Cheers!
                          Last edited by lpossamai; 29-06-2018, 09:24.

                          Comment

                          Working...