How to move Sonata Stats to a remote server?

If you’d like to move Sonata Stats to another server, to reduce the load on the main VitalPBX server.

  • First, install the Sonata Stats on your new server.

  • Then, you will need to edit this file /usr/share/sonata/queues-stats/backend/.env

DB_ASTERISK_HOST=VITALPBX_IP_SERVER
DB_ASTERISK_PORT=3306
DB_ASTERISK_USERNAME=REMOTE_MYSQL_USER
DB_ASTERISK_PASSWORD=REMOTE_MYSQL_SECURE_PWD

On this configuration, you will need to enter the IP address of the asterisk, server port, and credentials

  • In the Linux CLI, execute the command below.
mysql -uroot -e"create database sonata_stats"
  • Create a user with all permissions for the sonata_stats database.
mysql -uroot
grant all privileges on sonata_stats.*  to "stats"@"localhost" identified by "SECURE_PWD"
  • On the .env file edit these configurations and enter the credentials created in the previous step.
DB_USERNAME=stats
DB_PASSWORD=SECURE_PWD
  • From this location /usr/share/sonata/queues-stats/backend execute these commands
php artisan config:cache
php artisan migrate
  • To create our admin user, we have to execute the command below.
php artisan tinker

Then, we have to paste the following code.

use App\Role;
use App\User;

$user = User::updateOrCreate(
  ['name' => 'admin'],
  ['password' => 'enter your password here',
  'full_name' => 'admin',
  'tenant_id' => 1,
  'tenant' => 'vitalpbx']
);

$user->roles()->sync(Role::where('name', 'admin')->first());

Finally, edit the file /var/lib/sonata/stats/wizard.conf and configure the flag below.

installed=yes

Now, you should be able to access sonata stats from your new server.

3 Likes