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 CST Nmap scan report for localhost (127.0.0.1) Host is up (0.000080s latency). PORT STATE SERVICE 80/tcp open http Nmap done: 1 IP address (1 host up) scanned in 0.05 seconds [[email protected] ~]# nmap 127.0.0.1 -p 80|wc -l 8 [[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.1 200 #curl [[email protected] ~]# wget --spider --timeout=10 --tries=2 127.0.0.1 &>/dev/null [[email protected] ~]# echo $? #wget看返回值 0
案例shell
#!/bin/bash http_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
时间: 2024-10-15 21:48:42