If the number of events stored in the Enswitch database becomes excessive, performance may suffer. This can be cured by archiving old events.
Archiving events locally
If old events are still required, they can be archived within the Enswitch database. This improves the performance of the events report, but still makes the archived events available if necessary. To do this, change the "Table containing archived events" configuration setting to "events_archive", then add an entry similar to the following to /etc/crontab:
39 3 * * * enswitch /opt/enswitch/current/bin/events_archive 90
This archives events older than 90 days every night at 3:39am.
Archived events are moved from the events to the events_archive table within the Enswitch database. This improves performance by reducing the size of the indexes on the events table, making the searches done by the events report faster.
Archived events are hidden from all users by default. It is possible to allow some roles to access them by granting the "Read archived data" role permission. This should be done with caution because it reduces the performance gains made by archiving, and should normally be limited to the system owner role.
Archiving events remotely
As an alternative to archiving events locally as above, events can be moved to a remote database on another machine. THIS IS NOT SUPPORTED, AND NOT RECOMMENDED. IF YOU DO THIS, YOU ARE RESPONSIBLE FOR CONFIGURING AND MANAGING THE REMOTE MACHINE. YOU WILL NEED TO MERGE ANY SCHEMA CHANGES MADE BY FUTURE ENSWITCH UPGRADES. If you're sure you want to do this, the steps are:
- Contact Enswitch support and let them know you're doing this. They will disown any responsibility for what you're doing.
- Take a backup of the Enswitch database.
- If you've archived any events locally, move them back to the events table.
- Create the remote database, with the events table. This table must have exactly the same schema as the Enswitch database. Note that if future versions of Enswitch change these schemas, you must manually change the remote database.
- Create a database user for the new database, and give them access to the events table.
- Create "delete/events/archive", "insert/events/archive", and "select/events/archive" handlers in /etc/enswitch/databases.ini.
- Change the "Table containing archived events" configuration setting to "events".
- Restart the web server.
- Create a crontab entry, similar to the local archiving above, but for "/opt/enswitch/current/bin/events_archive_remote".
- Run "/opt/enswitch/current/bin/events_archive_remote <days>" manually.
- Check that the data in both databases is as you expect.
- Enable the "Read archived data" permission for any roles that may access archived events. This should be done with caution because it reduces the performance gains made by archiving, and should normally be limited to the system owner role.