Python 获取CentOS主机信息
Python 获取主机IP地址
|
1
2
3
4
5
6
7
8
9
10
11
|
#!/usr/bin/env python#coding:utf-8import osip=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 osimport subprocessdef load_stat(): loadavg = {} with open("/proc/loadavg",'r') as f: con = f.read().split() print(con)load_stat() |

浙公网安备 33010602011771号