Ad Widget

Collapse

Sending An Alert Via Curl

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • msantangelo
    Junior Member
    • Feb 2015
    • 19

    #1

    Sending An Alert Via Curl

    Hello everyone.

    I'm looking for suggestions about how best to send an alert via a curl command. For reference, I'm using curl to send a notification to a Cachet server.

    I thought I had it right with just a command, but I'm not sure.

    I save the Cachet Item ID as a Host Inventory Item (Serial number A, which I think is referenced by {HOST.SERIALNO.A1} ( https://www.zabbix.com/documentation...ed_by_location ). I have this set as the Default Subject and Recovery Subject. The Default Message is 4, and the Recovery Message is 1.

    Meanwhile, I've placed a script in /usr/lib/zabbix/alertscripts called notifyZabbix. The contents are:


    Code:
    #!/bin/bash
    
    to=$1
    compID=$2
    statusID=$3
    
    # Comment this next line out for Production
    #echo "curl -H 'Content-Type: application/json' -H 'X-Cachet-Token: anapitoken' http://theip/api/components/$compID -d '{"status":$statusID}' -X PUT"
    
    # Uncomment this next line for Production
    curl -H 'Content-Type: application/json' -H 'X-Cachet-Token: anapitoken' http://theip/api/components/"$compID" -d "{'status':$statusID}" -X PUT
    I went Admin -> Media Types and created a Media called Zabbix_Notify with a type of Script and the Script name of notifyZabbix (set to enabled).

    I gave a user the media of Zabbix_Notify.

    The action logs show Zabbix_Issue executed with subject and message as expected, but the Cachet server doesn't seem to be updating. I'm wondering if Zabbix is properly executing the script, but I'm not sure how to check.

    Any thoughts?
  • msantangelo
    Junior Member
    • Feb 2015
    • 19

    #2
    Figured it out.

    I defined a macro per host called $CACHET, with a value of the id in Cachet. I updated the Default subject and Recovery subject to be set to this macro {$CACHET}. The rest of it just worked.

    Stoked.

    Comment

    • tessa008
      Junior Member
      • Feb 2017
      • 4

      #3
      Cachet side

      Hi,

      Can you help me a little? What to do on Cachet side to receive the feed from Zabbix?

      I followed the same steps but there is no tutorial how to get Cachet to display it

      Comment

      Working...