184 lines
2.5 KiB
Markdown
184 lines
2.5 KiB
Markdown
# 服务器监控面板
|
||
|
||
|
||
|
||
## 数据库
|
||
|
||
使用数据库存储历史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 服务器后端**
|
||
|
||
|
||
|