Author |
Post |
|
#1 Thu Jul 15, 2010 16:46, 176 months ago.
|
Member
Registered: Jul 2009
Location: Italy
|
Operating system name and version: Debian 5.0.4 Version of smsd: 3-3.1.5 Smsd installed from: sources Name and model of a modem / phone: Siemens S35 Interface: serial
Hi to all, I would like to know if it's possible to make(or how to set) a counter to see how many sms my smstool's box sent to same phone number.
Tks Tokie
|
|
#2 Thu Jul 15, 2010 17:23, 176 months ago.
|
Administrator
Registered: May 2009
Location: Jyväskylä, Finland
|
If you have SQL database available, and use eventhandler to store messages into it ( example ), you can see counts from the database. If you do not want to use SQL database, the following script as an eventhandler will keep up the counters: #!/bin/bash
if [ "$1" = "SENT" ]; then
STORAGE="/var/spool/sms/sent_counters"
TO=`formail -zx To: < $2` #Remove plus sign, spaces, minus and short number prefix TO=`echo "$TO" | sed 's/ //g' | sed 's/+//g' | sed 's/s//g' | sed 's/-//g'`
! [ -f "$STORAGE" ] && touch ${STORAGE} counter=`formail -zx ${TO}: < ${STORAGE}` counter=$(($counter + 1))
TMPFILE=`mktemp /tmp/smsd_XXXXXX` cp ${STORAGE} $TMPFILE formail -f -I "${TO}: $counter" < $TMPFILE > ${STORAGE} unlink $TMPFILE
fi 'bash' Syntax Highlight powered by GeSHi This example will count the number of whole SMS, not number of parts. If you need to count number of parts, you have to set store_sent_pdu = yes, and count how many PDU's are in the message file, and apply this as an increment to the counter.
|
|
#3 Fri Jul 16, 2010 09:49, 176 months ago.
|
Member
Registered: Jul 2009
Location: Italy
Topic owner
|
keke wrote If you have SQL database available, and use eventhandler to store messages into it ( example ), you can see counts from the database.
Thank you for this keke wrote This example will count the number of whole SMS, not number of parts. If you need to count number of parts, you have to set store_sent_pdu = yes, and count how many PDU's are in the message file, and apply this as an increment to the counter.
Sorry, but I don't understand; Count the number of whole SMS already does in /var/spool/sms/stats/Siemens.counter; Correct? I only need to know how many sms my Smsd (with only one phone) sent to each phone number; for example: /var/spool/sms/stats/Siemens.counter 39333xxxxxx --> 14 39333yyyyyyy --> 4 or else: /var/spool/sms/stats/Siemens/39333xxxxxx.counter 14 /var/spool/sms/stats/Siemens/39333yyyyyyy.counter 4 It's possibile??
|
|
#4 Fri Jul 16, 2010 10:27, 176 months ago.
|
Administrator
Registered: May 2009
Location: Jyväskylä, Finland
|
tokie wrote Sorry, but I don't understand; Count the number of whole SMS already does in /var/spool/sms/stats/Siemens.counter; Correct?
Yes, but this file contains number of parts sent, not number of SMS. For example single SMS can contain 3 parts and in this case that counter is incremented with 3. For example, if using a SIM which has 1000 SMS ( = parts ) / month -contract, this counter can be used to detect when the limit is used. Smsd does not clear this counter, which means that every month smsd should be stopped and counter should be cleared manually. tokie wrote I only need to know how many sms my Smsd (with only one phone) sent to each phone number; for example: /var/spool/sms/stats/Siemens.counter 39333xxxxxx --> 14 39333yyyyyyy --> 4
That's what the script does, but the file cannot be same as the <modemname>.counter. You could use something like /var/spool/sms/stats/Siemens.numbers. The format of a file is compatible with formail: 39333xxxxxx; 14 39333yyyyyyy: 4 tokie wrote or else: /var/spool/sms/stats/Siemens/39333xxxxxx.counter 14 /var/spool/sms/stats/Siemens/39333yyyyyyy.counter 4 It's possibile??
Everything is possible . The next script does it. In this case, STORAGE defines a directory. #!/bin/bash
if [ "$1" = "SENT" ]; then
STORAGE="/var/spool/sms/sent_numbers"
TO=`formail -zx To: < $2` #Remove plus sign, spaces, minus and short number prefix TO=`echo "$TO" | sed 's/ //g' | sed 's/+//g' | sed 's/s//g' | sed 's/-//g'`
STORAGE="${STORAGE}/${TO}.counter"
! [ -f "$STORAGE" ] && touch ${STORAGE} count=`formail -zx ${TO}: < ${STORAGE}` count=$(($count + 1))
TMPFILE=`mktemp /tmp/smsd_XXXXXX` cp ${STORAGE} $TMPFILE formail -f -I "${TO}: $count" < $TMPFILE > ${STORAGE} unlink $TMPFILE
fi 'bash' Syntax Highlight powered by GeSHi Again, the format is compatible with formail. Another point is that when there is a header included, it's easy to monitor counters. For example: # cat /var/log/smstools/smsd_stats/*.counter GSM1: 479 GSM2: 242 GSM3: 8 GSM4: 715 GSM5: 830And after the latest script: # cat /var/spool/sms/sent_numbers/*.counter | grep -v "^$" 3584057XXXXX: 2 3584057XXXXX: 1
|
|
#5 Fri Jul 16, 2010 16:12, 176 months ago.
|
Member
Registered: Jul 2009
Location: Italy
Topic owner
|
keke wrote tokie wrote Sorry, but I don't understand; Count the number of whole SMS already does in /var/spool/sms/stats/Siemens.counter; Correct?
Yes, but this file contains number of parts sent, not number of SMS. For example single SMS can contain 3 parts and in this case that counter is incremented with 3. For example, if using a SIM which has 1000 SMS ( = parts ) / month -contract, this counter can be used to detect when the limit is used. Smsd does not clear this counter, which means that every month smsd should be stopped and counter should be cleared manually.
Only for information, I try many sms(my system send always same kind of sms) and the counter is incremented with 1 each sms!! keke wrote Everything is possible .
Absolutely right! keke wrote The next script does it. In this case, STORAGE defines a directory.
Works perfectly!! Thank you very much!! Now, I try to log all in sql database. Next time!!
|