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 ~]# 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
[root@XCN ~]# nmap 127.0.0.1 -p 80|wc -l
8
[root@XCN ~]# nmap 127.0.0.1 -p 80|grep open|wc -l  
1
[root@XCN ~]# ps -ef|grep nginx |wc -l    #进程
12
[root@XCN ~]# culr -I -s -w "%{http_code}" -o /dev/null 127.0.0.1
200      #curl
[root@XCN ~]# wget --spider --timeout=10 --tries=2 127.0.0.1 &>/dev/null
[root@XCN ~]# 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