Create (or Reset) the Monitor Database

For MySQL traffic monitoring connection and database information is stored in /opt/websafety/var/console/console/settings.py file and look like the following.

DILADELE_MONITOR_DB_MYSQL = {
    'ENGINE'  : 'django.db.backends.mysql',
    'NAME'    : 'websafety_monitor',
    'USER'    : 'websafety',      # only this can be adjusted
    'PASSWORD': 'Passw0rd',       # only this can be adjusted
    'HOST'    : '127.0.0.1',      # only this can be adjusted
    'PORT'    : '3306'            # only this can be adjusted
}

Please note the settings reference specific MySQL user websafety that you need to create for the MySQL database connection to succeed. You can of course use your own user if desired. We use the following command to create such a user in our Virtual Appliance mysql -u root mysql < websafety.sql where websafety.sql looks like the following.

GRANT ALL PRIVILEGES ON *.* To 'websafety'@'localhost' IDENTIFIED BY 'Passw0rd';
FLUSH PRIVILEGES;

After you have adjusted the settings above as desired run the following script.

# stop apache server so that Web UI does not have connections to database
service apache2 stop

# stop wsmgrd daemon so that it does not hold connections to database
service wsmgrd stop

# switch Web UI to new database settings
python3 /opt/websafety/var/console/switch_db.py --db=mysql

# reinitialize the database recreating all tables and dropping all current records
# the script assumes 'root', 'Passw0rd' credentials for Web UI; if it is not so
# please adjust the sync_db.py contents (it is easy)
python3 /opt/websafety/var/console/sync_db.py

# reset the owner just in case
chown -R websafety:websafety /opt/websafety

# start apache and wsmgrd
service wsmgrd start
service apache2 start

If something goes wrong or does not work as expected, please take a look at log files /opt/websafety/var/log/database.log and /opt/websafety/var/log/wsmgrd.log.

From now on monitoring data upload will be done into configured MySQL database. Reporting will pull data for reports from this database too. If you require your own reports on collected data, be free to use any reporting tool available for MySQL databases.