Xymon Mailing List Archive search

Remove square brackets from Alerts

3 messages in this thread

list Allan Spencer · Tue, 20 May 2008 11:45:02 +1000 ·
Hi,

Ive had a bit of a hunt around for this but didnt find anything. We're in the process of looking at a new email-to-sms provider and just found out that square brackets and a bunch of others are not supported so I need to know if I can remove them from the alert code or somehow generate the message in a way that it doesnt send them.

Currently I basically have the following

HOST=*
SCRIPT /home/monitor/server/bin/smsalert.sh 04xxxxxxxx reapt=15m duration=>10m recovered format=sms

and the smsalert.sh
echo "${BBALPHAMSG:0:160}" | gnokii --sendsms "$RCPT"

It all works fine and comes out as host.domain.com:svcs red [ackcode[ which is where the problem is. I had a plan originally to be able to reply back to the msg and ack the alert but currently its not being used so removing the ack code is an option but my preference is to remove the brackets if possible.

If anyone could assist it would be greatly appreciated

Cheers

Allan
list Dominique Frise · Tue, 20 May 2008 09:24:26 +0200 ·
Hi Allan,

We do encode square brackets before calling our sms_client exectutable.

# Alert message.
# Extract first error line from the received message text.
# SMS is limited to 160 char.
# We allow 30 char. for the $BBHOSTNAME:$BBSVCNAME [$ACKCODE] stuff.
# It remains 130 for the $LINE.
LINE=`echo "$BBALPHAMSG" | grep "&${BBCOLORLEVEL}" | head -1`
LINE=`echo "$LINE" | sed -e "s/&${BBCOLORLEVEL} //g"`
LINE=`echo "$LINE" | cut -c1-130`

# "[" and "]" must be encoded as 27(ESC) 60 and 27 62 respectively
# This is achieved in vi using CTRL-V ESC < and CTRL-V ESC >
# For details in 7 bit default alphabet specified in GSM,
# see http://www.visualgsm.com/bit_default_alphabet.htm
SMS_MSG="$BBHOSTNAME:$BBSVCNAME ^[<$ACKCODE^[>
$LINE"


Dominique
quoted from Allan Spencer


Allan Spencer wrote:
Hi,

Ive had a bit of a hunt around for this but didnt find anything. We're in the process of looking at a new email-to-sms provider and just found out that square brackets and a bunch of others are not supported so I need to know if I can remove them from the alert code or somehow generate the message in a way that it doesnt send them.

Currently I basically have the following

HOST=*
SCRIPT /home/monitor/server/bin/smsalert.sh 04xxxxxxxx reapt=15m duration=>10m recovered format=sms

and the smsalert.sh
echo "${BBALPHAMSG:0:160}" | gnokii --sendsms "$RCPT"

It all works fine and comes out as host.domain.com:svcs red [ackcode[ which is where the problem is. I had a plan originally to be able to reply back to the msg and ack the alert but currently its not being used so removing the ack code is an option but my preference is to remove the brackets if possible.

If anyone could assist it would be greatly appreciated

Cheers

Allan

list Henrik Størner · Fri, 23 May 2008 10:38:06 +0200 ·
quoted from Allan Spencer
On Tue, May 20, 2008 at 11:45:02AM +1000, Allan Spencer wrote:
out that square brackets and a bunch of others are not supported so I  
need to know if I can remove them from the alert code or somehow  
generate the message in a way that it doesnt send them.
[snip]
and the smsalert.sh
echo "${BBALPHAMSG:0:160}" | gnokii --sendsms "$RCPT"
How about

 echo "${BBALPHAMSG:0:160}" | \
 sed -e 's!\[!(!' -e 's!\]!)!' \
 gnokii --sendsms "$RCPT"

to simply replace the square brackets with plain ones ?


Henrik