Ad Widget

Collapse

How to get supported macros to bash variables

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • xtj
    Junior Member
    • Apr 2024
    • 5

    #1

    How to get supported macros to bash variables

    It is possible to get supported macros from

    put in variable bash script and send in json body?
    Something like thath:

    Code:
    #!/bin/bash
    
    url="my_endpoint"
    alert_subject="Severity:{EVENT.SEVERITY} Problem on:{HOST.HOST} - {EVENT.NAME}"
    alert_message="There is a problem on {HOST.HOST} - {EVENT.NAME} with severity: {EVENT.SEVERITY} since {EVENT.DATE}"
    
    bearertoken="my_token"
    
    json_data='{
    my_json_body
    }'
    
    response=$(curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $bearertoken" -d "$json_data" -k "$url")
    echo "$response"
  • Answer selected by tim.mooney at 01-05-2024, 21:46.
    markfree
    Senior Member
    • Apr 2019
    • 868

    Yes, it is possible.
    You could call your script and pass Zabbix macros as positional arguments:
    Code:
    /path/to/script.sh "{MACRO1}" "{MACRO2}" (...) "{MACRO11}" "{MACRO12}" etc
    Then, within your script, you can parse these parameters
    with new variables.
    Code:
    MACRO1=$1
    MACRO2=$2
    (...)
    MACRO11=${11}
    MACRO12=${12}
    
    (rest of the script)
    Last edited by markfree; 27-04-2024, 03:29.

    Comment

    • markfree
      Senior Member
      • Apr 2019
      • 868

      #2
      Yes, it is possible.
      You could call your script and pass Zabbix macros as positional arguments:
      Code:
      /path/to/script.sh "{MACRO1}" "{MACRO2}" (...) "{MACRO11}" "{MACRO12}" etc
      Then, within your script, you can parse these parameters
      with new variables.
      Code:
      MACRO1=$1
      MACRO2=$2
      (...)
      MACRO11=${11}
      MACRO12=${12}
      
      (rest of the script)
      Last edited by markfree; 27-04-2024, 03:29.

      Comment

      • xtj
        Junior Member
        • Apr 2024
        • 5

        #3
        markfree Thank You very much, Your advice resolve my problem. Now every think works fine; data of events are thru to ticket system
        Last edited by xtj; 29-04-2024, 10:16.

        Comment

        Working...