shell监控web服务的多种方案
1.端口
本地:ss.netstat,lsof
远程:telnet,nmap.nc
2.本地进程数
3.header(http,curl),模拟用户的方式
4.URL(wget,curl).模拟用户的方式
5.php,java写监控的程序,模拟用户的方式(让开发提供)
范例判断条件
[root@XCN~]#lsof-i:80|wc-l#本地端口2[root@XCN~]#nmap127.0.0.1-p80#远程端口StartingNmap5.51(http://nmap.org)at2017-06-2814:13CSTNmapscanreportforlocalhost(127.0.0.1)Hostisup(0.000080slatency).PORTSTATESERVICE80/tcpopenhttpNmapdone:1IPaddress(1hostup)scannedin0.05seconds[root@XCN~]#nmap127.0.0.1-p80|wc-l8[root@XCN~]#nmap127.0.0.1-p80|grepopen|wc-l1[root@XCN~]#ps-ef|grepnginx|wc-l#进程12[root@XCN~]#culr-I-s-w"%{http_code}"-o/dev/null127.0.0.1200#curl[root@XCN~]#wget--spider--timeout=10--tries=2127.0.0.1&>/dev/null[root@XCN~]#echo$?#wget看返回值0
案例shell
#!/bin/bashhttp_code=`culr-I-s-w"%{http_code}"-o/dev/null127.0.0.1`if[$http_code-ne200]thenecho"webiserro"elseecho"webisok"fi
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。