Python 获取主机IP地址
1 2 3 4 5 6 7 8 9 10 11 |
#!/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获取系统的负载信息
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#!/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()
|