Ad Widget

Collapse

Zix 4 - Using Macros with Scripts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ssalter
    Junior Member
    • Mar 2019
    • 3

    #1

    Zix 4 - Using Macros with Scripts

    I am having an issue passing Macro values to an external script and would greatly appreciate any insight that could be provided.

    Config is as follows:
    Template Item that measures memory % free
    Trigger that created a HIGH alarm when free memory is less than 10%
    Defined script that runs a PHP file to create a ticket in an ITSM system

    Script configuration is as follows:
    /usr/lib/zabbix/alertscripts/newticket.php "{HOST.NAME}" "{EVENT.NAME}" "{EVENT.ID}" "3"

    File that is run by the script accepts variables as such
    newticket.php <host> <title1> <eventid> <severity>
    Where HOST maps to HOST.NAME, TITLE1 maps to EVENT.NAME, etc

    Action defined to run the PHP script whenever a HIGH ticket is encountered

    For some reason, only the HOST.NAME is passed to the php script by Zabbix, the other Marcos are passed as "EVENT.ID" instead of the actual Event ID numeric value

    The PHP script runs on the xabbix host to communicate with an ITSM API for ticket creation. Manually running the script from the Zabbix command line where I manually input the values is fine. Letting the script auto fire based on the trigger or manually firing it from the Zabbix dashboard results in only the HOST.NAME macro value being passed to the script as stated above.
  • brunohl
    Senior Member
    Zabbix Certified Specialist
    • Mar 2019
    • 215

    #2
    Can you upload a screenshot of how it is configured in "Media Types" and in "Actions"?

    Comment

    • ssalter
      Junior Member
      • Mar 2019
      • 3

      #3
      Attachments have been uploaded.

      Interestingly when I look at the dashboard and click the host that is in alarm, I can manually execute "create_itop_ticket" script and it will resolve the Host Name from the Macro, but not the Event Name or the Event ID (I have been playing around with which of the parameters I want to use and have settled on these.
      Attached Files

      Comment

      • ssalter
        Junior Member
        • Mar 2019
        • 3

        #4
        Fixed a problem with the media type where I had the same parameter twice but it didn't resolve the overall issue. Updated screenshot attached.
        Attached Files

        Comment

        • brunohl
          Senior Member
          Zabbix Certified Specialist
          • Mar 2019
          • 215

          #5
          The thing is that I don't know if you have these variables in Media Types, I guess that maybe they're only available at your action. So If I were you I would do the following:

          Media types
          - Change your media types parameters to:
          {HOST.NAME}
          {HOST.SUBJECT}
          {ALERT.MESSAGE}
          3
          Click image for larger version

Name:	Screenshot_38.png
Views:	1477
Size:	24.6 KB
ID:	375770

          In your action configuration I would invoke your scripts as a Message (and use those variables on subject and message):
          Click image for larger version

Name:	Screenshot_39.png
Views:	1435
Size:	33.3 KB
ID:	375771

          I guess that this will work. Of course, you have to configure this media type to this user.

          Comment

          Working...