53 lines
1.7 KiB
Diff
53 lines
1.7 KiB
Diff
From 50941c1ad6ad3be2d8b1826a690df73227e15831 Mon Sep 17 00:00:00 2001
|
|
From: xuezhixin <xuezhixin@uniontech.com>
|
|
Date: Fri, 10 Nov 2023 15:09:48 +0800
|
|
Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=B5=8B=E7=B3=BB=E7=BB=9F=E7=9A=84?=
|
|
=?UTF-8?q?=E7=A3=81=E7=9B=98=E5=8F=AF=E7=94=A8=E7=A9=BA=E9=97=B4?=
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
---
|
|
sysmig_agent/share.py | 28 ++++++++++++++++++++++++++++
|
|
1 file changed, 28 insertions(+)
|
|
|
|
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
|
|
index 9e7bd35..0bd73f6 100644
|
|
--- a/sysmig_agent/share.py
|
|
+++ b/sysmig_agent/share.py
|
|
@@ -484,3 +484,31 @@ def run_subprocess(cmd="", print_cmd=True, print_output=True):
|
|
return_code = process.poll()
|
|
return output, return_code
|
|
|
|
+
|
|
+
|
|
+def os_storage():
|
|
+ """
|
|
+ 判断系统剩余空间大小
|
|
+ :return: GB
|
|
+ """
|
|
+ path = '/var/cache'
|
|
+ stat = os.statvfs(path)
|
|
+ CACHE_SPACE = 10.0
|
|
+ state = 1
|
|
+ ava_cache = format(stat.f_bavail * stat.f_frsize / 1024 // 1024 / 1024, '.1f')
|
|
+ if stat:
|
|
+ # with open(PRE_MIG,'a+') as pf:
|
|
+ # pf.write('/var/cache可用空间为'+ava_cache+'GB')
|
|
+ # pf.close()
|
|
+ if float(ava_cache) >= CACHE_SPACE:
|
|
+ state = 0
|
|
+ return ava_cache
|
|
+ # data = '可用空间为'+ava_cache+'GB'
|
|
+ else:
|
|
+ return ava_cache
|
|
+ # data = '可用空间为' + ava_cache + 'GB,请清理/var/cache的空间后重试。'
|
|
+ else:
|
|
+ return ava_cache
|
|
+ # data = '可用空间为'+ava_cache+'GB,请清理/var/cache的空间后重试。'
|
|
+ # return list_to_json(keylist,valuelist)
|
|
+
|
|
--
|
|
2.20.1
|
|
|