[CentOS] automated smtp server check

Tue Nov 4 22:41:36 UTC 2014
Leon Fauster <leonfauster at googlemail.com>

Am 04.11.2014 um 20:36 schrieb Frank Cox <theatre at melvilletheatre.com>:
> 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.



mon - old lady but small:

$ yum -y install epel-release ; yum install mon

$ rpm -qi mon |grep -E 'Size|Summary'
Size        : 1155876                          
Summary     : General-purpose resource monitoring system

$ rpm -ql mon | grep -E 'http|imap|smtp|pop&or$'
/usr/lib64/mon/mon.d/http.monitor
/usr/lib64/mon/mon.d/http_tppnp.monitor
/usr/lib64/mon/mon.d/imap.monitor
/usr/lib64/mon/mon.d/phttp.monitor
/usr/lib64/mon/mon.d/smtp.monitor
/usr/lib64/mon/mon.d/smtp3.monitor

$ vi /etc/mon/mon.cf

$ service mon start

$ monshow


and if you like (on EL{5,6}):

$ chkconfig mon on 


--
LF