[hobbit] Monitoring SMTP Relay server using hobbit
Alexander Bech
alex at bakarasse.de
Sat Dec 19 15:36:12 CET 2009
Balasubramaniam Natarajan schrieb:
> Hi
>
> I have two Windows 2003 server which works as SMTP relay server.
>
> What are the key parameter of the server should I monitor from Xymon.
>
> I want to check certain parameters like
>
> 1. If the Mail server is accepting mails.
> 2. If the Mail Server is able to relay it to the next server.
> 3. Is my Mail relaying server free from open relaying and stuffs,
>
> How could I achieve all these using Xymon? I have BBNT "An NT/W2K
> **CLIENT** for Big Brother System & Network Monitor Version 1.08d" on
> all the Windows 2003 servers.
Hi,
for 1 and 3 you can use a server-side script using expect:
file expect-smtp
###################
#!/usr/bin/expect
set mailserver [lrange $argv 0 0]
set from [lrange $argv 1 1]
set to [lrange $argv 2 2]
set timeout 90
spawn telnet $mailserver 25
expect "failed" {
send_user "$mailserver: connect failed\n"
exit
} "2?? *" {
} "4?? *" {
exit
} "refused" {
send_user "$mailserver: connect refused\n"
exit
} "closed" {
send_user "$mailserver: connect closed\n"
exit
} timeout {
send_user "$mailserver: connect to port 25 timeout\n"
exit
}
send "HELO server.isp.de\r"
expect "2?? *" {
} "5?? *" {
send_user "=== $mailserver: HELO 5??\n"
exit
} "4?? *" {
send_user "=== $mailserver: HELO 4??\n"
exit
}
send "MAIL FROM: <$from>\r"
expect "2?? *" {
} "5?? *" {
exit
} "4?? *" {
exit
}
send "RCPT TO: <$to>\r"
expect "2?? *" {
set smtpcode "2xx"
send_user "smtpcode = $smtpcode\n"
} "5?? *" {
set smtpcode "5xx"
send_user "smtpcode = $smtpcode\n"
exit
} "4?? *" {
set smtpcode "4xx"
send_user "smtpcode = $smtpcode\n"
exit
}
send "RSET\r"
send "QUIT\r"
exit
#########################
I call it from server-side shell-script mailserver-verify.sh
for a list of mailservers.
(in my case: check rejecting invalid recipients during the SMTP protocol)...
...
TEXT=$(${BBHOME}/ext/expect-smtp ${IP} verify at isp.de
non-existent-address@${DOMAIN})
...
220 server03.domain.de Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959 ready at Sat, 19 Dec 2009 14:57:09 +0100
HELO relay.isp.de
250 server03.domain.de Hello [10.224.138.110]
MAIL FROM: verify at isp.de
250 2.1.0 verify at isp.de....Sender OK
RCPT TO: non-existent-address at domain.de
550 5.1.1 User unknown
smtpcode = 5xx
... evaluate the line "smtpcode =" in ${TEXT},
and sent a message to xymon-server.
Regards,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20091219/ac9c4fd3/attachment.html>
More information about the Xymon
mailing list