Zabbix 5.0

Get alerts from Zabbix 5.0 into Squadcast

Follow the steps below to configure a service so as to push related alert data from Zabbix 5.0 into Squadcast.

Squadcast will then process this information to create incidents for this service as per your preferences.

Using Zabbix 5.0 as an Alert Source

You can either choose to use existing service or create a new service

Now, click on the corresponding Alert Sources button.

Select Zabbix 5.0 from Alert Source drop down and copy the Webhook URL shown.

Create a Squadcast Webhook in Zabbix 5.0

  1. Login to your Zabbix 5.0 dashboard. From the sidebar, click on Media types present under the Administration section.
  1. Copy the contents of the below XML snippet and save it in a file with .xml extension.
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
    <version>5.0</version>
    
    <media_types>
        <media_type>
            <name>Squadcast</name>
            <type>WEBHOOK</type>
            <parameters>
                <parameter>
                    <name>eventid</name>
                    <value>{EVENT.ID}</value>
                </parameter>
                <parameter>
                    <name>eventname</name>
                    <value>{EVENT.NAME}</value>
                </parameter>
                <parameter>
                    <name>hostname</name>
                    <value>{HOST.NAME}</value>
                </parameter>
                <parameter>
                    <name>severity</name>
                    <value>{EVENT.NSEVERITY}</value>
                </parameter>
                <parameter>
                    <name>triggerid</name>
                    <value>{TRIGGER.ID}</value>
                </parameter>
                <parameter>
                    <name>eventack</name>
                    <value>{EVENT.ACK.STATUS}</value>
                </parameter>
                <parameter>
                    <name>eventupdate</name>
                    <value>{EVENT.UPDATE.STATUS}</value>
                </parameter>
                <parameter>
                    <name>eventvalue</name>
                    <value>{EVENT.VALUE}</value>
                </parameter>
                <parameter>
                    <name>eventdate</name>
                    <value>{EVENT.DATE}</value>
                </parameter>
                <parameter>
                    <name>event_tags</name>
                    <value>{EVENT.TAGS}</value>
                </parameter>
                <parameter>
                    <name>hostip</name>
                    <value>{HOST.IP}</value>
                </parameter>
                <parameter>
                    <name>eventtime</name>
                    <value>{EVENT.TIME}</value>
                </parameter>
                <parameter>
                    <name>triggerdesc</name>
                    <value>{TRIGGER.DESCRIPTION}</value>
                </parameter>
                <parameter>
                    <name>eventopdata</name>
                    <value>{EVENT.OPDATA}</value>
                </parameter>
                <parameter>
                    <name>zabbixurl</name>
                    <value>{$ZABBIX.URL}</value>
                </parameter>
                <parameter>
                    <name>squadcastwebhook</name>
                    <value>{ALERT.SENDTO}</value>
                </parameter>
                <!-- <parameter>
                    <name>HTTPProxy</name>
                    <value></value>
                </parameter> -->
            </parameters>
            <script>
            try {
    var params = JSON.parse(value),
        req = new CurlHttpRequest(),
        fields = {},
        resp = '';

    //this is for when you have a proxy at your end    
    if (params.HTTPProxy) {
        req.SetProxy(params.HTTPProxy)
    }

    // Validating params
    if (isNaN(parseInt(params.eventid)) || params.eventid &lt; 1) {
        throw 'incorrect value for variable &quot;eventid&quot;. The value must be a positive number.';
    }
    if (params.eventname.length &lt; 1) {
        throw 'incorrect value for variable &quot;eventname&quot;. The value must be a non-empty string.';
    }
    if (params.hostname.length &lt; 1) {
        throw 'incorrect value for variable &quot;hostname&quot;. The value must be a non-empty string.';
    }
    if (isNaN(parseInt(params.severity)) || (params.severity &lt; 0 &amp;&amp; params.severity &gt; 5)) {
        throw 'incorrect value for variable &quot;severity&quot;. The value must be a number 0..5.';
    }
    if (isNaN(parseInt(params.triggerid)) || params.triggerid &lt; 1) {
        throw 'incorrect value for variable &quot;triggerid&quot;. The value must be a positive number.';
    }
    if (params.eventack != 'Yes' &amp;&amp; params.eventack != 'No') {
        throw 'incorrect value for variable &quot;eventack&quot;. The value must be Yes or No.';
    }
    if (isNaN(parseInt(params.eventupdate)) || (params.eventupdate &lt; 0 || params.eventupdate &gt; 1)) {
        throw 'incorrect value for variable &quot;eventupdate&quot;. The value must be 0 or 1.';
    }
    if (isNaN(parseInt(params.eventvalue)) || (params.eventvalue &lt; 0 || params.eventvalue &gt; 1)) {
        throw 'incorrect value for variable &quot;eventvalue&quot;. The value must be 0 or 1.';
    }
    if (params.squadcastwebhook.length &lt; 1) {
        throw 'incorrent value for variable &quot;squadcastwebhook&quot;. The value must be a non-empty string.';
    }

    var severityMapping = [
        'Not classified',
        'Information',
        'Warning',
        'Average',
        'High',
        'Disaster'
    ];

    req.AddHeader('Content-Type: application/json');

    fields.event_id = params.eventid;
    fields.event_nseverity = severityMapping[params.severity];
    fields.event_name = params.eventname;
    fields.trigger_description = params.triggerdesc;
    fields.event_opdata = params.eventopdata;
    fields.event_date = params.eventdate;
    fields.event_time = params.eventtime;
    fields.event_tags = params.eventtags;
    fields.host_ip = params.hostip;
    fields.host_name = params.hostname;
    fields.event_url = params.zabbixurl + '/tr_events.php?triggerid=' + params.triggerid + ' &amp;eventid=' + params.eventid;

    // if event is a "trigger" event
    if ((params.eventvalue == 1) &amp;&amp; (params.eventupdate == 0))
        fields.event_action = 'trigger';
    // if event is "acknowledge" event
    else if ((params.eventvalue == 1) &amp;&amp; (params.eventupdate == 1) &amp;&amp; (params.eventack == 'Yes'))
        return 'OK';
    // if event is "resolve" event
    else if (params.eventvalue == 0)
        fields.event_action = 'resolve';
    else
        throw 'incorrect values. Update message without ack will not be sent.';

    Zabbix.Log(4, '[Squadcast Webhook] Sending request:' + JSON.stringify(fields));
    Zabbix.Log(4, '[Squadcast Webhook] Webhook URL:' + params.squadcastwebhook);
    resp = req.Post(params.squadcastwebhook, JSON.stringify(fields));
    Zabbix.Log(4, '[Squadcast Webhook] Receiving response:' + resp);

    try {
        resp = JSON.parse(resp);
    } catch (error) {
        throw 'incorrect response. Squadcast returned a non-JSON object.';
    }
    if (req.Status() > 299) {
        throw resp;
    }

    return 'OK';
} catch (error) {
    Zabbix.Log(3, '[Squadcast Webhook] Notification failed : ' + error);
    throw 'Squadcast notification failed : ' + error;
}
            </script>
        </media_type>
    </media_types>
</zabbix_export>

πŸ“˜

Note:

If you use a proxy at your end:

  • Uncomment lines 74 through 77 and add your proxy URL inside the value tag and you are good to go.
  1. Click on Import button in the top right corner.
  1. Choose the saved .xml file from your device and click on Import.
  1. Verify if Squadcast Media Type was added successfully. Click on Media Types > Search for Squadcast > click on the result.

You should be able to view the Parameters and Script, similar to the screenshots below.

πŸ“˜

Note:

HTTPProxy parameter and value will be listed here if you uncommented the same in the script previously.

Click on Script to view that our script has been added.

  1. Now you can add this media type to any user you want. Click on the Users tab under the Administration section from the sidebar.
  1. Click on the User you want to add this Squadcast media type to.
  1. Go to the "Media" tab, click on "Add" and enter the following details:

Type: Squadcast
Send To: The Webhook URL you obtained from Squadcast dashboard.

  1. Finally click on "Add" to save the media for the user and make sure you click on "Update" button on the "Media" page to save the details.
  1. Now go to the "Actions" tab in the "Configurations" section in the sidebar.
  1. Click on "Create Action" at the top right corner to create a new action.
    Enter the name as "Squadcast Notifications".
  1. Click on "Operations" tab and configure it as per your requirements.

That's it! Your Zabbix 5.0 integration is now good to go.

Zabbix 5.0 supports auto-resolve . Whenever an issue in Zabbix 5.0 is resolved, it gets auto-resolved in Squadcast as well.

Updated 8 days ago


Zabbix 5.0


Get alerts from Zabbix 5.0 into Squadcast

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.