CPU_INFO
#!/usr/bin/env python
from __future__ import print_function
from collections import OrderedDict
import pprint
def CPUinfo():
''' Return the information in /proc/CPUinfo
as a dictionary in the following format:
CPU_info['proc0']={...}
CPU_info['proc1']={...}
'''
CPUinfo=OrderedDict()
procinfo=OrderedDict()
nprocs = 0
with open('/proc/cpuinfo') as f:
for line in f:
if not line.strip():
# end of one processor
CPUinfo['proc%s' % nprocs] = procinfo
nprocs=nprocs+1
# Reset
procinfo=OrderedDict()
else:
if len(line.split(':')) == 2:
procinfo[line.split(':')[0].strip()] = line.split(':')[1].strip()
else:
procinfo[line.split(':')[0].strip()] = ''
return CPUinfo
if __name__=='__main__':
CPUinfo = CPUinfo()
for processor in CPUinfo.keys():
print(CPUinfo[processor]['model name'])
Memory_info
import cpuinfo,monitor
CPUinfo = cpuinfo.CPUinfo()
for processor in CPUinfo.keys():
cpu = {"cpuinfo":CPUinfo[processor]['model name']}
print (cpu)
meminfo = monitor.meminfo()
memToal = {"memToal": 'Total memory: {0}'.format(meminfo['MemTotal'])}
memFree = {"memFree": 'Free memory: {0}'.format(meminfo['MemFree'])}
print (memToal)
print (memFree)
SysInfo = {"cpu", "memToal", "memFree"}
print (SysInfo)
SSH_Client
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from paramiko import SSHClient
from paramiko import AutoAddPolicy
ip = ''
prot =
user = ''
passwd = ''
cmd = 'pwd'
s = SSHClient()
s.set_missing_host_key_policy(AutoAddPolicy())
s.connect(ip, prot, user, passwd)
stdin,stdout,stderr = s.exec_command(cmd)
print stdout.read()
print stderr.read()
s.close()
/