diff options
author | Kyomotoi <[email protected]> | 2022-04-05 15:19:45 +0800 |
---|---|---|
committer | Kyomotoi <[email protected]> | 2022-04-05 15:27:21 +0800 |
commit | 76cfd49f4129702ac9694077adb7529e390a2957 (patch) | |
tree | 56df622d15b5d6169ca912ff0df75d6cf3880a8d | |
parent | d7176305b5658db05d2e2713c4b389d2081e3b51 (diff) | |
download | ATRI-76cfd49f4129702ac9694077adb7529e390a2957.tar.gz ATRI-76cfd49f4129702ac9694077adb7529e390a2957.tar.bz2 ATRI-76cfd49f4129702ac9694077adb7529e390a2957.zip |
🚸 提高自身状态可观性
-rw-r--r-- | ATRI/plugins/status/data_source.py | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/ATRI/plugins/status/data_source.py b/ATRI/plugins/status/data_source.py index 68ad216..3595c0c 100644 --- a/ATRI/plugins/status/data_source.py +++ b/ATRI/plugins/status/data_source.py @@ -8,6 +8,21 @@ from ATRI.rule import is_in_service from ATRI.exceptions import GetStatusError +_status_msg = """ +> Status Overview + +[CPU: {cpu}%] +[Memory: {mem}%] +[Disk usage: {disk}%] + +[Net sent: {inteSENT}MB] +[Net recv: {inteRECV}MB] + +[Runtime: {up_time}] +{msg} +""".strip() + + class IsSurvive(Service): def __init__(self): Service.__init__(self, "状态", "检查自身状态", rule=is_in_service("状态")) @@ -52,14 +67,14 @@ class IsSurvive(Service): log.info("资源占用正常") is_ok = True - msg0 = ( - "Self status:\n" - f"* CPU: {cpu}%\n" - f"* MEM: {mem}%\n" - f"* DISK: {disk}%\n" - f"* netSENT: {inteSENT}MB\n" - f"* netRECV: {inteRECV}MB\n" - f"* Runtime: {up_time}\n" - ) + msg + msg0 = _status_msg.format( + cpu=cpu, + mem=mem, + disk=disk, + inteSENT=inteSENT, + inteRECV=inteRECV, + up_time=up_time, + msg=msg, + ) return msg0, is_ok |