Ad Widget

Collapse

Reach Different Asterisk Servers on the Same Asterisk by HTTP Template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Idan
    Junior Member
    • Nov 2023
    • 4

    #1

    Reach Different Asterisk Servers on the Same Asterisk by HTTP Template

    Hi Zabbix community,

    my Zabbix server version: 6.0.21.

    I have different Asterisk 11 servers (different IP addresses) which I wanna register under the same Asterisk template - Asterisk by HTTP Template.

    In the Macros of the template,
    there is a Macro named {$AMI.URL} which should contain the IP address + endpoint to your Asterisk HTTP server, should look like this: http://123.123.123.123:123/rawman

    Now, my question is,
    how can I have the IP address of the server dynamically instead of hard-coding it like this - http://123.123.123.123:123/rawman?

    I tried to put in the value of the {$AMI.URL} Macro the URL this way: http://{HOST.IP}:123/rawman
    but it seems that it's not possible to use another Macro as the value of another Macro.

    Any idea how to have the URL dynamically - to have the same Asterisk Template assigned to different Asterisk servers.

    Thanks in advance,

    Idan
  • solution
    Senior Member
    • Jun 2020
    • 269

    #2
    To use any template with macro on multiple hosts, never define the macros in the template.
    Define macros on the host.​
    ​​

    If you don't want to copy the macros from the template, you click on "Inherited and host macros" and click on change:
    Click image for larger version

Name:	image.png
Views:	176
Size:	26.3 KB
ID:	474466



    Wellington

    Comment

    • Idan
      Junior Member
      • Nov 2023
      • 4

      #3
      Thanks for the response.

      I know I can set host macro for each one of them but the thing is,
      I have a lot of Asterisk servers and I need to find a way to set the {$AMI.URL} automatically with the HOST.IP.

      Any idea?

      Comment

      • solution
        Senior Member
        • Jun 2020
        • 269

        #4
        hmmm, use macro in the value field.
        I don't think it's accepted.
        In the case of this "Asterisk by HTTP" template, try the following:
        From:
        Items --> Asterisk: Get stats --> URL: {$AMI.URL}

        To:
        Items --> Asterisk: Get stats --> URL: http://{HOST.CONN}:8088/asterisk/rawman​

        Click image for larger version

Name:	image.png
Views:	223
Size:	18.8 KB
ID:	474475

        and apply to hosts.

        I don't have asterisk to test.
        Does it work as expected?​

        Wellington

        Comment

        • Idan
          Junior Member
          • Nov 2023
          • 4

          #5
          Ok so first,
          I found out that if you set the URL this way in the the HTTP Agent

          http://{HOST.IP}:8866/rawman

          it's reading the host IP properly.

          It's also reading the host IP properly in the way you mentioned - http://{HOST.CONN}:8866/rawman.

          Click image for larger version

Name:	zbx1.png
Views:	204
Size:	76.1 KB
ID:	474480

          However, I see that the issue now is with the preprocessing JavaScript -
          need to set the url to be dynamically the host IP,
          but it turns out that it's not possible to use built-in Macros in preprocessing scripts.

          The url is set this way by default in the preprocessing script:

          url: '{$AMI.URL}'

          So need to find a way to set the url like this:

          url: 'http://{HOST.IP}:8866/rawman' - which isn't working there unfortunately..

          Click image for larger version

Name:	zbx2.png
Views:	198
Size:	114.1 KB
ID:	474481

          Any idea?

          Comment

          • solution
            Senior Member
            • Jun 2020
            • 269

            #6
            Sorry, no new ideas.
            As there are only 11 servers, configure the AMI.URL macro with the address on each host.

            Any Senior User or with more advanced knowledge with more
            any tips?

            Wellington​

            Comment

            • Idan
              Junior Member
              • Nov 2023
              • 4

              #7
              I have about 350 Asterisk servers,
              I meant that the Asterisk version is 11

              Thanks a lot for your help.

              If anyone have any other ideas, I would love to know.

              Thanks

              Comment

              Working...