Ad Widget

Collapse

Twilio SMS alerts - Detailed Alert information

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kpax
    Member
    • Dec 2013
    • 52

    #1

    Twilio SMS alerts - Detailed Alert information

    Hello,

    we are using Zabbix version 4.2 combine with Twilio SMS alerts external scripts.
    All works fine according to the severity level.

    I would like to know if there is a possible way to receive detailed Alert information and not just generalize text. (e.g. there is a problem please check Zabbix dashboard)

    Thanks, heaps.


    in Zabbix (Action):

    cd /usr/lib/zabbix/alertscripts/
    php critical-sms.php


    in ExternalScript (folder):

    Code:
    <?php
        /* Send an SMS using Twilio. You can run this file 3 different ways:
         *
         * 1. Save it as sendnotifications.php and at the command line, run
         *         php sendnotifications.php
         *
         * 2. Upload it to a web host and load mywebhost.com/sendnotifications.php
         *    in a web browser.
         *
         * 3. Download a local server like WAMP, MAMP or XAMPP. Point the web root
         *    directory to the folder containing this file, and load
         *    localhost:8888/sendnotifications.php in a web browser.
         */
    
        // Step 1: Get the Twilio-PHP library from twilio.com/docs/libraries/php,
        // following the instructions to install it with Composer.
        require_once "vendor/autoload.php";
        use Twilio\Rest\Client;
    
        // Step 2: set our AccountSid and AuthToken from https://twilio.com/console
        $AccountSid = "xxxx";
        $AuthToken = "xxxx";
    
        // Step 3: instantiate a new Twilio Rest Client
        $client = new Client($AccountSid, $AuthToken);
    
        // Step 4: make an array of people we know, to send them a message.
        // Feel free to change/add your own phone number and name here.
        $people = array(
    
    //      "+1234" => "James",
    //      "+1234" => "James",
            "+1234" => "James",
            "+1234" => "James",
            "+1234" => "James",
            "+1234" => "James",
        );
    
        $now = time();
        $now = date('r', $now);
    
        // Step 5: Loop over all our friends. $number is a phone number above, and
        // $name is the name next to it
        foreach ($people as $number => $name) {
    
            $sms = $client->account->messages->create(
    
                // the number we are sending to - Any phone number
                $number,
    
                array(
                    // Step 6: Change the 'From' number below to be a valid Twilio number
                    // that you've purchased
                    'from' => "+xxxxxxx",
    
                    // the sms body
                    'body' => "PROBLEM. Hi $name,\nthere is Zabbix alert with severity of:\nCritical ; High.\ncheck Zabbix dashboard or mailbox. event was occurred on $now"
                )
            );
    
            // Display a confirmation message on the screen
            echo "Sent message to $name";
        }
Working...