From 23a620274d349cac644af6e572c20a9da32d19cb Mon Sep 17 00:00:00 2001 From: cppla Date: Sat, 28 Feb 2026 14:10:35 +0800 Subject: [PATCH] =?UTF-8?q?linux=E5=B0=9D=E8=AF=95=E4=BB=8Eos=E4=B8=AD?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clients/client-psutil.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/clients/client-psutil.py b/clients/client-psutil.py index b0d98b3..14f3a4e 100755 --- a/clients/client-psutil.py +++ b/clients/client-psutil.py @@ -521,13 +521,16 @@ if __name__ == '__main__': elif 'bsd' in sysname: os_name = 'bsd' elif sysname.startswith('linux'): - # try distro if available - os_name = 'linux' + # try distro from os-release try: - import distro # optional - os_name = distro.id() or 'linux' + with open('/etc/os-release') as f: + for line in f: + if line.startswith('ID='): + val = line.strip().split('=',1)[1].strip().strip('"') + if val: os_name = val + break except Exception: - pass + os_name = 'linux' else: os_name = sysname or 'unknown' except Exception: