shell監控web服務的多種方案

來源:互聯網
上載者:User

標籤:shell監控web服務的多種方案

1.連接埠

本地:ss.netstat,lsof

遠程:telnet,nmap.nc

2.本地進程數

3.header(http,curl),類比使用者的方式

4.URL(wget,curl).類比使用者的方式

5.php,java寫監控的程式,類比使用者的方式(讓開發提供)



範例判斷條件

[[email protected] ~]# lsof -i :80|wc -l    #本地連接埠  2[[email protected] ~]# nmap 127.0.0.1 -p 80    #遠程連接埠Starting Nmap 5.51 ( http://nmap.org ) at 2017-06-28 14:13 CSTNmap scan report for localhost (127.0.0.1)Host is up (0.000080s latency).PORT   STATE SERVICE80/tcp open  httpNmap done: 1 IP address (1 host up) scanned in 0.05 seconds[[email protected] ~]# nmap 127.0.0.1 -p 80|wc -l8[[email protected] ~]# nmap 127.0.0.1 -p 80|grep open|wc -l  1[[email protected] ~]# ps -ef|grep nginx |wc -l    #進程12[[email protected] ~]# culr -I -s -w "%{http_code}" -o /dev/null 127.0.0.1200      #curl[[email protected] ~]# wget --spider --timeout=10 --tries=2 127.0.0.1 &>/dev/null[[email protected] ~]# echo $?     #wget看傳回值0

案例shell

#!/bin/bashhttp_code=`culr -I -s -w "%{http_code}" -o /dev/null 127.0.0.1`if [ $http_code -ne 200 ]then  echo "web is erro"else  echo "web is ok"fi

本文出自 “小菜鳥” 部落格,請務必保留此出處http://baishuchao.blog.51cto.com/12918589/1942710

shell監控web服務的多種方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.