SMS Server Tools 3
This site is hosted by Kekekasvi.com
 Menu
Basic information:
Additional information:
Support:
Get SMS Server Tools 3:
Additional Options

 Sponsored links

 Search
Custom Search

 Visitor locations
 
 SMS Server Tools 3 Community
Welcome, Guest. Please login or register. Sat May 25, 2024 11:21
SMSTools3 Community » Help and support Bottom

[answered] counter sms to same phone

  This topic is locked

Page:  1

Author Post
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

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.

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?? :roll:

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?? :roll:

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: 830


And after the latest script:
# cat /var/spool/sms/sent_numbers/*.counter | grep -v "^$"
3584057XXXXX: 2
3584057XXXXX: 1


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!! :lol:
keke wrote
Everything is possible ;).

Absolutely right! :twisted:

keke wrote
The next script does it. In this case, STORAGE defines a directory.

Works perfectly!! :mrgreen:
Thank you very much!!

Now, I try to log all in sql database.
Next time!!

  This topic is locked

Page:  1

SMSTools3 Community » Help and support Top

 
Time in this board is UTC.  

Privacy Policy   SMS Server Tools 3 Copyright © Keijo Kasvi.