Ad Widget

Collapse

One action for multiple web scenario

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jusavard
    Member
    • Sep 2013
    • 48

    #1

    One action for multiple web scenario

    Hi,
    Let's suppose I have 3 hosts :
    For each host I have created a Web Scenario. Each web scenario have the same name "General Web Tests". This scenario only have 1 step which is to get the homepage of the "host" and expect to get a 200 response code. Pretty simple for now.
    From there, FOR EACH HOST, I have create a trigger that verify if the "General Web Tests" have any error.
    Which mean :
    First question : Is it possible to have ONE general trigger for each host ?
    Something like :

    Code:
    [INDENT]{{HOST.NAME}:web.test.fail[General Web Tests].[B]last([/B][B])[/B]}<>0[/INDENT]
    Second question : Is it possible to have ONE action that send an email if any web scenario failed which INCLUDE the last HTML error and the download speed of the last request ?
    Something like :

    Code:
    [INDENT]Subject :
    Problem : {TRIGGER.STATUS} {HOST.NAME1} - {TRIGGER.NAME}
    Message :
    Problem started at {EVENT.TIME} on {EVENT.DATE}
    Problem name: {TRIGGER.NAME}
    Host: {HOST.NAME}
    Severity: {TRIGGER.SEVERITY}
    
    Original problem ID: {EVENT.ID}
    {TRIGGER.URL}
    
    Additionnal info :
    
    Last HTML error : {{HOST.NAME}:web.test.fail[General Web Tests].last(0)}
    Downlaod speed of the last HTML request : {{HOST.NAME}:web.test.in[General Web Tests,,bps].last(0)}[/INDENT]
    My goal here is not to have to create 1 custom action for each host which would look like :

    Code:
    [INDENT]#1
    Last HTML error : {www.host1.com:web.test.fail[General Web Tests].last(0)}
    Downlaod speed of the last HTML request : {www.host1.com:web.test.in[General Web Tests,,bps].last(0)}
    #2
    Last HTML error : {www.host2.com:web.test.fail[General Web Tests].last(0)}
    Downlaod speed of the last HTML request : {www.host2.com:web.test.in[General Web Tests,,bps].last(0)}
    #3
    Last HTML error : {www.host3.com:web.test.fail[General Web Tests].last(0)}
    Downlaod speed of the last HTML request : {www.host3.com:web.test.in[General Web Tests,,bps].last(0)}[/INDENT]
  • kernbug
    Senior Member
    • Feb 2013
    • 330

    #2
    Hello

    Looks like you need a template for this checks with web scenario:



    For actions - define one host group, add this hosts and make one alert action:

    Comment

    • jusavard
      Member
      • Sep 2013
      • 48

      #3
      Hi kernbug,
      That's what I usually do when monitoring hosts for cpu/ram/services/(Whatever the zabbix agent can provides). However the web test part of zabbix is... let's just say different. I first though it wouldn't be possible to have a template for web monitoring but then I read about macros. For the record, I'll explain how I made my own Web Test Template :
      1. Configuration --> Template --> Create Template ( Upper right corner )
      2. Add Template Name ( for instance : Template Web tests )
      3. OPTIONNAL = New group : Templates/Web
      4. Click on "Macro" tab and on "Template Macro"
      5. Enter Macro {$HOME_URL}
      6. Enter Value "http://www.foo.bar" ( You can write anything here but don't write your real URL here )
      7. Clic Add and Update
      8. Return to Configuration --> Template
      9. See if you template is in the list
      10. If it is, click on its "Web" link
      11. Clic on "Create web scenario" (Upper right corner )
      12. Add Name ( for instance : Common tests )
      13. OPTIONNAL : Change Attempts Value to "2" instead of "1"
      14. OPTIONNAL : If you Zabbix server must use a HTTP Proxy enter you values in "HTTP Proxy"
      15. Click on "Steps"
      16. Click on "Add"
      17. Configure your step here. In my case I just wanted to test if the home page of every sites returned a 200 HTML code. Here is what I made :
        1. Enter Name ( For instance : Query Homepage )
        2. DO NOT ENTER YOU URL HERE. Write the macro I made you create earlier ( {$HOME_URL} )
        3. Enter Required Status codes = 200
        4. Click Update ( The window show close )
      18. Double check your settings in "Scenario" and "Step". If everything's fine click "Add"
      19. Alost done... For every host youo want to monitor follow these steps
        1. Click on Configuration --> Hosts
        2. Click on the name of the host you want to monitor ( for instance host1 )
        3. Click on Macros ( should be between IPMI and Host inventory as of Zabbix v3.4.9)
        4. Edit Macro = {$HOME_URL}
        5. Edit Macro = You real URL here ( for instance https://www.host1.com )
        6. Click Add
        7. Click on Template ( 2 links on left where your clicked on Macros )
        8. Link new templates = The name of you template here ( in my case "Template Web tests" )
        9. Click Add
        10. And finaly, click "Update"


      Even if it's great to now have a template for web monitoring, I still have the "trigger/action" problem. I don't see any macro I can use not to have to create a action for every host. Like I said, it would be great to use a macro within a macro like this :

      Code:
      {{HOST.NAME}:web.test.fail[General Web Tests].last(0)}

      Comment

      • jusavard
        Member
        • Sep 2013
        • 48

        #4
        Hey finaly I found a way : https://www.zabbix.com/forum/zabbix-...item-key/page2

        So my message in action looks like this :

        Code:
        Problem started at {EVENT.TIME} on {EVENT.DATE}
        Problem name: {TRIGGER.NAME}
        Host: {HOST.NAME}
        Severity: {TRIGGER.SEVERITY}
        
        Original problem ID: {EVENT.ID}
        {TRIGGER.URL}
        
        Additionnal info :
        
        Last HTML error : {{HOST.HOST}:web.test.fail[Standard tests].last(0)}
        Downlaod speed of the last HTML request : {{HOST.HOST}:web.test.in[Standard tests,,bps].last(0)}
        Please node the {HOST.HOST} instead of the {HOST.NAME}.

        Comment

        • Glide
          Junior Member
          • Jan 2021
          • 10

          #5
          Very interesting, I was searching exactly that.
          The macro trick is what I was missing.
          I was trying to use inventory variables but they can't be used by web scenarios.

          Comment

          Working...