Hier sind mehrere Scripte nötig checkMailWrapper.sh, checkSMTP.expect und checkPOP3.expect
Dieses Script wird vom Zabbix aufgerufen
#!/bin/bash # parameters from user to connect to servers # order is VERY important SMTPSERVER=$1 SMTPSENDER=$2 SMTPRECIEVER=$3 POP3SERVER=$4 POP3USER=$5 POP3PWD=$6 START=$(date '+%s%N' | cut -b1-13) # call the smtp check and store output on $RESPONSE for further processing RESPONSE="$(/usr/local/share/zabbix/externalscripts/checkSMTP.expect $SMTPSERVER $SMTPSENDER $SMTPRECIEVER)" END=$(date '+%s%N' | cut -b1-13) # fetch msgid of the mail just sent # this is for postfix only if [ "x$(echo $RESPONSE | grep '250 2.0.0 Ok: queued as ')" != 'x' ] ; then MSGID=`echo "$RESPONSE" | grep '250 2.0.0 Ok: queued as ' | awk '{print $NF}'` [ "x$MSGID" = 'x' ] && MSGID=`echo "$RESPONSE" | grep 'OK id=' | awk -F'=' '{print $2}'` # fetch msgid for the mail just sent # this is for atmail only elif [ "x$(echo $RESPONSE | grep 'OK id=')" != 'x' ] ; then MSGID=`echo "$RESPONSE" | grep 'OK id=' | awk -F'=' '{print $2}'` else echo 0 && exit 1 fi # check if we have a msgid # connect to given pop3 server and check login and mailbox status if [ "x$MSGID" != 'x' ] ; then POP3="$(/usr/local/share/zabbix/externalscripts/checkPOP3.expect $POP3SERVER $POP3USER $POP3PWD)" [ "x$(echo $POP3 | grep -i '+OK logged in')" != 'x' ] && echo $(($END - $START)) && exit 0 # return an error if anything goes wrong echo 0 && exit 1 fi # return an error if the script comes until here echo 0 && exit 1
#!/usr/bin/expect -f
set SERVER [lrange $argv 0 0]
set SENDER [lrange $argv 1 1]
set RECIEVER [lrange $argv 2 2]
spawn telnet $SERVER 25
expect "220*"
send "EHLO zab1.datapark.ch\r"
expect "250*"
send "MAIL FROM: <$SENDER>\r"
expect "250*"
send "RCPT TO: <$RECIEVER>\r"
expect {
"250*" {
send "RSET\r"
expect "250*"
send "QUIT\r"
expect "221*"
expect eof
exit
send "DATA\r"
}
"450*" {
send "RSET\r"
expect "250*"
send "QUIT\r"
expect "221*"
expect eof
exit 1
}
"550*" {
send "RSET\r"
expect "250*"
send "QUIT\r"
expect "221*"
expect eof
exit 1
}
}
expect {
"354*" {
send "From: <$SENDER>\r"
send "To: <$RECIEVER>\r"
send "Date: [exec date -R]\r"
send "Subject: Beim naechsten Ton ist es [exec date +%R]\r\r"
send "[exec date -R]\r"
send ".\r"
}
"450*" {
send "RSET\r"
}
}
expect "250*"
send "QUIT\r"
expect "221*"
expect eof
#!/usr/bin/expect
set SERVER [lrange $argv 0 0]
set USER [lrange $argv 1 1]
set PASS [lrange $argv 2 2]
spawn /usr/bin/openssl s_client -quiet -connect $SERVER:995
expect "+OK*"
send "USER $USER\r"
expect "+OK*"
send "PASS $PASS\r"
expect "+OK*"
send "STAT\r"
expect {
"+OK*" {
send "DELE 1\r"
expect "+OK*"
send "QUIT\r"
expect "+OK*"
exit
}
}
exit
An unforeseen error has occured. This is most likely a bug somewhere. It might be a problem in the discussion plugin.
More info has been written to the DokuWiki error log.