heartbeat/README.md
2023-09-05 15:27:38 +08:00

53 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# heartbeat
用python写的简易心跳工具配合Uptime-kuma的被动监控功能当然你也可以自己实现服务端实现监测PC客户端的运行情况。
## 运行效果
通过访问连接服务端会实现被动检测。同时本地访问结果会回显记录在heartbeat.log如果服务端异常可以通过返回的代码进行故障排查。
## 使用方法
### 下载程序:
1. 下载[最新的版本](https://github.com/yshtcn/heartbeat/releases)。
2. 解压缩到任意目录
### 编辑配置文件:
运行前,记得打开把[config.Exsample.ini配置文件](https://github.com/yshtcn/heartbeat/blob/main/config.Exsample.ini)复制一份改名为config.ini并打开配置接收心跳包的服务器地址。
如果不存在config.ini直接运行程序程序会将config.Exsample.ini范例配置自动复制一份。
### 日志文件
心跳日志会存放在heartbeat.log包括时间和返回值。例如下面是一个返回200正常值的日志
```
2023-08-04 11:46:15.306916 Ping: 8ms. Final URL: http://example.com/heartbeat?ping=8. Response status code: 200
```
## 执行python源代码
如果你需要直接使用源代码,可能需要用到以下几个步骤:
### 确保安装Python
可以从[这里下载最新的python环境](https://python.org/downloads/release/)。
### 安装必要的python库
使用命令行执行以下命令:
···
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pystray pillow requests configparser PySocks
···
### 写一个批处理方便执行
每次使用py命令并不方便可以把以下内容保存为bat文件。
```
@echo off
@echo heartbeat start
cd /d %~dp0
py heartbeat.py
pause
```
### 写一个批处理方便执行(静默)
如果希望后台运行可以把以下内容保存为bat文件执行。
```
@echo off
cd /d %~dp0
start pythonw heartbeat.py
```