3. Data Queue Partial Update

The script is able to update the queues data activity already stored in the QueueMetrics database with a new data coming from a different queue_log. It’s useful for maintaining corrupted (or restoring) databases.

This script works in pair with the qloader.pl script with revision number equal or greater than 1.12.

3.1. Configuration

In order to use it, the script has to be customized with information related to the database. The relevant configuration keys are:

my $mysql_host = "127.0.0.1";
my $mysql_db   = "queuemetrics";
my $mysql_user = "queuemetrics";
my $mysql_pass = "javadude";

my $qloaderbin = "./qloader.pl";

my $logfile    = "queuepartialupdater.log";

More in detail:

  • $mysql_host: is the server where the QM database is located
  • $mysql_db: is the QM database name
  • $mysql_user: is a QM database user with read/write permissions
  • $mysql_pass: is the password related to the below-specified user
  • $qloaderbin: is the full path where the qloader.pl script could be reached
  • $logfile: is the file where the log will be written

You can pass the following parameters to avoid changing the file itself:

  • -h hostname: the MySQL hostname to connect to
  • -d database: the MySQL database to connect to
  • -u user: the MySQL username to use
  • -p pass: the MySQL password to use

3.2. How to use it

The script can be called via the command line by specifying:

  • The queue data file to be read
  • The partition to be updated
  • The queue log data file (the one the qloader script will use).

The script will be responsible for removing all data overlapping with the period specified in the input queue data file for the defined partition. It will then be responsible for calling the qloader script. That script will be able to fill the database with the new information provided by the same queue data log. At the end of the processing, the log specified by the comnmand line will report the result of the new data filling. The log specified by the configuration, instead, will list the actions performed by the queuePartialUpdater script in order to correct the database.

An example of usage is:

./queuePartialUpdater.pl /var/log/asterisk/queue_log P001 /var/log/qlog.log