Ad Widget

Collapse

Alert scrip doesn't work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sjs
    Junior Member
    • Sep 2016
    • 3

    #1

    Alert scrip doesn't work

    Hello,

    I have server with Ubuntu 14.04 LTS and zabbix-server-mysql 3.0.4
    I try to add the functionality to send SMS. I use script from smseagle.

    Code:
    #!/usr/bin/php
    <?php
    /*******************************************
     * cli_smseagle.php
     *
     * Script to send an SMS via
     * SMSEagle - sms hardware gateway
     *
     * Version : 1.1
     * Date : Nov 23 2015
     * Author : Radoslaw Janowski / WWW.SMSEAGLE.EU
     * License: BSD
     * Copyright (c) 2013-2015, SMSEagle www.smseagle.eu
     * 
     *****************************************/
     
    //Set the following values:
    $smseagle_ip     = "192.168.0.102";
    $login     = "smseagleuser";
    $password  = "smseaglepassword";
    $timezone  = "Europe/Warsaw"; 
    //available timezones can be found here: http://www.php.net/manual/en/timezones.php
    
     
    // Debugging?
    $debug    = false;
     
    /**********************************************************************
      do not change below unless you know what you are doing
     **********************************************************************/
    date_default_timezone_set($timezone);
     
    if (count($argv)<3) {
        die ("Usage: ".$argv[0]." recipientmobilenumber \"subject\" \"message\"\n");
    }
     
    if ( $debug ) file_put_contents("/tmp/smseagle_".date("YmdHis"), serialize($argv));
     
    $to         = $argv[1];
    $message    = $argv[2];
     
    if ( $message == "" || !is_numeric($to) ) {
        die("missing params!\n");
    }
     
    $apiargs = array(
        "login" => $login,
    	"pass" => $password,
        "to" => $to,
        "message" => $message
    );
     
     
    $url = "http://".$smseagle_ip."/index.php/http_api/send_sms?";
    $params = "";
     
    foreach ($apiargs as $k=>$v) {
        if ( $params != "" ) {
            $params .= "&";
        }
        $params .= $k."=".urlencode($v);
    }
     
    $url .= $params;
     
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url );
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($curl);
     
    if ( $result === false ) {
        file_put_contents("/tmp/smseagle_error_".date("YmdHis"), curl_error($curl));
        die(curl_error($curl)."\n");
    } else {
        if ( $debug || $result != 100 ) file_put_contents("/tmp/smseagle_answer_".date("YmdHis"), $result);
    }
     
    ?>
    Script work properly from console.
    I added script to zabbix
    - Administration>Media types>add script
    - Administration>Users>add new media.
    - Configuration>Actions>add operations

    Zabbix dashboard show that alert send, but nothing on smsgateway.
    I capture traffic and doesn't see any packet to smsgateway.

    Zabbix log with 5lvl debug doesn't help.

    Dear colleagues, would you kindly help with this issue.

    Thank you in advance.
  • sjs
    Junior Member
    • Sep 2016
    • 3

    #2
    any update? Can some one help?

    Comment

    • sjs
      Junior Member
      • Sep 2016
      • 3

      #3
      solved

      Ok, I got it.
      I updated zabbix from 2.4 to 3.0
      In zabbix 3.0 need to set macros. After I add this info. All work.

      BR

      Comment

      • Frederico
        Junior Member
        • Jun 2010
        • 9

        #4
        Same issue

        what Macro you need set ?

        Att ,

        Comment

        • Atsushi
          Senior Member
          • Aug 2013
          • 2028

          #5
          Hi Frederico,
          I think that it was probably that {ALERT.SENDTO}, {ALERT.SUBJECT} and {ALERT.MESSAGE} were added.

          Please read manual.

          Comment

          Working...