Linux Monitoring Server Scripts

Source: Internet
Author: User

#! /bin/bash

Ctime= ' Date +%x%t '
monitor_dir=/home/jk/
if [!-D $monitor _dir]; Then
mkdir $monitor _dir
Fi
CD $monitor _dir
Web_stat_log=web.status
if [!-f $web _stat_log]; Then
Touch $web _stat_log
Fi
Server_list_file=server.list
if [!-f $server _list_file]; Then
echo "' Date ' +%y-%m-%d%h:%m:%s ' ERROR: $server _list_file not exists!" >> $web _stat_log
Exit 1
Fi

For website in ' Cat $server _list_file '
Do
Url= "/http $website/index.html"
Server_status_code= ' Curl-o/dev/null-s-M--connect-timeout 10-w%{http_code} "$url" '
If ["$server _status_code" = "200"]; Then
echo "' Date ' +%y-%m-%d%h:%m:%s ' visit $website status code OK" >> $web _stat_log
Else
echo "' Date ' +%y-%m-%d%h:%m:%s ' visit $website $server _status_code error!!! Server can ' t connect at 10s or stop response at ten s, send alerm sms ... ">> $web _stat_log
echo "$website's not open for 10 seconds! # $server _status_code# "| Mail-s $ctime ***@139.com
Fi
Done
Exit 0

Linux Monitoring Server Scripts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.