https://github.com/nonebot/plugin-status
https://github.com/nonebot/plugin-status
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/nonebot/plugin-status
- Owner: nonebot
- License: mit
- Created: 2024-03-04T04:43:57.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-04T06:56:14.000Z (about 2 years ago)
- Last Synced: 2024-04-14T09:04:13.462Z (almost 2 years ago)
- Language: Python
- Size: 83 KB
- Stars: 7
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nonebot-plugin-status
_✨ NoneBot 服务器状态(CPU, Memory, Disk Usage)查看插件 ✨_
## 使用方式
通用:
- 发送 Command `状态` 或者 `status`
OneBot:
- 向机器人发送戳一戳表情
- 双击机器人头像戳一戳
## 配置项
> [!WARNING]
> GitHub 仓库中的文档为最新 DEV 版本,配置方式请参考 [PyPI](https://pypi.org/project/nonebot-plugin-status/) 上的文档。
配置方式:直接在 NoneBot 全局配置文件中添加以下配置项即可。
### server_status_enabled
- 类型:`bool`
- 默认值:`True`
- 说明:是否启用服务器状态查看功能
### server_status_truncate
- 类型:`bool`
- 默认值:`True`
- 说明:是否启用模板变量按需注入功能(节约时间)
### server_status_only_superusers
- 类型: `bool`
- 默认: `True`
- 说明: 是否仅允许超级用户使用
> 超级用户需在配置文件中如下配置:
>
> ```dotenv
> SUPERUSERS=["your qq id"]
> ```
### server_status_template
- 类型: `str`
- 默认: 请参考示例
- 说明:发送的消息模板,支持的方法、变量以及类型如下:
- relative_time (`Callable[[datetime], timedelta]`): 获取相对时间
- humanize_date (`Callable[[datetime], str]`): [人性化时间](https://python-humanize.readthedocs.io/en/latest/time/#humanize.time.naturaldate)
- humanize_delta (`Callable[[timedelta], str]`): [人性化时间差](https://python-humanize.readthedocs.io/en/latest/time/#humanize.time.precisiondelta)
- cpu_usage (`float`): CPU 使用率
- per_cpu_usage (`List[float]`): 每个 CPU 核心的使用率
- memory_usage (`svmem`): 内存使用情况,包含 total, available, percent, used, free(, active, inactive, buffers, cached, shared) 属性
- swap_usage (`sswap`): 内存使用情况,包含 total, used, free, percent, sin, sout 属性
- disk_usage (`Dict[str, psutil._common.sdiskusage]`): 磁盘使用率,包含 total, used, free, percent 属性
- uptime (`datetime`): 服务器运行时间
- runtime (`datetime`): NoneBot 运行时间
- bot_connect_time (`Dict[str, datetime]`): 机器人连接时间
配置文件示例(默认模板)
```dotenv
SERVER_STATUS_TEMPLATE='
CPU: {{ "%02d" % cpu_usage }}%
Memory: {{ "%02d" % memory_usage.percent }}%
Runtime: {{ runtime | relative_time | humanize_delta }}
{% if swap_usage.total %}Swap: {{ "%02d" % swap_usage.percent }}%{% endif %}
Disk:
{% for name, usage in disk_usage.items() %}
{{ name }}: {{ "%02d" % usage.percent }}%
{% endfor %}
'
```
