Ad Widget

Collapse

Problem with manual event action usin bash script with json body

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xtj
    Junior Member
    • Apr 2024
    • 5

    #1

    Problem with manual event action usin bash script with json body

    Hello to everyone from community ZABBIX.
    Zabbix 6.0 LTS
    It is possible to create manual event action with bash script sending json body to api endpoint ?

    My scenario:

    I create in administration->scripts->manual evet script

    path on svr : /usr/lib/zabbix/alertscripts/my_script.sh

    I set on srcipt 755 permission
    Code:
    #!/bin/bash
    
    url="https:my_endpoint/api/my_example/Issues"
    
    bearertoken="my_token"
    
    json_data='{
    "IssueTypeId":"exaple",
    "AttributeValueList":[
    {
    "example":"3",
    }
    ]
    }'
    
    response=$(curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $bearertoken" -d "$json_data" "$url")
    
    echo "$response"
    but I get response timeout

    Cannot execute script.

    Connection timeout of 60 seconds exceeded when connecting to Zabbix server "localhost".

    Can I plese some sugesstion, advice what is wrong or is it possible to get this scenario in this steps.

    In simillar task

    WebScenario POST json data - ZABBIX Forums

    probably everything works fine but I do not know anything more about place or detail his scenario [what he want to get], from where useer send file with json body and witch language he is using to create script if he create them.

    Please for help.​
  • xtj
    Junior Member
    • Apr 2024
    • 5

    #2
    Ok, I resolve task, issue was by my side; I do not opened the traffic from zabbix to my ticket system service. Now I think about how to put information from event to json body [use the macros ?] of the script. I will still wait for advice or ideas. Every sugesstion is counting.

    Comment

    Working...