[asterisk-users] Multi operator platform Asterisk {manage}

Steve Edwards asterisk.org at sedwards.com
Wed Aug 19 08:26:46 CDT 2009


On Wed, 19 Aug 2009, ABBAS SHAKEEL wrote:

> Rsync looks really great !

Yep. Something I wish I learned about earlier in my career :)

> How you are get CDR records etc from the remote servers for reporting 
> purpose ..... I was thinking to have one centralized database ? but your 
> comments let me think about distributed database ?

I like having a database at each datacenter for autonomy and performance.

Periodically, the master database executes a script with the following 
snippet (error checking and irrelevant details removed for brevity):

# for each host
         for     HOST in ${HOST_LIST}
         do

${DATE} "+%T Mark the records on ${HOST} to be collected."
                 mysql\
                         ${USER_AUTH}\
                         --database=@DATABASE_DATABASE@\
                         --execute="update cdrs set disposition = 'COLLECTING'"\
                         --execute=" where disposition is NULL;"\
                         --host=${HOST}\
                         ${END_OF_LIST}

${DATE} "+%T Dump the marked records from ${HOST}."
                 mysqldump\
                         ${USER_AUTH}\
                         --databases @DATABASE_DATABASE@\
                         --host=${HOST}\
                         --no-create-info\
                         --skip-opt\
                         --tables cdrs\
                         --where="disposition = 'COLLECTING'"\
                         >/tmp/${HOST}.sql\
                         ${END_OF_LIST}

${DATE} "+%T Load the records from ${HOST} into our database."
                 mysql\
                         ${USER_AUTH}\
                         --database=@DATABASE_DATABASE@\
                         --host=localhost\
                         </tmp/${HOST}.sql\
                         ${END_OF_LIST}

${DATE} "+%T Compressing the dump file from ${HOST}."
                 gzip /tmp/${HOST}.sql
                 mv /tmp/${HOST}.sql.gz /tmp/${HOST}.sql.gz-${TIMESTAMP}

${DATE} "+%T Delete the collected records from ${HOST}."
                 mysql ${USER_AUTH}\
                         --database=@DATABASE_DATABASE@\
                         --execute="delete from cdrs where disposition = 'COLLECTING';"\
                         --host=${HOST}\
                         ${END_OF_LIST}

${DATE} "+%T Set the disposition on this host."
                 mysql ${USER_AUTH}\
                         --database=${DATABASE_DATABASE}\
                         --execute="update cdrs set disposition = 'COLLECTED'"\
                         --execute=" where disposition = 'COLLECTING';"\
                         --host=localhost\
                         ${END_OF_LIST}

# end of hosts loop
         done

-- 
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards       sedwards at sedwards.com      Voice: +1-760-468-3867 PST
Newline                                              Fax: +1-760-731-3000



More information about the asterisk-users mailing list