I don't know what the "Simple" smtp-check does.
All I know is that it triggers more than it should and it doesn't support SSL.
I therefore wrote this small external script. Most of the work is done by "swaks". You can easily install it with yum or apt-get (apt-get install swaks).
cat /usr/local/sbin/smtpup
All I know is that it triggers more than it should and it doesn't support SSL.
I therefore wrote this small external script. Most of the work is done by "swaks". You can easily install it with yum or apt-get (apt-get install swaks).
Code:
Item
Email (SMTP) server
external
smtpup[ {HOST.CONN1 ]
interval 60s
Show value "Service State"
Code:
mkdir /etc/zabbix/external ln -s /usr/local/sbin/smtpup /etc/zabbix/external/smtpup
Code:
#!/bin/bash
export PATH=${PATH}:/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin
# Script mainly used for Zabbix (http://www.zabbix.com) to check if an SMTP-server is up
# Zabbix itself has an smtp-check function, but due to its nature it gives many false positives.
# This script, mainly because it uses swaks, has a dialogue with the SMTP-server that's comparable
# with a real-life SMTP-session. It says Hello (HELO) and then the SMTP-server tells the things he
# understands. This script then gives a QUIT, because it just wants to test if the server is working#
# Put the script in /usr/local/sbin and make a symbolic link in /etc/zabbix/externalscripts
#
# ln -s /usr/local/sbin/smtpup /etc/zabbix/externalscripts/smptup
#
# The latter is important because it needs this to differentiate between executing it from
# command-line and executing it from zabbix (zabbix gives an extra parameter)
#
# An item in zabbix is like this:
#
# Description: Email (SMTPAUTH) server is responding
# Type: external check
# Key: smtpup[ {HOST.CONN1} 587 ]
# Type of information: Numeric (unsigned)
# Data type: Decimal
# Update interval: 60
# Show value: Service state
# This Zabbix' workaround will lose the first paramater when executed from
# /etc/zabbix/externalscripts/
echo "${BASH_SOURCE}" | grep -q "zabbix" && shift 1
# Server
OPTIONS=
SERVER="$1"
PORT="$2"
# CONSTANTS
RETURN=0
QUITON=HELO
REPLY='^<. *250'
TIMEOUT=5
# Put your Internet FQDN-address here.
# If your IP also has its reverse DNS to that same FQDN it is even better.
# HELO=smtp.yourdomain.com
HELO=
[ -z "${HELO}" ] || OPTIONS="${OPTIONS} --helo ${HELO}"
if [ ! -z "${SERVER}" ] ; then
[ -z ${PORT} ] && PORT=25
[ "${PORT}" = "465" ] && OPTIONS="${OPTIONS} -tlsc"
swaks ${OPTIONS} -q ${QUITON} -p ${PORT} --timeout ${TIMEOUT} -s ${SERVER} 2>/dev/null | grep -q "${REPLY}" && RETURN=1
fi
echo "$RETURN"
Comment