You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2015-11-02 13:01:55

eric.le-corre
Member
Registered: 2013-01-07
Posts: 1,005

SLA envoi alerte SMS

Bonjour,

Peut être une fonctionnalité qui pourrait intéresser certaines personnes :

J'utilise Zabbix, un logiciel de monitoring pour mon réseau. Avec Zabbix, j'ai développé avec l'aide d'autres scripts sur internet une page PHP qui permet d'envoyer une alerte SMS. Cela fonctionne ainsi, j'ai un compte sur une plateforme SMS tm4b : https://www.tm4b.com/en/features

J'ai une page alerteSMS.php codé ainsi :

#!/usr/bin/php
<?php

// Where should this script log to? The directory must already exist.
$logfilelocation = "/var/log/zabbix-server/sms/";
$to         = $argv[1];
$subject    = $argv[2];
$message    = $argv[3];


$request = ""; //initialise the request variable
$param["type"] = "broadcast";
#$param["route"] = "GD02";
$param["username"] = "toto"; //this is the username of our TM4B account
$param["password"] = "titi"; //this is the password of our TM4B account
#$param["type"] = "broadcast";
#$param["version"] = "2.1";
$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 if
#$param["route"] = "frst";//we want to send the message via first class
#$param["sim"] = "yes";//we are only simulating a broadcast

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%7C447771514662&from=MyCo$
*/
$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;

?>

Ensuite pour envoyer un SMS, il suffit de lancer cette simple commande :
./alertesms.php numero-de-telephone "objet" "message"

Exemple :
./alertesms.php +33673023329 "ALERTE: un ticket est passé en urgence HAUTE" "le ticket 2897 est passé en urgence haute à 12h00"

Voilà donc il serait techniquement possible d'ajouter cette fonctionnalité d'alerte SMS notamment pour les SLAs à GLPI et de façon très simple.

Offline

#2 2015-11-06 16:34:58

fathi.bennasr
Member
From: Tunis
Registered: 2014-04-02
Posts: 54

Re: SLA envoi alerte SMS

Bonjour,

Comment appeler automatiquement cette page depuis glpi (lorsque par exemple le ticket passe en urgence HAUTE) ?


Rocky Linux 8 - php-7.4.27 + memcached - MariaDB-server-10.6.5 - GLPI 9.5.6 + Fusioninventory 9.5+3.0
ocsinventory-server-2.9.2

Offline

Board footer

Powered by FluxBB