This is a step-by-step tutorial on how to determine whether your file storage is getting close to its capacity limit before you run out of space — and how to monitor it in an automated way.
Solution
While the Axigen mail server software has a maximum message storage file size of 4GB, we typically recommend a limit of 3GB per file for message storage. Given the maximum of 128 files per storage location, that will result in a maximum available storage space of 384 GB for each storage location of each domain. If needed, you can add additional storage locations.
However, the question is, how can you determine when the file storage is nearing its capacity limit so you can add more storage before you run out of space? This article aims to address this issue.
Steps to Check File Storage Capacity Limit
First of all, the 3GB per file limit has been implemented for safety reasons in order to avoid possible complications that may appear when reaching the 4GB size, where there's no more room to expand. This would require the compaction of the storage with split argument, which is not a trivial procedure, and we strongly suggest you avoid it.
You can monitor the storage usage by using one of the below methods:
Method #1
1. Scripts that check the expandable storage size in GB or in percentage
Use the sample python scripts in order to check if the expandable storage size is less then a specific value (in GB). Download here
Note: These scripts work via cli2.py, which you can download here
Installation:
Place both python scripts (cli2.py and checkstorage.py) in the same directory and use the chmod command to make them executable. For example:
Edit the following lines in the checkstorage.py script with your CLI listener details:
CLI_PORT=7000;
CLI_ADMIN_USER="admin";
CLI_ADMIN_PASS="your-admin-password";
Usage:
Usage: checkstorage.py <Value to check for - in GB>
~/scripts$ .
it will give no output if the expandable storage size is higher than the mentioned value:
~/scripts$
This will be the result if only one expandable storage size is lower than the provided value:
domain example.tld storage /var/opt/axigen/domains/example.tld//messages/ alarm (125.4GB 50.49%)
~/scripts$
This will be the result if multiple expandable storage sizes are lower than the provided value
domain example.tld storage /var/opt/axigen/domains/example.tld//objects/ alarm (128.0GB 99.50%)
domain example.tld storage /var/opt/axigen/domains/example.tld//messages/ alarm (125.4GB 50.49%)
domain localdomain.tld storage /var/opt/axigen/domains/localdomain.tld/ alarm (128.0GB 100.00%)
domain localdomain.tld storage /var/opt/axigen/domains/localdomain.tld/objects/ alarm (128.0GB 100.00%)
domain localdomain.tld storage /var/opt/axigen/domains/localdomain.tld/messages/ alarm (127.9GB 100.00%)
domain someotherdomain.tld storage /var/opt/axigen/domains/someotherdomain.tld/ alarm (128.0GB 100.00%)
domain someotherdomain.tld storage /var/opt/axigen/domains/someotherdomain.tld/objects/ alarm (128.0GB 77.35%)
domain someotherdomain.tld storage /var/opt/axigen/domains/someotherdomain.tld/messages/ alarm (127.9GB 74.58%)
~/scripts$
You can also find below an alternative script that will check the disk space used in percentages. This script will show an alert if the percentage of the disk space used by an Axigen storage is more or equal to the percentage you enter as a value out of the total storage available for it. This script also needs to be placed in the same folder with cli2.py.
In order to use it, add execution permission to it (chmod +x percentagestorage.py) and modify the script with your CLI listener details:
CLI_PORT=7000;
CLI_ADMIN_USER="admin";
CLI_ADMIN_PASS="your-admin-password";
Usage:
Usage: percentagestorage.py <% to check - for ex: 90%>
~/scripts$
~/scripts$ ./percentagestorage.py 90
Add a value followed by % - ex: 90%
~/scripts$
If the percentage of the storages used by the Axigen domains is not equal or higher than the value added in the command line, there will be no output:
~/scripts$
This will be the result if only one storage used (in percentage) more than the provided value:
domain example.tld storage /var/opt/axigen/domains/example.tld//messages/ alarm (4.2GB) Expandable 0.5%
~/scripts$
This storage used 0.5% out of the total size available for it.
This will be the result if multiple domain storages are used (in percentage) more than the provided value:
domain example.tld storage /var/opt/axigen/domains/example.tld/ alarm (128.0GB) Expandable 0.0%
domain example.tld storage /var/opt/axigen/domains/example.tld//objects/ alarm (128.0GB) Expandable 0.0%
domain example.tld storage /var/opt/axigen/domains/example.tld//messages/ alarm (4.2GB) Expandable 0.5%
domain localdomain.tld storage /var/opt/axigen/domains/localdomain.tld/ alarm (128.0GB) Expandable 0.0%
domain localdomain.tld storage /var/opt/axigen/domains/localdomain.tld/objects/ alarm (128.0GB) Expandable 0.0%
domain localdomain.tld storage /var/opt/axigen/domains/localdomain.tld/messages/ alarm (127.9GB) Expandable 0.0%
domain someotherdomain.tld storage /var/opt/axigen/domains/someotherdomain.tld/ alarm (128.0GB) Expandable 0.0%
domain someotherdomain.tld storage /var/opt/axigen/domains/someotherdomain.tld/objects/ alarm (128.0GB) Expandable 0.0%
domain someotherdomain.tld storage /var/opt/axigen/domains/someotherdomain.tld/messages/ alarm (127.9GB) Expandable 0.0%
~/scripts$
Note: the above steps rely on executing some python scripts. You will need to have a functional python interpreter, version 2.6 or 2.7 available on the system.
From here on, you can customize the usage of these scripts in order to achieve the desired behavior (for example, to add it to your crontab and from there make sure it sends you an email when the script provides an output).
Method #2
2. Using SNMP / Prometheus
Context info in our SNMP & Prometheus Metrics documentation page
2a. Using SNMP
You can also check the values of the storage by using SNMP.
This will be the CLI interface output to the show storage information command for domain name example.tld:
+OK: command successful
<domain#> show storageinformation
Storage Max. file size Max. file count Total Used Expandable Compaction
/var/opt/axigen/domains/example.tld/ 1048576Kb 128 7032Kb 6992Kb 134210696Kb 100.00%
/var/opt/axigen/domains/example.tld//objects/ 1048576Kb 128 7224Kb 6172Kb 134210504Kb 66.04%
/var/opt/axigen/domains/example.tld//messages/ 819200Kb 11 4608148Kb 4071460Kb 4403052Kb 61.48%
+OK: command successful
<domain#>
and this will be the result you will get via SNMP:
AXIGEN-MIB::pathDS.0 = STRING: /var/opt/axigen/domains/example.tld/
AXIGEN-MIB::maxFilesDS.0 = STRING: 128
AXIGEN-MIB::maxFileSizeDS.0 = STRING: 1048576
AXIGEN-MIB::diskSizeDS.0 = STRING: 7032
AXIGEN-MIB::usedSizeDS.0 = STRING: 6992
AXIGEN-MIB::pathOS.0 = STRING: /var/opt/axigen/domains/example.tld//objects/
AXIGEN-MIB::maxFilesOS.0 = STRING: 128
AXIGEN-MIB::maxFileSizeOS.0 = STRING: 1048576
AXIGEN-MIB::diskSizeOS.0 = STRING: 7224
AXIGEN-MIB::usedSizeOS.0 = STRING: 6172
AXIGEN-MIB::storageIndex.0 = INTEGER: 1
AXIGEN-MIB::pathMS.0 = STRING: /var/opt/axigen/domains/example.tld//messages/
AXIGEN-MIB::maxFilesMS.0 = STRING: 11
AXIGEN-MIB::maxFileSizeMS.0 = STRING: 819200
AXIGEN-MIB::diskSizeMS.0 = STRING: 4608148
AXIGEN-MIB::usedSizeMS.0 = STRING: 4071460
You can also use SNMP with third-party software like the Zabbix monitoring system and to set alerts when the size reaches a certain threshold. The configuration of Axigen's SNMP service is presented in the documentation section available at the links:
2b. Prometheus exporter HTTP endpoint, using the [server WebAdmin Listener URL]/metrics statistics
For the Prometheus exporter endpoint (/metrics), authorization is enabled by default. The administrator can disable the authorization for /metrics by setting the AXI_PROMETHEUS_USER and AXI_PROMETHEUS_PASS environment variables to an existing administrative user with reporting permissions.
When authentication is enabled (default case)
The HTTP endpoint for Prometheus exporter can only be accessed by specific administrative users, not by all authenticated administrative users. If the authentication process completes successfully, the next step, before displaying the content, is to check if the authenticated user has permission to this endpoint.
A single, server permission is required for this: "Manage Reporting".
- If the currently authenticated user has this permission, HTTP 200 is returned, and the content of the endpoint page is displayed.
- If the currently authenticated user does not have this permission, HTTP 403 is returned, and a text is displayed.
When authentication is disabled
HTTP 200 is returned, and the content of the endpoint page is displayed.
Note: The AXI_PROMETHEUS_USER and AXI_PROMETHEUS_PASS variables were introduced starting with Axigen version 10.3.3.
When these variables are set, the basic authentication needed for accessing the Prometheus metrics is bypassed internally.