即可获取windows系统及硬件信息
又可获取linux系统及硬件信息
一站式,全平台!
文章底部直接贴完整代码,先上介绍和函数说明
system-info
基于python3的linux和windows系统信息api
linux and windows system information api
Github: https://github.com/Pure-Peace/system-info
based on: python3.8(基本python3以上即可)
所有api均支持linux和windows
All apis support linux and windows
api列表:
CpuConstants
ExecShellUnix
GetBootTime
GetCpuConstants
GetCpuInfo
GetDiskInfo
GetDiskInfoUnix
GetDiskInfoWindows
GetErrorInfo
GetFullSystemData
GetIoRead
GetIoReadWrite
GetIoWrite
GetLoadAverage
GetMemInfo
GetMemInfoUnix
GetMemInfoWindows
GetNetWork
GetRegValue
GetSystemInfo
GetSystemVersion
GetSystemVersionUnix
GetSystemVersionWindows
ToSizeInt
ToSizeString
UNIX
cpuConstants
md5
readFile
api说明:
当前系统网络使用情况:上传下载速率,收发包
GetNetWork()
both
{
'up': 1.54,
'down': 0.37,
'upTotal': 87688289,
'downTotal': 336439316,
'downPackets': 397399,
'upPackets': 262468
}
当前系统磁盘IO情况:IO读写
GetIoReadWrite()
both
{
'write': 1003332, 'read': 1466368}
当前系统CPU常量
GetCpuConstants()
windows
{
'cpu_count': 1, 'cpu_name': 'AMD Ryzen 5 2500U with Radeon Vega Mobile Gfx ', 'cpu_core': 4, 'cpu_threads': 8}
linux
{
'cpu_count': 1, 'cpu_name': 'Intel(R) Xeon(R) Platinum 8269CY CPU @ 2.50GHz', 'cpu_core': 1, 'cpu_threads': 1}
当前系统CPU信息、使用率
GetCpuInfo()
windows
{
'used': 17.2,
'used_list': [23.8, 12.2, 19.6, 10.2, 20.3, 6.2, 12.6, 30.3],
'cpu_count': 1,
'cpu_name': 'AMD Ryzen 5 2500U with Radeon Vega Mobile Gfx ',
'cpu_core': 4,
'cpu_threads': 8
}
linux
{
'used': 2.0,
'used_list': [3.4],
'cpu_count': 1,
'cpu_name': 'Intel(R) Xeon(R) Platinum 8269CY CPU @ 2.50GHz',
'cpu_core': 1,
'cpu_threads': 1
}
当前系统负载信息
GetLoadAverage()
windows
{
'one': 0,
'five': 0,
'fifteen': 0,
'max': 16,
'limit': 16,
'safe': 12.0
}
linux
{
'one': 0.46,
'five': 0.18,
'fifteen': 0.14,
'max': 2,
'limit': 2,
'safe': 1.5
}
当前系统内存使用情况(linux比windows多了cached和buffers)
GetMemInfo()
windows
{
'memTotal': 7069,
'memFree': 1202,
'memRealUsed': 5866,
'menUsedPercent': '82.98'
}
linux
{
'memTotal': 1838,
'memFree': 181,
'memBuffers': 25,
'memCached': 448,
'memRealUsed': 1184,
'memUsedPercent': 64.41784548422198
}
当前系统磁盘信息
GetDiskInfo()
windows
[{
'path': 'C:/',
'size': {
'total': 85899341824,
'used': 84512485376,
'free': 1386856448,
'percent': 98.4},
'fstype': 'NTFS',
'inodes': False},
{
'path': 'D:/',
'size': {
'total': 413524815872,
'used': 367597920256,
'free': 45926895616,
'percent': 88.9},
'fstype': 'NTFS',
'inodes': False}]
linux
[{
'path': '/',
'size': ['50G', '16G', '32G', '33%'],
'inodes': ['3276800', '261498', '3015302', '8%']
}]
获取系统注册表信息(仅windows可用)
GetRegValue(key: str, subkey: str, value: str)
'''
获取系统注册表信息
Parameters
----------
key : str
类型.
subkey : str
路径.
value : str
key.
Returns
-------
value : Any
DESCRIPTION.
'''
获取系统版本信息
GetSystemVersion()
windows
Windows 10 Home China (build 18362) x64 (Py3.8.5)
linux
CentOS 7.6.1810(Py 3.8.5)
获取系统启动时间及运行时间
GetBootTime()
both
{
'timestamp': 1597574445.835271,
'runtime': 33396.16829442978,
'datetime': '2020-08-17 03:57:22'}
获取全部系统信息
GetFullSystemData()
windows
{
'cpu': {
'used': 16.0,
'used_list': [29.0, 16.4, 30.5, 13.9, 28.1, 16.8, 24.0, 26.7],
'cpu_count': 1,
'cpu_name': 'AMD Ryzen 5 2500U with Radeon Vega Mobile Gfx ',
'cpu_core': 4,
'cpu_threads': 8
},
'load': {
'one': 0,
'five': 0,
'fifteen': 0,
'max': 16,
'limit': 16,
'safe': 12.0
},
'mem': {
'memTotal': 7069,
'memFree': 1181,
'memRealUsed': 5888,
'menUsedPercent': '83.29'
},
'disk': [{
'path': 'C:/',
'size': {
'total': 85899341824,
'used': 84515794944,
'free': 1383546880,
'percent': 98.4
},
'fstype': 'NTFS',
'inodes': False
}, {
'path': 'D:/',
'size': {
'total': 413524815872,
'used': 367597862912,
'free': 45926952960,
'percent': 88.9
},
'fstype': 'NTFS',
'inodes': False
}],
'network': {

本文介绍了一个基于Python的跨平台系统信息API,能够获取Windows和Linux系统的详细信息,包括CPU、内存、磁盘、网络等各项指标,适用于系统监控和资源管理。
最低0.47元/天 解锁文章
268

被折叠的 条评论
为什么被折叠?



