Xymon Mailing List Archive search

receiving sms alerts...

list Steffan Noord
Wed, 13 Sep 2017 10:59:47 +0200
Message-Id: <005001d32c6e$a6529110$f2f7b330$@tikklik.nl>

Im using this:

In alerts

script /home/xymon/server/sms/smsalert.pl 31xxxxxx FORMAT=sms

 
/home/xymon/server/sms/smsalert.pl:

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

#!/bin/sh

 
/home/xymon/server/sms/sendsms.php $RCPT "$BBALPHAMSG"

 
/home/xymon/server/sms/sendsms.php:

#!/usr/bin/php

<?php

 
$gsm = $argv[1];

$message = $argv[2];

mail('user-a95c6d58b6f3@xymon.invalid', 'Monitor Alert', $message .  $gsm);

$file = fopen("http://www.targetsms.nl/service/sendsms?username=xxxx&handle=7840ea16c7f3001fe86152bef5b6b727&aff=32879&soort=SMS&originator=Monitor+Alert&to=$gsm&message=$message","r";);;

?>

 
Van: Xymon [mailto:xymon-bounces at xymon.com] Namens Metron 6 (six)
Verzonden: woensdag 13 september 2017 02:47
Aan: Bruce Ferrell <user-24fbf1912cfe@xymon.invalid>
CC: xymon at xymon.com
Onderwerp: Re: [Xymon] receiving sms alerts...

 
i cant get it to work....

 
this is from alerts.cfg

 
 HOST=%^mt-* SERVICE=conn
      MAIL user-ab9f8efad8f2@xymon.invalid <mailto:user-ab9f8efad8f2@xymon.invalid>  REPEAT=30 RECOVERED
      SCRIPT /usr/local/bin/smsalert.sh 306944420303 FORMAT=SMSthis is smsalert.sh

 
this is smsalert.sh

 
#!/bin/bash
echo "Parameters passed by Xymon to the smsalert.sh script: "$RCPT ":" $BBALPHAMSG >> /usr/local/bin/logsms.txt
/usr/local/bin/sendsms.sh $RCPT $BBALPHAMSG

and this is sendsms.sh

 
#!/bin/bash
RCPTTO=$1
RCPTTEXT=$2
echo "parameters passed to sendsms.sh are " $RCPTTO ":" $RCPTTEXT >> /usr/local/bin/logsms.txt
curl -v -u <username>:<password> 'https://www.prosms.gr/secure/api/index.php?mobile_number='$RCPTTO'; <https://www.prosms.gr/secure/api/index.php?mobile_number='$RCPTTO'&originator=EZHellas&text='$RCPTTEXT'&request_delivery=true>; &originator=EZHellas&text='$RCPTTEXT'&request_delivery=true' >> /usr/local/bin/logsms.txt

 
This is whats written to the log file:

 
Parameters passed by Xymon to the smsalert.sh script: 306944420303 : mt-PASCHALIDIS-SERRES:conn red [666942] &red 10.122.90.26 is unreachable
parameters passed to sendsms.sh are  306944420303 : mt-PASCHALIDIS-SERRES:conn
1|75739990|248

 
and of course i receive a cropped sms message...

anyone can help ?

 
On Fri, Sep 8, 2017 at 5:46 PM, Bruce Ferrell <user-24fbf1912cfe@xymon.invalid <mailto:user-24fbf1912cfe@xymon.invalid> > wrote:
either of these would do the job:

php <file that contains the code below>

or a script that looks like this (adjust the first line to your php location. and define the variables to match the info they gave you):


#!/usr/bin/php
<?php

        // Simple SMS send function

        function sendSMS($key, $to, $message, $originator) {

                $URL = "https://smscenter.gr/api/sms/send?key="; . $key . "&to=" . $to;

                $URL .= "&text=" . urlencode( $message ) . '&from=' . urlencode( $originator );

                $fp = fopen( $URL, 'r' );

                return fread( $fp, 1024 );

        }

        // Example of use 

        $response = sendSMS( 'myapikey', 'recipientnumber', 'My test message', 'from' );

        echo $response;

?>


On 9/8/17 7:17 AM, Metron 6 (six) wrote:

hello all, 

i got a subscription to an SMS gateway, and the script they gave me is this:


<?php

        // Simple SMS send function

        function sendSMS($key, $to, $message, $originator) {

                $URL = "https://smscenter.gr/api/sms/send?key="; . $key . "&to=" . $to;

                $URL .= "&text=" . urlencode( $message ) . '&from=' . urlencode( $originator );

                $fp = fopen( $URL, 'r' );

                return fread( $fp, 1024 );

        }

        // Example of use 

        $response = sendSMS( 'myapikey', 'recipientnumber', 'My test message', 'from' );

        echo $response;

?>


how could i implement it inside alerts.cfg in order to get sms alerts ?


--

regards,
Metron 6 (six)

user-17e4b93d552a@xymon.invalid <mailto:user-17e4b93d552a@xymon.invalid> 

--

regards,
Metron 6 (six)

user-17e4b93d552a@xymon.invalid <mailto:user-17e4b93d552a@xymon.invalid>