Hi guys.
I want to send alerts to sms provider.
In which file are the alerts written to the database.
How can I do it.
Hi Kevin.
Thank you for reply.
I have already examined https://docs.librenms.org/Alerting/Transports/
But I want to add extra sms provider.
The provider content I want to add is following
<?php
function sendsms($msg, $numbernum, $header)
{
** $username= “XXXX”;**
** $pass= “XXXX”;**
** $startdate=date(‘d.m.Y H:i’);**
** $startdate=str_replace(’.’, ‘’,$startdate );**
** $startdate=str_replace(’:’, ‘’,$startdate);**
** $startdate=str_replace(’ ', ‘’,$startdate);**
** $stopdate=date(‘d.m.Y H:i’, strtotime(’+1 day’));**
** $stopdate=str_replace(’.’, ‘’,$stopdate );**
** $stopdate=str_replace(’:’, ‘’,$stopdate);**
** $stopdate=str_replace(’ ', ‘’,$stopdate);**
** $url=“http://api.netgsm.com.tr/bulkhttppost.asp?usercode=$username&password=$pass&gsmno=$numbernum&message=$msg&msgheader=$header&startdate=$startdate&stopdate=$stopdate”;**
** //echo $url;**
** $ch = curl_init(); **
** curl_setopt($ch,CURLOPT_URL,$url);**
** curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);**
// curl_setopt($ch,CURLOPT_HEADER, false);
** $output=curl_exec($ch);**
** curl_close($ch);**
** return $output;**
}
$message='Message Text ';
**$number=‘905XXXXXXXXX’; **
$head=‘MessageHeader’;
**$message = html_entity_decode($message, ENT_COMPAT, “UTF-8”); **
**$message = rawurlencode($message); **
**$head = html_entity_decode($head, ENT_COMPAT, “UTF-8”); **
**$head = rawurlencode($head); **
echo sendsms($message,$number,$head);
?>
How can I add this php file
nevzatgul,
share your code and give back to the community… and make a pull request in git hub
Pull Request
<?php
function sendsms($msg, $numbernum, $header)
{
$username= “XXXX”;
$pass= “XXXX”;
$startdate=date(‘d.m.Y H:i’);
$startdate=str_replace(’.’, ‘’,$startdate );
$startdate=str_replace(’:’, ‘’,$startdate);
$startdate=str_replace(’ ', ‘’,$startdate);
$stopdate=date(‘d.m.Y H:i’, strtotime(’+1 day’));
$stopdate=str_replace(’.’, ‘’,$stopdate );
$stopdate=str_replace(’:’, ‘’,$stopdate);
$stopdate=str_replace(’ ', ‘’,$stopdate);
$url=“http://api.netgsm.com.tr/bulkhttppost.asp?usercode=$username&password=$pass&gsmno=$numbernum&message=$msg&msgheader=$header&startdate=$startdate&stopdate=$stopdate”;
//echo $url;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
// curl_setopt($ch,CURLOPT_HEADER, false);
$output=curl_exec($ch);
curl_close($ch);
return $output;
}
$message='Message Text ';
$number=‘905XXXXXXXXX’;
$head=‘MessageHeader’;
$message = html_entity_decode($message, ENT_COMPAT, “UTF-8”);
$message = rawurlencode($message);
$head = html_entity_decode($head, ENT_COMPAT, “UTF-8”);
$head = rawurlencode($head);
echo sendsms($message,$number,$head);
?>
Post the code in git hub by making a pull request -
Click here to make pull request