check smtp command for icinga 2


This command will check if messages can be sent via smtp. It supports performance data.


You need to have msmtp installed, on systems using apt, use:

apt install msmtp

Now create a file called /etc/msmtprc, following is a basic configuration. More information can be found here

# Set default values for all following accounts.
auth           off
tls            off
logfile        /var/log/msmtp.log

account        test
port           25
user           test
password       password

account default: test

You can now test if msmtp is setup correctly as such:

echo -e "To:\nSubject: Test\n\nHello this is sending email using msmtp" | msmtp


Usage: check_smtp [OPTIONS]
  -c CRITICAL       Critical threshold for execution in milliseconds (default: 3500)
  -w WARNING        Warning threshold for execution in milliseconds (default: 2000)
  -M MESSAGE        Message to be sent (default: check_smtp message)
  -S SUBJECT        Subject to be send (default: check_smtp subject)
  -A ACCOUNT        Account to be used (default: default used in config file)
  -R RECIPIENT      Recipient E-Mail Address
  Note: msmtp requires a config file under /etc/msmtprc

Example manually defining an account:

./ -R -A test

Example setting custom message and a lower warning threshold:

./ -R -M "Custom!" -w 1500

Command Template

object CheckCommand "check-smtp" {
  command = [ ConfigDir + "/scripts/" ]
  arguments += {
    "-c" = "2500"
    "-w" = "2000"
    "-M" = "Icinga Test"
    "-S" = "Icinga Test"
    "-A" = "test"
    "-R" = ""