[CentOS] automated smtp server check

José María Terry Jiménez jtj at tssystems.net
Tue Nov 4 19:49:53 UTC 2014


El 04/11/14 a las 20:36, Frank Cox escribió:
> I would like to set up a cron job to automatically check whether my mailserver and webserver are up, and tell me if they're not.
>
> This script tells me if my webserver is up:
>
> #!/bin/bash
> wget -q --tries=10 --timeout=20 --spider http://melvilletheatre.com
> if [[ $? -eq 0 ]]; then
>          echo "Online"
> else
>          echo "Offline"
> fi
>
> How can I do the something similar with my mailserver?
>
> Or if someone knows of an integrated tool that will monitor this in a better way (whatever that may be), I'm more than interested.
>
Hello

I use Nmap to test if a server up in a port:

$ nmap -p587 a.mail.server |grep -i 587

587/tcp open  submission

Or several ports:

$ nmap -p25,143,587 a.mail.server |grep -i open
25/tcp  open  smtp
143/tcp open  imap
587/tcp open  submission

If the server is working, the port is shown as open. You can parse it as 
desired to message you as you want

Best



More information about the CentOS mailing list