Ping the router (not protected by UPS) to shutdown the server.
272
路由器放在UPS保护之外,ping不通路由器,用来判断是否断电了,如果重试间隔*重试时间 没有恢复网络,则执行关机。
version: '3.8'
name: network-ups
services:
network-ups:
image: noahyann/network-ups:latest
container_name: network-ups
restart: unless-stopped
pid: host # 共享宿主机 PID 命名空间 (nsenter)
privileged: true # 操作宿主机机的权限
network_mode: bridge # 不创建堆栈子网
volumes:
- /etc/localtime:/etc/localtime:ro # 解决日志时区问题
environment:
- TARGET_IP=192.168.10.1 # 监控的路由器 IP
- RETRY_INTERVAL=30 # 重试间隔(秒)
- MAX_RETRIES=10 # 最大连续失败次数 10x30=300s=5min
- SUCCESS_SLEEP=120 # 成功 ping 后的休眠时间(秒)2min
- DEBUG_FLAG=false # 调试开关,false=失败关机 true=失败写log到/tmp
version: '3.8'
name: network-ups
services:
network-ups:
image: noahyann/network-ups:latest
container_name: network-ups
restart: unless-stopped
pid: host # 共享宿主机 PID 命名空间 (nsenter)
privileged: true # 操作宿主机机的权限
network_mode: bridge # 不创建堆栈子网
volumes:
- /etc/localtime:/etc/localtime:ro # 解决日志时区问题
environment:
- TARGET_IP=192.168.10.1 # 监控的路由器IP,调试可用不存在的IP或者临时断网
- RETRY_INTERVAL=30 # 重试间隔(秒)
- MAX_RETRIES=2 # 最大连续失败次数 2x30=60s=1min
- SUCCESS_SLEEP=60 # 成功 ping 后的休眠时间(秒)1min
- DEBUG_FLAG=true # 调试开关,false=失败关机 true=失败写log到/tmp
Content type
Image
Digest
sha256:60b6682bf…
Size
5.2 MB
Last updated
6 months ago
docker pull noahyann/network-ups