Ad Widget

Collapse

Custom alertscript doesn't work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmrkvicka9191
    Junior Member
    • May 2022
    • 2

    #1

    Custom alertscript doesn't work

    Hi folks, I would like to set sending webhooks by python script, but I have one problem with this. I am trying according this manual https://www.zabbix.com/documentation...s/media/script . The script is executing but it doesn't send values which I want. This is my script

    Code:
    #!/usr/bin/python
    import sys
    import requests
    hostname = sys.argv[1]
    eventname = sys.argv[2]
    severity = sys.argv[3]
    payload = '{{"text": "{0},{1},{2}"}}'.format(hostname,eventname,severity)
    headers = {'Content-type': 'application/json'}
    endpoint = "https://example.com/asdf"
    requests.post(endpoint, headers=headers, data=payload, verify=False)
    In zabbix settings I have added these parmeters:
    {HOST.NAME}
    {EVENT.NAME}
    {EVENT.SEVERITY}

    Notificiation which has been sent from zabbix doesn't contain values ony parameter names. Notificiation looks like this:
    {HOST.NAME},{EVENT.NAME},{EVENT.SEVERITY}

    Could someone help me, where is the problem? Thank you in advance.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    So your media type is "Script"?
    Alert scripts take 3 macros... besides hardcoded values...
    Script name Enter the name of the script.
    Script parameters Add command-line parameters to the script.
    {ALERT.SENDTO}, {ALERT.SUBJECT} and {ALERT.MESSAGE} macros are supported in script parameters.
    Customizing script parameters is supported since Zabbix 3.0.
    {ALERT.MESSAGE} → Alert script parameters 'Default message' value from action configuration.
    Supported since 3.0.0.
    {ALERT.SENDTO} → Alert script parameters 'Send to' value from user media configuration.
    Supported since 3.0.0.
    {ALERT.SUBJECT} → Alert script parameters 'Default subject' value from action configuration.
    So compose your Alert message, which contains all the "content" you need and then use ALERT.* macros to forward them to script...

    Comment

    Working...