日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

跨平台 获取系统信息的python库 http://support.hyperic.com/disp

發布時間:2025/3/19 python 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 跨平台 获取系统信息的python库 http://support.hyperic.com/disp 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

跨平臺 獲取系統信息的python庫 http://support.hyperic.com/disp - 張沈鵬,在路上... - ITeye技術網站

跨平臺 獲取系統信息的python庫 http://support.hyperic.com/disp

博客分類:PythonPythonGitLinuxOSWindowsThe Sigar API provides a portable interface for gathering system information such as:



??? * System memory, swap, cpu, load average, uptime, logins

??? * Per-process memory, cpu, credential info, state, arguments, environment, open files

??? * File system detection and metrics

??? * Network interface detection, configuration info and metrics

??? * Network route and connection tables



Linux Windows 都可以用





內存檢測的庫 http://support.hyperic.com/display/SIGAR/Home

git clone git://github.com/hyperic/sigar.git sigar.git

./autogen.sh

./configure

make

make install

cd bindings/python/

python setup.py install









xxx@xxxx~/hypertable/sigar.git/bindings/python/examples $ cat free.py

import os, sigar;



sg = sigar.open()

mem = sg.mem()

swap = sg.swap()

sg.close()



print "\tTotal\tUsed\tFree"



print "Mem:\t",\

??? (mem.total() / 1024), \

??? (mem.used() / 1024), \

??? (mem.free() / 1024)



print "Swap:\t", \

??? (swap.total() / 1024), \

??? (swap.used() / 1024), \

??? (swap.free() / 1024)



print "RAM:\t", mem.ram(), "MB"



xxx@xxxx~/hypertable/sigar.git/bindings/python/examples $ python free.py

Total Used Free

Mem: 33018784 20918484 12100300

Swap: 0 0 0

RAM: 32248 MB

xxx@xxxx~/hypertable/sigar.git/bindings/python/examples $ cat df.py

import os, sigar;



sg = sigar.open()

fslist = sg.file_system_list()



def format_size(size):

??? return sigar.format_size(size * 1024)



print 'Filesystem\tSize\tUsed\tAvail\tUse%\tMounted on\tType\n'



for fs in fslist:

??? dir_name = fs.dir_name()

??? usage = sg.file_system_usage(dir_name)



??? total = usage.total()

??? used = total - usage.free()

??? avail = usage.avail()

??? pct = usage.use_percent() * 100

??? if pct == 0.0:

??????? pct = '-'



??? print fs.dev_name(), format_size(total), format_size(used), format_size(avail),\

??????? pct, dir_name, fs.sys_type_name(), '/', fs.type_name()

xxx@xxxx~/hypertable/sigar.git/bindings/python/examples $ python df.py

Filesystem Size Used Avail Use% Mounted on Type



/dev/md/2? 37G? 26G? 12G 69.0 / reiserfs / local

proc?? 0??? 0??? 0? - /proc proc / none

sysfs?? 0??? 0??? 0? - /sys sysfs / none

udev? 10M 208K 9.8M - /dev tmpfs / none

devpts?? 0??? 0??? 0? - /dev/pts devpts / none

/dev/sda4 391G 321G? 70G 83.0 /log2 reiserfs / local

/dev/sdd1 931G 281G 650G 31.0 /mp4 reiserfs / local

/dev/sde1 1.4T 1.3T? 75G 95.0 /backup1 xfs / local

/dev/sdf1 1.4T 157G 1.2T 12.0 /backup2 xfs / local

shm? 16G?? 0?? 16G - /dev/shm tmpfs / none

tmpfs? 40M?? 0?? 40M - /tmplog tmpfs / none

usbfs?? 0??? 0??? 0? - /proc/bus/usb usbfs / none

/dev/sdb1 1.4T 566G 831G 41.0 /mp5 vfat / local

/dev/sdc1 200G? 82G 118G 41.0 /mp3 reiserfs / local

總結

以上是生活随笔為你收集整理的跨平台 获取系统信息的python库 http://support.hyperic.com/disp的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。