Python 获取主机IP地址
#!/usr/bin/env python
#coding:utf-8 import os ip=os.popen("ifconfig eth0|grep 'inet addr'|awk -F ':' '{print $2}'|awk '{print $1}'")
for i in ip:
print "ip地址为:%s" %(i.strip()) #ip=ip.read().strip()
#print ip
Python获取系统的负载信息
#!/usr/bin/env python
#coding:utf-8 #获取系统的负载信息
import os
import subprocess def load_stat():
loadavg = {}
with open("/proc/loadavg",'r') as f:
con = f.read().split()
print(con)
load_stat()