SMSeagle not working

Hello All!

I have a strange problem with SMS-eagle (Firmware 4.41) SMSEagle is an offline hardware SMS gateway.

When i try to send an SMS from the transport GUI in LibreNMS, nothing happens.
But if i point out an apache2 webserver in linux instead of the gateway and copy the string that shows in the logfile and sends it to the gateway, then I get an SMS… strange…

Logfile in apache2 that works if i copy it to the addressfield of a browser and sends it to the gateway (X=Tel nr.)

[07/Feb/2023:07:27:35 +0100] “GET /index.php/http_api/send_sms?login=librenms&pass=LibreNMS&to=%2BXXXXXXXXX%2C&message=Testing+transport+from+LibreNMS HTTP/1.1” 404 434 “-” “-”

My environment:

===========================================

Component Version
LibreNMS 23.1.0-19-gaa033ec3c (2023-02-02T14:07:59+01:00)
DB Schema 2022_09_03_091314_update_ports_adsl_table_with_defaults (248)
PHP 8.1.2-1ubuntu2.10
Python 3.10.6
Database MariaDB 10.6.11-MariaDB-0ubuntu0.22.04.1
RRDTool 1.7.2
SNMP 5.9.1
===========================================

[OK] Composer Version: 2.5.2
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database Schema is current
[OK] SQL Server meets minimum requirements
[OK] lower_case_table_names is enabled
[OK] MySQL engine is optimal
[OK] Database and column collations are correct
[OK] Database schema correct
[OK] MySQl and PHP time match
[OK] Active pollers found
[OK] Dispatcher Service not detected
[OK] Locks are functional
[OK] Python poller wrapper is polling
[OK] Redis is unavailable
[OK] rrd_dir is writable
[OK] rrdtool version ok

Best regards / Matte Nilsson

Hi!

Can you try to send the HTTP GET request manually from the command-line of the LibreNMS server using Curl (curl -v)? The output may give some more information.

With kind regards,
Ruben

Hello!

Thanks for the push in right direction!
The gateway was redirecting http → https and curl didnt like that.
so we added this to line 59 in the Smseagle.php-file:

curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

Best regards / Matte Nilsson

Hello!
If anyone have problem with SMSeagle, we have “improved” the Smseagle.php code for SMSeagle Software version 4.41, feel free to use!

<?php
/* Copyright (C) 2015 Daniel Preussker <[email protected]>
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>. */

/**
 * SMSEagle API Transport
 *
 * @author Barry O'Donovan <[email protected]>
 * @copyright 2017 Barry O'Donovan, LibreNMS
 * @license GPL
 */

namespace LibreNMS\Alert\Transport;

use Illuminate\Support\Str;
use LibreNMS\Alert\Transport;
use LibreNMS\Util\Proxy;

class Smseagle extends Transport
{
    protected $name = 'SMSEagle';

    public function deliverAlert($obj, $opts)
    {
        $smseagle_opts['url'] = $this->config['smseagle-url'];
        $smseagle_opts['user'] = $this->config['smseagle-user'];
        $smseagle_opts['token'] = $this->config['smseagle-pass'];
        $smseagle_opts['to'] = preg_split('/([,\r\n]+)/', $this->config['smseagle-mobiles']);

        return $this->contactSmseagle($obj, $smseagle_opts);
    }

    public static function contactSmseagle($obj, $opts)
    {
        $params = [
            'login' => $opts['user'],
            'pass' => $opts['token'],
            'to' => implode(',', $opts['to']),
            'message' => $obj['msg'],
        ];
        $url = Str::startsWith($opts['url'], 'http') ? '' : 'http://';
        $url .= $opts['url'] . '/index.php/http_api/send_sms?' . http_build_query($params);
        $preg_changefrom = array('/%2C/','/,&/','/%2B/');
        $preg_changeto = array(',','&','+');
        $url = preg_replace($preg_changefrom,$preg_changeto,$url);
        $curl = curl_init($url);

        Proxy::applyToCurl($curl);
        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);

        $ret = curl_exec($curl);
        if (substr($ret, 0, 2) == 'OK') {
            return true;
        } else {
            return false;
        }
    }

    public static function configTemplate()
    {
        return [
            'config' => [
                [
                    'title' => 'SMSEagle Base URL',
                    'name' => 'smseagle-url',
                    'descr' => 'SMSEagle Host',
                    'type' => 'text',
                ],
                [
                    'title' => 'User',
                    'name' => 'smseagle-user',
                    'descr' => 'SMSEagle User',
                    'type' => 'text',
                ],
                [
                    'title' => 'Password',
                    'name' => 'smseagle-pass',
                    'descr' => 'SMSEagle Password',
                    'type' => 'text',
                ],
                [
                    'title' => 'Mobiles',
                    'name' => 'smseagle-mobiles',
                    'descr' => 'SMSEagle Mobiles, can be new line or comma separated',
                    'type' => 'textarea',
                ],
            ],
            'validation' => [
                'smseagle-url'     => 'required|url',
                'smseagle-user'    => 'required|string',
                'smseagle-pass'    => 'required|string',
                'smseagle-mobiles' => 'required',
            ],
        ];
    }
}

Best regards / Matte Nilsson

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.