Hello,
i use TM4B server (http://www.tm4b.com/) to send SMS alerts from zabbix.
To do that i used this script to create my own script with TM4B : https://www.zabbix.com/wiki/howto/config/alerts/smsapi
How to do that :
1) modify this script :
#!/usr/bin/php
<?php
$to = $argv[1];
$subject = $argv[2];
$message = $argv[3];
$request = ""; //initialise the request variable
$param["type"] = "broadcast";
$param["username"] = "yourusername"; //this is the username of our TM4B account
$param["password"] = "yourpassword"; //this is the password of our TM4B account
$param["msg"] = $message; //this is the message that we want to send
$param["to"] = $to; //these are the recipients of the message
$param["from"] = "zabbix";//this is our sender, you can also put $subject
foreach($param as $key=>$val) //traverse through each member of the param array
{
$request.= $key."=".urlencode($val); //we have to urlencode the values
$request.= "&"; //append the ampersand (&) sign after each paramter/value pair
}
$request = substr($request, 0, strlen($request)-1); //remove the final ampersand (&) sign from the request
/*
This will produce the following request:
username=abcdef&password=12345&msg=This+is+sample+ message.&to=447768254545%7C447956219273%7C44777151 4662&from=MyCompany&route=frst&sim=yes
*/
$url = "http://www.tm4b.com/client/api/http.php"; //although we have used https, you can also use http
$ch = curl_init(); //initialize curl handle
curl_setopt($ch, CURLOPT_URL, $url); //set the url
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); //return as a variable
curl_setopt($ch, CURLOPT_POST, 1); //set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, $request); //set the POST variables
$response = curl_exec($ch); //run the whole process and return the response
curl_close($ch); //close the curl handle
//print $response; //show the result onscreen for debugging
print $response;
?>
2)save the script as zabbixsms.php for example and install curl on the zabbix server
3)edit zabbix_server.conf (for me in /etc/zabbix/zabbix_server.conf) and look for path of AlertScriptsPath. (for me /usr/lib/zabbix/alertscripts)
4)copy zabbixsms.php in AlertScriptsPath (/usr/lib/zabbix/alertscripts/) and chmod 755 zabbixsms.php
5)test the script : ./zabbixsms.php +4471234123123 "Test subject" "Test message". You should receive the SMS
6)in Zabbix goto Administration, Media Types, add a new media called zabbixsms (your choice) and choose that it's a script, and enter the filename you specified (here: zabbixsms.php) as the script name.
7)Finally, in Zabbix, Administration, Users, click on a user, and add a new media called zabbixsms.php (or whatelse you specified). Enter their phone number like +44623023325, and press save
8) look for configuration, action to sens alert to the user
it is finish !
i use TM4B server (http://www.tm4b.com/) to send SMS alerts from zabbix.
To do that i used this script to create my own script with TM4B : https://www.zabbix.com/wiki/howto/config/alerts/smsapi
How to do that :
1) modify this script :
#!/usr/bin/php
<?php
$to = $argv[1];
$subject = $argv[2];
$message = $argv[3];
$request = ""; //initialise the request variable
$param["type"] = "broadcast";
$param["username"] = "yourusername"; //this is the username of our TM4B account
$param["password"] = "yourpassword"; //this is the password of our TM4B account
$param["msg"] = $message; //this is the message that we want to send
$param["to"] = $to; //these are the recipients of the message
$param["from"] = "zabbix";//this is our sender, you can also put $subject
foreach($param as $key=>$val) //traverse through each member of the param array
{
$request.= $key."=".urlencode($val); //we have to urlencode the values
$request.= "&"; //append the ampersand (&) sign after each paramter/value pair
}
$request = substr($request, 0, strlen($request)-1); //remove the final ampersand (&) sign from the request
/*
This will produce the following request:
username=abcdef&password=12345&msg=This+is+sample+ message.&to=447768254545%7C447956219273%7C44777151 4662&from=MyCompany&route=frst&sim=yes
*/
$url = "http://www.tm4b.com/client/api/http.php"; //although we have used https, you can also use http
$ch = curl_init(); //initialize curl handle
curl_setopt($ch, CURLOPT_URL, $url); //set the url
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); //return as a variable
curl_setopt($ch, CURLOPT_POST, 1); //set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, $request); //set the POST variables
$response = curl_exec($ch); //run the whole process and return the response
curl_close($ch); //close the curl handle
//print $response; //show the result onscreen for debugging
print $response;
?>
2)save the script as zabbixsms.php for example and install curl on the zabbix server
3)edit zabbix_server.conf (for me in /etc/zabbix/zabbix_server.conf) and look for path of AlertScriptsPath. (for me /usr/lib/zabbix/alertscripts)
4)copy zabbixsms.php in AlertScriptsPath (/usr/lib/zabbix/alertscripts/) and chmod 755 zabbixsms.php
5)test the script : ./zabbixsms.php +4471234123123 "Test subject" "Test message". You should receive the SMS
6)in Zabbix goto Administration, Media Types, add a new media called zabbixsms (your choice) and choose that it's a script, and enter the filename you specified (here: zabbixsms.php) as the script name.
7)Finally, in Zabbix, Administration, Users, click on a user, and add a new media called zabbixsms.php (or whatelse you specified). Enter their phone number like +44623023325, and press save
8) look for configuration, action to sens alert to the user
it is finish !