Computer_status/README.md
2024-12-18 10:37:23 +08:00

184 lines
2.5 KiB
Markdown
Raw Permalink 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.

# 服务器监控面板
## 数据库
使用数据库存储历史30天的数据每隔一秒储存一次
数据库存储:对象数据库
采用本地db文件相对路径
数据对象Computer_status
## 数据操作文件
文件名称Computer_status
### 数据对象
类名 Computer_status
time:时间戳单位s
ram_all:所有内存
ram_use:已占用内存
cpu_use:cpu占用比如50% 记作50
cpu_c:cpu温度
disk:记录磁盘,例如{'磁盘1':[容量,已用容量,io读,io写],'磁盘2':[容量,已用容量,io读,io写]} (单位kb)
web:记录网络流量,例如{网口1:[上传,下载],'网口2':[上传,下载]} 单位kbps
gpu:记录显卡信息,字典{'显卡名称':显卡信息,'显卡名称':显卡信息}
显卡信息(字典){
gpu_ram_all:gpu显存容量GB
gpu_ram_use:gpu显存使用GB
gpu_use:gpu占用比如50% 记作50
gpu_fan:风扇占用比如50% 记作50
}
构造函数:
Computer_status(time,ram_all,ram_use,cpu_use,cpu_c,disk,web,gpu)
### 数据读取方法
获取最新30s信息
方法名称get_data_30s
参数:无
返回Computer_status集合
获取指定时间戳到指定时间戳信息
方法名称get_data
参数:{
time_start
类型 int
备注:开始时间
time_end
类型 int
备注:结束时间
}
返回Computer_status集合
获取最新30s信息
方法名称get_data_json_30s
参数:无
将Computer_status集合根据时间排序升序转为json
返回json
获取指定时间戳到指定时间戳信息
方法名称get_data_json
参数:{
time_start
类型 int
备注:开始时间
time_end
类型 int
备注:结束时间
}
将Computer_status集合根据时间排序升序转为json
返回json
### 数据写入方法
写入一条数据
方法名称write_data
参数:{
名称computer_status
类型Computer_status
备注:数据对象
}
### 数据删除方法
删除time_start之前的数据
方法名称delete_data
参数:{
time_start
类型 int
备注:开始时间
}
## 数据存储部分
每隔一秒读取电脑状态打包成Computer_status对象,调用Computer_status.write_data
## web端部分
展示Computer_status对象中的状态以时间为轴绘制折线图
可以选择实时展示每隔1s发送请求服务器调用Computer_status.get_data_json_30s返回json
可以选择查看指定时间端的历史信息,发送请求,包含开始时间和结束时间服务器调用Computer_status.get_data_json返回json
### **Web 前端**
### **Python 服务器后端**