Setup Monit email alert using Yandex's SMTP

There are many ways to monitor a server, one of them is using Monit, a tool that will always check the services running on the server and it can send alerts when there is a problem.

Monit also has the ability to restart any service with some triggers.

Here is an example of Monit config to use Yandex’s SMTP for email alerts.

set mailserver smtp.yandex.com port 587
username "[email protected]" password "p4$W0_rD"
using sslv3

set alert [email protected]

check system vmi69564.contabo.host
if memory usage > 80% for 2 cycles then alert
if cpu usage (user) > 70% for 2 cycles then alert
if cpu usage (system) > 30% then alert
if cpu usage (wait) > 20% then alert
if loadavg (1min) > 6 for 2 cycles then alert
if loadavg (5min) > 4 for 2 cycles then alert
if swap usage > 5% then alert

check filesystem rootfs with path /
if space usage > 80% then alert

That’s it. 🙂