|
|
SMS Server Tools 3 Community |
Welcome, Guest. The forum is currently read-only, but will open soon. |
Sun Jun 01, 2025 14:16 |
Page: 1
Keywords: Mode: All keywords (AND) |
Thu May 15, 2014 15:21
|
LightScape66: Hello folks,
I'd like to post a script for use as Nagios plugin:
This Script is looking for the substrings Aktuelles and Guthaben that is used by German Telekom:
2014-05-14 15:08:48,5, GSM1: CMD: AT+CUSD=1,"*100#": OK +CUSD: 2,"Aktuelles Guthaben: 2.18 EUR.",15
You can change these strings easily. If you are looking for errors, you can turn on debugging with DEBUG=1.
#! /bin/sh
#
# This Nagios plugin checks the balance of prepaid-answer from SMStools3
#
PROGNAME=`basename $0`
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION="1.0.01"
SMSCONF=/etc/smsd.conf
BALANCESTR1=Aktuelles
BALANCESTR2=Guthaben
BALANCESTR="$BALANCESTR1 $BALANCESTR2"
. $PROGPATH/utils.sh
#
# Set to 1 for many debugging and verbose outputs
#
DEBUG=0
MODEM=$1
BALCRIT=$2
BALWARN=$3
print_help() {
print_revision $PROGNAME $REVISION
echo ""
echo "Usage:"
echo " $PROGNAME <MODEM> <CRITICAL> <WARNING>"
echo " MODEM = GSM1, GSM2....."
echo " CRITICAL = critical level"
echo " WARNING = warning level"
echo ""
}
#
# find directory with stats from config file
#
[ -f $SMSCONF ] || {
echo ERROR: SMS-Config not found
exit $STATE_UNKNOWN
}
[ -r $SMSCONF ] || {
echo ERROR: SMS-Config not readable
exit $STATE_UNKNOWN
}
result=`grep stats $SMSCONF | grep "=" | grep "/"`
IFSalt=$IFS
IFS==
set $result
result=$2
IFS=$IFSalt
STATSDIR=`echo $result`
[ -z $MODEM ] && MODEM=GSM1
[ -z $BALCRIT ] && BALCRIT=100
[ -z $BALWARN ] && BALWARN=200
#
# raise Warn, if Warn and Crit are equal
#
[ $BALWARN -eq $BALCRIT ] && BALWARN=`expr $BALWARN + 100`
#
# swap Warn and Crit, if Warn is less then Crit
#
[ $BALWARN -lt $BALCRIT ] && {
BALSWAP=$BALWARN
BALWARN=$BALCRIT
BALCRIT=$BALSWAP
[ $DEBUG -eq 1 ] && echo "Swapping Warn and Crit"
}
[ $DEBUG -eq 1 ] && {
echo "Modem : "$MODEM
echo "Warning : "$BALWARN
echo "Critical: "$BALCRIT
echo "statsDIR: "$STATSDIR
}
[ $MODEM = "--help" ] && {
print_help
exit $STATE_OK
}
#
# is MODEM defined?
#
grep "\[$MODEM\]" $SMSCONF | grep -v "#" 2>&1>/dev/null || {
echo "ERROR: Modem $MODEM not defined in $SMSCONF"
exit $STATE_UNKNOWN
}
#
# does a balance file exist?
#
BALFILE=$STATSDIR/$MODEM.balance
[ $DEBUG -eq 1 ] && echo "BALFILE : "$BALFILE
[ -f $BALFILE ] || {
echo "ERROR: $BALFILE doesn't exist"
exit $STATE_UNKNOWN
}
[ -r $BALFILE ] || {
echo "ERROR: $BALFILE isn't readable"
exit $STATE_UNKNOWN
}
[ $DEBUG -eq 1 ] && cat $BALFILE
#
# read Balance
#
result=`grep -i "$BALANCESTR" $BALFILE 2>/dev/null`
ADDSTR="INFO: $result"
[ $DEBUG -eq 1 ] && echo result: $result
[ $DEBUG -eq 1 ] && echo $ADDSTR
#
# Find Balance
#
ende=0
set $result
while [ $ende -eq 0 ]
do
result=$1
[ "Z$result" = "Z" ] && {
echo "ERROR: no matching result found in $BALFILE"
exit $STATE_UNKNOWN
}
[ $DEBUG -eq 1 ] && echo Loop: $result
echo $result | grep -i $BALANCESTR2 2>&1>/dev/null && {
BALANCE=$2
ende=1
}
shift
done
[ $DEBUG -eq 1 ] && echo Balance pre-converted: $BALANCE
#
# re-format result, convert Euro+Cents to Cents only
#
BALANCE=`echo $BALANCE | sed 's/\.//g'`
BALANCE=`expr $BALANCE + 0`
if [ $BALANCE -le $BALCRIT ]
then
echo "CRITICAL: Balance: $BALANCE not bigger than $BALCRIT Eurocents"
echo $ADDSTR
echo "Levels: WARN=$BALWARN CRIT=$BALCRIT in Eurocents"
exit $STATE_CRITICAL
elif [ $BALANCE -le $BALWARN ]
then
echo "WARNING: Balance: $BALANCE not bigger than $BALWARN Eurocents"
echo $ADDSTR
echo "Levels: WARN=$BALWARN CRIT=$BALCRIT in Eurocents"
exit $STATE_WARNING
else
echo "OK: Balance $BALANCE Eurocents"
echo $ADDSTR
echo "Levels: WARN=$BALWARN CRIT=$BALCRIT in Eurocents"
exit $STATE_OK
fi
Comments are appreciated....
Bye,
Tom
|
Wed Sep 11, 2013 11:31
|
LightScape66: Hello,
okay, after reading a FAQ-section somewhere on this board, I found the answer. I need an init-string for this modem, that the GSM modem stores the incoming SMS on the SIM card. Only there SMS can be accessed via smsd. (I hope, I understood this topic correctly!)
# Example smsd.conf. Read the manual for a description
devices = GSM1
logfile = /var/log/smsd.log
loglevel = 7
[GSM1]
device = /dev/ttyUSB0
incoming = yes
baudrate = 115200
pin = 1234
init = AT+CPMS="SM","SM","SM"
Bye,
Tom
|
Wed Sep 11, 2013 11:18
|
LightScape66: Hello,
just one guess... are the SMS stored on the SIM card? Is this memory full?
Maybe you want to test the card in a cellphone?
Bye,
Tom
|
Wed Sep 11, 2013 10:00
|
LightScape66: Operating system name and version: CentOS 6.4
Version of smsd: 3.1.15
Smsd installed from: sources
Name and model of a modem / phone: Falcom Samba 55
Interface: USB
Hallo, I can't receive messages with the modem:
2013-09-11 11:39:27,7, GSM1: <- OK
2013-09-11 11:39:27,6, GSM1: Checking if modem needs PIN
2013-09-11 11:39:27,7, GSM1: -> AT+CPIN?
2013-09-11 11:39:27,7, GSM1: Command is sent, waiting for the answer
2013-09-11 11:39:27,7, GSM1: <- +CPIN: READY OK
2013-09-11 11:39:27,7, GSM1: -> AT+CSQ
2013-09-11 11:39:27,7, GSM1: Command is sent, waiting for the answer
2013-09-11 11:39:28,7, GSM1: <- +CSQ: 30,99 OK
2013-09-11 11:39:28,6, GSM1: Signal Strength Indicator: (30,99) -53 dBm (Excellent), Bit Error Rate: not known or not detectable
2013-09-11 11:39:28,6, GSM1: Checking if Modem is registered to the network
2013-09-11 11:39:28,7, GSM1: -> AT+CREG?
2013-09-11 11:39:28,7, GSM1: Command is sent, waiting for the answer
2013-09-11 11:39:28,7, GSM1: <- +CREG: 2,1,"165F","6103" OK
2013-09-11 11:39:28,6, GSM1: Modem is registered to the network
2013-09-11 11:39:28,6, GSM1: Selecting PDU mode
2013-09-11 11:39:28,7, GSM1: -> AT+CMGF=0
2013-09-11 11:39:28,7, GSM1: Command is sent, waiting for the answer
2013-09-11 11:39:29,7, GSM1: <- OK
2013-09-11 11:39:29,6, GSM1: Checking memory size
2013-09-11 11:39:29,7, GSM1: -> AT+CPMS?
2013-09-11 11:39:29,7, GSM1: Command is sent, waiting for the answer
2013-09-11 11:39:29,7, GSM1: <- +CPMS: "SM",0,20,"MT",19,45,"MT",19,45 OK
2013-09-11 11:39:29,6, GSM1: Used memory is 0 of 20
2013-09-11 11:39:29,6, GSM1: No SMS received
My sending phone tells me, that the message is sent successfully. The value "19" (both) was 18, before I send another SMS to try again.
As smsd.conf, I'm using a very simple file:
# Example smsd.conf. Read the manual for a description
devices = GSM1
logfile = /var/log/smsd.log
loglevel = 7
[GSM1]
device = /dev/ttyUSB0
incoming = yes
baudrate = 115200
pin = 1234
Maybe, something is missing there?
Kind regards,
Tom
|
Page: 1
Time in this board is UTC.
|
|
|
 |
|
 |
|