This is my second blog for testing weblogin the first one was for testing moodle https://xeois.com/blog/moodle-check-web-login-script and this one is for Zimbra. I have written a custom script which I want to share with you that helps us check the login in Zimbra and escalate it via Nagios in case it fails. Some users ask me if they are using Nagios they can easily monitor all the services for zimbra and i totally agree with them. But not everyone is having the same level of knowledge as you geeks are having. This script can be easily used with nagios or without nagios for your convenience. You can take of the highlighted part of the script to remove the nagios bit out of it. You may have to modify the script if you are not using it for nagios for escalation type you want to use. The answer is as simple as to make sure all the service Zimbra depends upon are functioning properly like (mysql, ldap, webserver, postfix etc). Please find the script below to check the Zimbra login.
We will use curl to check the web login for zimbra.
#removes any cookies
rm -f /tmp/$2
#create a cookie entry in the cookie file for that site
curl -b $2 -c /tmp/$2 $1 > /dev/null
#gets the auth token in cookies
curl -b /tmp/$2 -c /tmp/$2 “$1/zimbra/?loginOp=login&username=$3&password=$4” > /dev/null
#use the cookie files to lookup the address book for firstname.lastname@example.org
curl –cookie /tmp/$2 –data “zimbra/h/search?sq=$3&st=contact&search=Search” $1 | grep $3@$5 >/dev/null
if [fusion_builder_container hundred_percent=”yes” overflow=”visible”][fusion_builder_row][fusion_builder_column type=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none”][ $? -eq 0 ]; then
/bin/echo “OK: Authentication Successfull \n”
elif [ $? -eq 1 ]; then
/bin/echo ” Critical: Authentication Failure \n”
Please feel free to contact for more information and do give us your feedback.[/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]