My monitoring script

Source: Internet
Author: User

1

#! /Bin/bash
PID = 'ps-Ef | grep tomcat8082 | grep-V grep | WC-l'
Port = 'netstat-anplt | grep 8082 | WC-l'
Path =/usr/tomcat/tomcat8082/bin/startup. Sh
If [$ pid = 1-A $ port-EQ 1]; then
Echo "Tomcat is running"
Else
Echo "tomcat8082 is stoped and now let's run it"
Sleep 3
Echo "now restart tomcat8082"
[-X $ path] & SH $ PATH>/dev/null 2> & 1 & status = "sucess" | status = "failure"
Sleep 5
PID = 'ps-Ef | grep tomcat8082 | grep-V grep | WC-l'
Port = 'netstat-anplt | grep 8082 | WC-l'
Pid8082 = 'ps-Ef | grep tomcat8082 | grep-V grep | awk '{print $2 }''
If [$ PID-ne 1-A $ port-ne 1]; then
While true
Do
Kill-9 $ pid8082
[$? -EQ 0] & break
Sleep 1
Done
[-X $ path] Sh $ Path & status = "success" | status = "failure"
Fi
Fi
~

2 #! /Bin/bash
Port = 'netstat-anplt | grep httpd | WC-l'
Process = 'ps-Ef | grep httpd | WC-l'
Path =/etc/init. d/httpd
If [$ port-EQ 1-A $ process-GT 1]; then
Echo "HTTP is running"
Else
Echo "HTTP is stopping, do you want to start httpd? "
Read-P "start [1] \ t not start [2]:"
[$ A-EQ 1] & [-x $ path] & $ PATH start
If [$ port-ne 1-o $ process-LE 1]; then
While true
Do
Pkill httpd
[$? -EQ 0] & break
Done
[-X $ path] & $ PATH start
Fi
[$ A-EQ 2] & Exit
Fi ~

3

#! /Bin/bash
# Stat = 'nmap 192.168.0.200-P 80 | grep open | WC-l'
IP = 192.168.0.200
Wget-T 10-Q 192.168.0.200
If [$? -EQ 0]; then
Echo "the HTTPd service of $ IP is running"
Else
/Etc/init. d/httpd start
Fi
~

4

#! /Bin/bash
# Stat = 'nmap 192.168.0.200-P 80 | grep open | WC-l'
[-F/etc/init. d/functions] &./etc/init. d/functions | Exit 1
Httpcode = 'curl-I-s 192.168.0.200 | head-1 | awk '{print $2 }''
If ["$ httpcode" = "200"]; then
Action "HTTP is running."/bin/true
Else
Action "HTTP is not running."/bin/false
Sleep 1
/Etc/init. d/httpd Start>/dev/null &&\
Action "nginx is started."/bin/true
Fi
~

My monitoring script

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.