目录位置及容量
This commit is contained in:
parent
d52157a222
commit
04b9f39fb9
@ -1,15 +1,39 @@
|
|||||||
|
import os.path
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
|
import psutil
|
||||||
from flask import Blueprint, jsonify
|
from flask import Blueprint, jsonify
|
||||||
|
|
||||||
|
from config import DANMAKU_FACTORY_EXEC, FFMPEG_EXEC, BILILIVE_RECORDER_DIRECTORY, XIGUALIVE_RECORDER_DIRECTORY
|
||||||
from util.system import check_exec
|
from util.system import check_exec
|
||||||
from config import DANMAKU_FACTORY_EXEC, FFMPEG_EXEC
|
|
||||||
|
|
||||||
blueprint = Blueprint("api_collector", __name__, url_prefix="/api/collector")
|
blueprint = Blueprint("api_collector", __name__, url_prefix="/api/collector")
|
||||||
|
|
||||||
|
|
||||||
|
def _get_disk_info(path):
|
||||||
|
if os.path.isdir(path):
|
||||||
|
disk_info = psutil.disk_usage(path)
|
||||||
|
return {
|
||||||
|
'exist': True,
|
||||||
|
'percent': disk_info.percent,
|
||||||
|
'free': disk_info.free / (1024 ** 2),
|
||||||
|
'total': disk_info.total / (1024 ** 2)
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
return {
|
||||||
|
'exist': False,
|
||||||
|
'percent': 0,
|
||||||
|
'free': 0,
|
||||||
|
'total': 0
|
||||||
|
}
|
||||||
|
|
||||||
@blueprint.get("/")
|
@blueprint.get("/")
|
||||||
def collect_basic_status():
|
def collect_basic_status():
|
||||||
return jsonify({
|
return jsonify({
|
||||||
|
'disk': {
|
||||||
|
'bili': _get_disk_info(BILILIVE_RECORDER_DIRECTORY),
|
||||||
|
'xigua': _get_disk_info(XIGUALIVE_RECORDER_DIRECTORY)
|
||||||
|
},
|
||||||
'exec': {
|
'exec': {
|
||||||
'ffmpeg': check_exec(FFMPEG_EXEC),
|
'ffmpeg': check_exec(FFMPEG_EXEC),
|
||||||
'danmaku': check_exec(DANMAKU_FACTORY_EXEC),
|
'danmaku': check_exec(DANMAKU_FACTORY_EXEC),
|
||||||
|
@ -124,11 +124,19 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>B站录播姬目录</td>
|
<td>B站录播姬目录</td>
|
||||||
<td>{{ config.recorder.bili_dir }}</td>
|
<td :class="{warning: !collector.basic.disk.bili.exist, success: collector.basic.disk.bili.exist}">{{ config.recorder.bili_dir }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>使用率 {{ collector.basic.disk.bili.percent }}%</td>
|
||||||
|
<td :class="{warning: !collector.basic.disk.bili.exist}">{{ collector.basic.disk.bili.free }}M / {{ collector.basic.disk.bili.total }}M</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>西瓜视频录播目录</td>
|
<td>西瓜视频录播目录</td>
|
||||||
<td>{{ config.recorder.xigua_dir }}</td>
|
<td :class="{warning: !collector.basic.disk.xigua.exist, success: collector.basic.disk.xigua.exist}">{{ config.recorder.xigua_dir }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>使用率 {{ collector.basic.disk.bili.percent }}%</td>
|
||||||
|
<td :class="{warning: !collector.basic.disk.xigua.exist}">{{ collector.basic.disk.xigua.free }}M / {{ collector.basic.disk.xigua.total }}M</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@ -148,8 +156,22 @@
|
|||||||
},
|
},
|
||||||
system: {
|
system: {
|
||||||
os: "",
|
os: "",
|
||||||
|
},
|
||||||
|
disk: {
|
||||||
|
bili: {
|
||||||
|
exist: false,
|
||||||
|
percent: 0,
|
||||||
|
free: 0,
|
||||||
|
total: 0
|
||||||
|
},
|
||||||
|
xigua: {
|
||||||
|
exist: false,
|
||||||
|
percent: 0,
|
||||||
|
free: 0,
|
||||||
|
total: 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
config: {
|
config: {
|
||||||
danmaku: {
|
danmaku: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user