Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

check_exchange_webmail.sh

Rating
0 votes
Favoured:
0
Hits
103411
Files:
FileDescription
check_exchange_webmail.shcheck_exchange_webmail.sh
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
This is a bash shell script that checks to see if it can access webmail provided by exchange. -> check_exchange_webmail.sh
#! /bin/bash

# VERSION 0.5
# This script checks to see if it can access webmail provided by exchange
# At current, it only outputs OK or CRITICAL
# Checked On: (If it works for you, please let me know so I can add it to the list)
# - Exchange 2003 / Server 2003 R2 Standard

# 1. First create a new email for performing your checks
# 2. Send an email to your new email address with a 'key' in the subject
# (The 'key' variable below must match your key you sent EXACTLY)
# 3. Create a temp profile in Outlook and log into your check account
# (I found I had to log into Outlook BEFORE I could log in via webmail.)
# 4. Copy this script to your libexec folder and name it 'check_exchange_webmail.sh'
# (Mine is located: /usr/local/nagios/libexec)
# 5. chmod 755 /usr/local/nagios/libexec/check_exchange_webmail.sh (or wherever you put it)
# 6. Change the below variables 'user', 'pass', & 'key' to reflect your setup
# 7. Save and verify it works by running the script
# (/usr/local/nagios/libexec/check_exchange_webmail.sh [server ip]
# 8. If it works, create a new command for it in 'commands.cfg'
# Example:
# define command{
# command_name check_exchange_webmail
# command_line $USER1$/check_exchange_webmail.sh $HOSTADDRESS$
# }
# 9. Create a new service in 'services.cfg' (Or wherever your services are)
# Example:
# define service{
# use generic-service
# host_name [your hostname]
# service_description WEBMAIL
# check_command check_exchange_webmail
# }
# 10. Run the nagios check. Mine is:
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
# 11. If it shows everything ok, restart nagios
# /etc/init.d/nagios restart

user="[user]"
pass="[pass]"
key="[key]"


gtc=`curl -s -k -u $user:$pass https://$1/exchange/$user/Inbox/?Cmd=contents&Page=1`

chc=`echo "$gtc" | grep $key | cut -d" " -f1 | cut -d">" -f1 | cut -d"<" -f2`
ins=`echo "$chc" | sed s/^/FOUND/g`

if [ $ins = FOUNDTABLE ]
then
echo "OK - FOUND KEY: $key"
exit 0
else
echo "CRITICAL - CRAP, SOMETHING HAPPENED"
exit 2
fi