Register
It is currently Thu Jul 31, 2014 3:37 pm

[REQUEST]Bash Script check website with Email


All times are UTC - 6 hours


Post new topic Reply to topic  [ 6 posts ] 
Author Message
 PostPosted: Tue Jan 31, 2012 11:54 pm   

Joined: Tue Jan 31, 2012 11:35 pm
Posts: 2
Hello.

I newbie about that. I want bash script check website status with email alert. Please help me..

Thanks.


Top
 Profile  
 PostPosted: Wed Feb 01, 2012 8:10 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 664
Location: Des Moines, Iowa
Gonna need alot more info than that to help...


Top
 Profile WWW  
 PostPosted: Wed Feb 01, 2012 8:35 pm   

Joined: Tue Jan 31, 2012 11:35 pm
Posts: 2
I want script to check website problem. Example if website cannot open but server stay runner just web cannot open. Sample this software http://www.integrio.net/products.html but i want simple check. This product windows only.. i want use in linux centos. If website problem he will sent email. Sorry for my bad english hope u understand..

Thanks


Top
 Profile  
 PostPosted: Mon Mar 05, 2012 11:32 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 664
Location: Des Moines, Iowa
If you want to monitor a server, you can look into Nagios.


Top
 Profile WWW  
 PostPosted: Fri Mar 09, 2012 12:04 pm   
Moderator
User avatar

Joined: Wed May 03, 2006 2:05 pm
Posts: 242
Hi arif5303!

Here's an alternative to Nagios that may be closer to what you're looking for. It's a fairly simple server/service monitor with a web based interface. phpservermon

If you really want to do something simple for yourself though, I say go for it! Where are you stuck? Do you just need a starting point, or do you have something written that isn't working the way you like?

EDIT: I never posted the link! Also, here's a simple port monitoring script using 'netcat':
Code:
## The host we want to monitor
host=yourdomain.com

## The email that receives alerts
addy=youremail@somemailhost.net

## The ports we want to check
ports="80 25 53 443 143 110"

## For each port number...
for port in $ports; do

    ## See if we can make a connection
    if ! nc -z $host $port; then

        ## Make a list of dead ports
        down="${down} $port"

    fi

done

## If there are any dead ports
## (if $down is not emtpy)
if [ -n "$down" ]; then

    ## Send an email
    echo "Unresponsive ports: $down" | mail -s "Port monitor alert!" $addy

fi


Top
 Profile YIM  
 PostPosted: Sat Mar 17, 2012 5:45 pm   
User avatar

Joined: Fri Jul 22, 2011 5:39 pm
Posts: 46
Code:
#!/bin/bash
# Written by jj@domain.com
# Monitors an IIS server and emails the Admin if the
# server reports anything other than "Microsoft-IIS"
# http://bashscripts.org/forum/viewtopic.php?f=16&t=1522
# Last Edited on Thu Dec 29, 2011 - 10:11:40 PM EST
###
# set -x # debug method
MAIL_ME="jj@domain.com"
MAIL_SUBJECT="Norveld_Server_needs_attention"
SERVER_DATE=$(TZ=PST8PDT date "+%a %b %d %I:%M:%S %p %Z")
LOCAL_DATE=$(date +%c)

# store this in a variable
IIS=$(curl -Is http://xxx.xxx.xxx.xxx | \grep -E '^Server' | cut -c9-21)
echo "$SERVER_DATE" - Web Server Check = "$IIS" >> /home/jj/Documents/cirrhus9/Accounts/Norveld/3WeekTest/norveld.test

if [ "$IIS" = "Microsoft-IIS" ] ; then
exit 0*/1 * * * * /home/jj/Documents/cirrhus9/Accounts/Norveld/3WeekTest/norveldchk2.sh > /dev/null 2>&1
else
echo "Norveld_Server_Check - FAILED" on "$LOCAL_DATE" | mail "$MAIL_ME" -s "$MAIL_SUBJECT"
exit 1
fi
#EOF

Set a cron:


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP