- Real-time usage check: Fetches the current mail usage from the SMTP2Go API
- Configurable thresholds: Set custom warning and critical percentage thresholds
- Performance data output: Returns Icinga-compatible performance data for both absolute mail usage and percentage utilization
- Python 3
- requests Python library (install with
pip install requests
)
- Make sure Python 3 is installed on your monitoring server
- Install the
requests
library if not already present:pip3 install requests
- Download or clone this repository and place the script in the plugins folder
git clone https://github.com/StratoGh0st99/check_smtp2go_usage.git cd check_smtp2go_usage cp check_smtp2go_usage.py /usr/lib/nagios/plugins/
- Make the script executable.
chmod +x /usr/lib/nagios/plugins/check_smtp2go_quota.py
./check_smtp2go_quota.py --api-key YOUR_API_KEY --warn 80 --crit 90
-a / --api-key (required): Your SMTP2Go API key
-w / --warn (required): Warning threshold in percent (e.g. 80 for 80%)
-c / --crit (required): Critical threshold in percent (e.g. 90 for 90%)
OK - 200 of 1000 mails used (20.00%) | mails_used=200;800;900;0;1000 usage_percent=20.00%;80;90;0;100
- Define the CheckCommand in Icinga2
object CheckCommand "check_smtp2go_quota" { import "plugin-check-command" command = [ "/usr/lib/nagios/plugins/check_smtp2go_quota.py" ] arguments = { "--api-key" = "$smtp2go_api_key$" "--warn" = "$smtp2go_warn$" "--crit" = "$smtp2go_crit$" } }
- Apply the service to a host
apply Service "smtp2go-quota" { import "generic-service" check_command = "check_smtp2go_quota" vars.smtp2go_api_key = "YOUR_API_KEY" vars.smtp2go_warn = "80" vars.smtp2go_crit = "90" assign where host.name == "myhost" }
- Reload Icinga2
systemctl reload icinga2