mirror of
https://github.com//cppla/ServerStatus
synced 2025-12-18 21:01:38 +08:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c57044935 | ||
|
|
fdf5f03a13 | ||
|
|
05f9784b1e | ||
|
|
270c45aead | ||
|
|
2d0bdd0ab8 | ||
|
|
7e866f70cc | ||
|
|
032189e257 | ||
|
|
b05f73bb88 |
33
README.md
33
README.md
@@ -3,7 +3,6 @@
|
|||||||
* ServerStatus中文版是一个酷炫高逼格的云探针、云监控、服务器云监控、多服务器探针~。
|
* ServerStatus中文版是一个酷炫高逼格的云探针、云监控、服务器云监控、多服务器探针~。
|
||||||
* 在线演示:https://tz.cloudcpp.com
|
* 在线演示:https://tz.cloudcpp.com
|
||||||
|
|
||||||
[](https://github.com/cppla/ServerStatus)
|
|
||||||
[](https://github.com/cppla/ServerStatus)
|
[](https://github.com/cppla/ServerStatus)
|
||||||
[](https://github.com/cppla/ServerStatus)
|
[](https://github.com/cppla/ServerStatus)
|
||||||
[](https://github.com/cppla/ServerStatus)
|
[](https://github.com/cppla/ServerStatus)
|
||||||
@@ -15,29 +14,22 @@
|
|||||||
* autodeploy 自动部署.
|
* autodeploy 自动部署.
|
||||||
* clients 客户端文件
|
* clients 客户端文件
|
||||||
* server 服务端文件
|
* server 服务端文件
|
||||||
* web 网站文件
|
* web 网站文件
|
||||||
|
|
||||||
# 更新说明:
|
|
||||||
|
|
||||||
* 20200629, 优化IPv6,优化前端。注意docker默认是不支持IPv6的, 如使用docker需要手动开启ipv6
|
|
||||||
* 20200407, 网速计算不严谨,fixed
|
|
||||||
* 20190129, 降低CPU占用
|
|
||||||
* 20181221, 增加实时到三网的延迟
|
|
||||||
* 20181126, add tupd(tcp, udp, process ,thread) count for view ddcc attack
|
|
||||||
* 20180829, 网络情况:主机到三网(CU,CT,CM)每小时丢包率的检测
|
|
||||||
* 20180726, 一切皆容器额,查看自动部署或autodeploy/readme
|
|
||||||
* 20180312, 加入失联(被照顾)检测【正常:MH361, 屏蔽:MH370】,校准虚拟化流量统计异常
|
|
||||||
* 20170807, 更新平均1,5,15负载, 增加服务器总流量监控
|
|
||||||
|
|
||||||
# 自动部署:
|
# 自动部署:
|
||||||
|
|
||||||
【服务端】:
|
【服务端】:
|
||||||
```bash
|
```bash
|
||||||
|
`x86_64`: docker pull cppla/serverstatus:latest
|
||||||
|
`arm64`: docker pull cppla/serverstatus:arm
|
||||||
|
|
||||||
|
|
||||||
wget https://raw.githubusercontent.com/cppla/ServerStatus/master/autodeploy/config.json
|
wget https://raw.githubusercontent.com/cppla/ServerStatus/master/autodeploy/config.json
|
||||||
docker run -d --restart=always --name=serverstatus -v {$path}/config.json:/ServerStatus/server/config.json -p {$port}:80 -p {$port}:35601 cppla/serverstatus
|
docker run -d --restart=always --name=serverstatus -v {$path}/config.json:/ServerStatus/server/config.json -p {$port}:80 -p {$port}:35601 cppla/serverstatus:latest
|
||||||
|
|
||||||
eg:
|
eg:
|
||||||
docker run -d --restart=always --name=serverstatus -v ~/config.json:/ServerStatus/server/config.json -p 80:80 -p 35601:35601 cppla/serverstatus
|
docker run -d --restart=always --name=serverstatus -v ~/config.json:/ServerStatus/server/config.json -p 80:80 -p 35601:35601 cppla/serverstatus:latest
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
【客户端】:
|
【客户端】:
|
||||||
@@ -124,7 +116,14 @@ pip install psutil
|
|||||||
安装即可
|
安装即可
|
||||||
```
|
```
|
||||||
|
|
||||||
打开云探针页面,就可以正常的监控。接下来把服务器和客户端脚本自行加入开机启动,或者进程守护,或以后台方式运行即可!例如: nohup python client-linux.py &
|
打开云探针页面,就可以正常的监控。接下来把服务器和客户端脚本自行加入开机启动,或者进程守护,或以后台方式运行即可!例如: nohup python client-linux.py &
|
||||||
|
|
||||||
|
### 如何快速跟随系统启动呢?其实好多人都搞复杂化了
|
||||||
|
1、chmod 755 /root/client-linux.py
|
||||||
|
2、vim /etc/crontab,尾部追加
|
||||||
|
```diff
|
||||||
|
@reboot root /root/client-linux.py SERVER=$server USER=$user
|
||||||
|
```
|
||||||
|
|
||||||
# 为什么会有ServerStatus中文版:
|
# 为什么会有ServerStatus中文版:
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ USER = "s01"
|
|||||||
PORT = 35601
|
PORT = 35601
|
||||||
PASSWORD = "USER_DEFAULT_PASSWORD"
|
PASSWORD = "USER_DEFAULT_PASSWORD"
|
||||||
INTERVAL = 1
|
INTERVAL = 1
|
||||||
PORBEPORT = 80
|
PROBEPORT = 80
|
||||||
|
PROBE_PROTOCOL_PREFER = "ipv4" # ipv4, ipv6
|
||||||
|
PING_PACKET_HISTORY_LEN = 100
|
||||||
CU = "cu.tz.cloudcpp.com"
|
CU = "cu.tz.cloudcpp.com"
|
||||||
CT = "ct.tz.cloudcpp.com"
|
CT = "ct.tz.cloudcpp.com"
|
||||||
CM = "cm.tz.cloudcpp.com"
|
CM = "cm.tz.cloudcpp.com"
|
||||||
@@ -26,8 +28,13 @@ import re
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
|
import errno
|
||||||
import subprocess
|
import subprocess
|
||||||
import threading
|
import threading
|
||||||
|
try:
|
||||||
|
from queue import Queue # python3
|
||||||
|
except ImportError:
|
||||||
|
from Queue import Queue # python2
|
||||||
|
|
||||||
def get_uptime():
|
def get_uptime():
|
||||||
with open('/proc/uptime', 'r') as f:
|
with open('/proc/uptime', 'r') as f:
|
||||||
@@ -116,7 +123,7 @@ def ip_status():
|
|||||||
ip_check = 0
|
ip_check = 0
|
||||||
for i in [CU, CT, CM]:
|
for i in [CU, CT, CM]:
|
||||||
try:
|
try:
|
||||||
socket.create_connection((i, PORBEPORT), timeout=1).close()
|
socket.create_connection((i, PROBEPORT), timeout=1).close()
|
||||||
except:
|
except:
|
||||||
ip_check += 1
|
ip_check += 1
|
||||||
if ip_check >= 2:
|
if ip_check >= 2:
|
||||||
@@ -156,27 +163,38 @@ netSpeed = {
|
|||||||
|
|
||||||
def _ping_thread(host, mark, port):
|
def _ping_thread(host, mark, port):
|
||||||
lostPacket = 0
|
lostPacket = 0
|
||||||
allPacket = 0
|
packet_queue = Queue(maxsize=PING_PACKET_HISTORY_LEN)
|
||||||
startTime = time.time()
|
|
||||||
|
IP = host
|
||||||
|
if host.count(':') < 1: # if not plain ipv6 address, means ipv4 address or hostname
|
||||||
|
try:
|
||||||
|
if PROBE_PROTOCOL_PREFER == 'ipv4':
|
||||||
|
IP = socket.getaddrinfo(host, None, socket.AF_INET)[0][4][0]
|
||||||
|
else:
|
||||||
|
IP = socket.getaddrinfo(host, None, socket.AF_INET6)[0][4][0]
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
if packet_queue.full():
|
||||||
|
if packet_queue.get() == 0:
|
||||||
|
lostPacket -= 1
|
||||||
try:
|
try:
|
||||||
b = timeit.default_timer()
|
b = timeit.default_timer()
|
||||||
socket.create_connection((host, port), timeout=1).close()
|
socket.create_connection((IP, port), timeout=1).close()
|
||||||
pingTime[mark] = int((timeit.default_timer()-b)*1000)
|
pingTime[mark] = int((timeit.default_timer() - b) * 1000)
|
||||||
except:
|
packet_queue.put(1)
|
||||||
lostPacket += 1
|
except socket.error as error:
|
||||||
finally:
|
if error.errno == errno.ECONNREFUSED:
|
||||||
allPacket += 1
|
pingTime[mark] = int((timeit.default_timer() - b) * 1000)
|
||||||
|
packet_queue.put(1)
|
||||||
|
#elif error.errno == errno.ETIMEDOUT:
|
||||||
|
else:
|
||||||
|
lostPacket += 1
|
||||||
|
packet_queue.put(0)
|
||||||
|
|
||||||
if allPacket > 100:
|
if packet_queue.qsize() > 30:
|
||||||
lostRate[mark] = float(lostPacket) / allPacket
|
lostRate[mark] = float(lostPacket) / packet_queue.qsize()
|
||||||
|
|
||||||
endTime = time.time()
|
|
||||||
if endTime - startTime > 3600:
|
|
||||||
lostPacket = 0
|
|
||||||
allPacket = 0
|
|
||||||
startTime = endTime
|
|
||||||
|
|
||||||
time.sleep(INTERVAL)
|
time.sleep(INTERVAL)
|
||||||
|
|
||||||
@@ -211,7 +229,7 @@ def get_realtime_date():
|
|||||||
kwargs={
|
kwargs={
|
||||||
'host': CU,
|
'host': CU,
|
||||||
'mark': '10010',
|
'mark': '10010',
|
||||||
'port': PORBEPORT
|
'port': PROBEPORT
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
t2 = threading.Thread(
|
t2 = threading.Thread(
|
||||||
@@ -219,7 +237,7 @@ def get_realtime_date():
|
|||||||
kwargs={
|
kwargs={
|
||||||
'host': CT,
|
'host': CT,
|
||||||
'mark': '189',
|
'mark': '189',
|
||||||
'port': PORBEPORT
|
'port': PROBEPORT
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
t3 = threading.Thread(
|
t3 = threading.Thread(
|
||||||
@@ -227,7 +245,7 @@ def get_realtime_date():
|
|||||||
kwargs={
|
kwargs={
|
||||||
'host': CM,
|
'host': CM,
|
||||||
'mark': '10086',
|
'mark': '10086',
|
||||||
'port': PORBEPORT
|
'port': PROBEPORT
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
t4 = threading.Thread(
|
t4 = threading.Thread(
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ USER = "s01"
|
|||||||
PORT = 35601
|
PORT = 35601
|
||||||
PASSWORD = "USER_DEFAULT_PASSWORD"
|
PASSWORD = "USER_DEFAULT_PASSWORD"
|
||||||
INTERVAL = 1
|
INTERVAL = 1
|
||||||
PORBEPORT = 80
|
PROBEPORT = 80
|
||||||
|
PROBE_PROTOCOL_PREFER = "ipv4" # ipv4, ipv6
|
||||||
|
PING_PACKET_HISTORY_LEN = 100
|
||||||
CU = "cu.tz.cloudcpp.com"
|
CU = "cu.tz.cloudcpp.com"
|
||||||
CT = "ct.tz.cloudcpp.com"
|
CT = "ct.tz.cloudcpp.com"
|
||||||
CM = "cm.tz.cloudcpp.com"
|
CM = "cm.tz.cloudcpp.com"
|
||||||
@@ -28,6 +30,11 @@ import json
|
|||||||
import psutil
|
import psutil
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
|
import threading
|
||||||
|
try:
|
||||||
|
from queue import Queue # python3
|
||||||
|
except ImportError:
|
||||||
|
from Queue import Queue # python2
|
||||||
|
|
||||||
def get_uptime():
|
def get_uptime():
|
||||||
return int(time.time() - psutil.boot_time())
|
return int(time.time() - psutil.boot_time())
|
||||||
@@ -100,7 +107,7 @@ def ip_status():
|
|||||||
ip_check = 0
|
ip_check = 0
|
||||||
for i in [CU, CT, CM]:
|
for i in [CU, CT, CM]:
|
||||||
try:
|
try:
|
||||||
socket.create_connection((i, PORBEPORT), timeout=1).close()
|
socket.create_connection((i, PROBEPORT), timeout=1).close()
|
||||||
except:
|
except:
|
||||||
ip_check += 1
|
ip_check += 1
|
||||||
if ip_check >= 2:
|
if ip_check >= 2:
|
||||||
@@ -140,27 +147,38 @@ netSpeed = {
|
|||||||
|
|
||||||
def _ping_thread(host, mark, port):
|
def _ping_thread(host, mark, port):
|
||||||
lostPacket = 0
|
lostPacket = 0
|
||||||
allPacket = 0
|
packet_queue = Queue(maxsize=PING_PACKET_HISTORY_LEN)
|
||||||
startTime = time.time()
|
|
||||||
|
IP = host
|
||||||
|
if host.count(':') < 1: # if not plain ipv6 address, means ipv4 address or hostname
|
||||||
|
try:
|
||||||
|
if PROBE_PROTOCOL_PREFER == 'ipv4':
|
||||||
|
IP = socket.getaddrinfo(host, None, socket.AF_INET)[0][4][0]
|
||||||
|
else:
|
||||||
|
IP = socket.getaddrinfo(host, None, socket.AF_INET6)[0][4][0]
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
if packet_queue.full():
|
||||||
|
if packet_queue.get() == 0:
|
||||||
|
lostPacket -= 1
|
||||||
try:
|
try:
|
||||||
b = timeit.default_timer()
|
b = timeit.default_timer()
|
||||||
socket.create_connection((host, port), timeout=1).close()
|
socket.create_connection((IP, port), timeout=1).close()
|
||||||
pingTime[mark] = int((timeit.default_timer() - b) * 1000)
|
pingTime[mark] = int((timeit.default_timer() - b) * 1000)
|
||||||
except:
|
packet_queue.put(1)
|
||||||
lostPacket += 1
|
except socket.error as error:
|
||||||
finally:
|
if error.errno == errno.ECONNREFUSED:
|
||||||
allPacket += 1
|
pingTime[mark] = int((timeit.default_timer() - b) * 1000)
|
||||||
|
packet_queue.put(1)
|
||||||
|
#elif error.errno == errno.ETIMEDOUT:
|
||||||
|
else:
|
||||||
|
lostPacket += 1
|
||||||
|
packet_queue.put(0)
|
||||||
|
|
||||||
if allPacket > 100:
|
if packet_queue.qsize() > 30:
|
||||||
lostRate[mark] = float(lostPacket) / allPacket
|
lostRate[mark] = float(lostPacket) / packet_queue.qsize()
|
||||||
|
|
||||||
endTime = time.time()
|
|
||||||
if endTime - startTime > 3600:
|
|
||||||
lostPacket = 0
|
|
||||||
allPacket = 0
|
|
||||||
startTime = endTime
|
|
||||||
|
|
||||||
time.sleep(INTERVAL)
|
time.sleep(INTERVAL)
|
||||||
|
|
||||||
@@ -191,7 +209,7 @@ def get_realtime_date():
|
|||||||
kwargs={
|
kwargs={
|
||||||
'host': CU,
|
'host': CU,
|
||||||
'mark': '10010',
|
'mark': '10010',
|
||||||
'port': PORBEPORT
|
'port': PROBEPORT
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
t2 = threading.Thread(
|
t2 = threading.Thread(
|
||||||
@@ -199,7 +217,7 @@ def get_realtime_date():
|
|||||||
kwargs={
|
kwargs={
|
||||||
'host': CT,
|
'host': CT,
|
||||||
'mark': '189',
|
'mark': '189',
|
||||||
'port': PORBEPORT
|
'port': PROBEPORT
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
t3 = threading.Thread(
|
t3 = threading.Thread(
|
||||||
@@ -207,7 +225,7 @@ def get_realtime_date():
|
|||||||
kwargs={
|
kwargs={
|
||||||
'host': CM,
|
'host': CM,
|
||||||
'mark': '10086',
|
'mark': '10086',
|
||||||
'port': PORBEPORT
|
'port': PROBEPORT
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
t4 = threading.Thread(
|
t4 = threading.Thread(
|
||||||
|
|||||||
Reference in New Issue
Block a user