How to do it...

We can use the paramiko module to create a remote session to a Unix machine. Then, from this session, we can read the remote machine's /proc/cpuinfo file to extract the CPU information.

Listing 6.3 gives the code for printing a remote machine's CPU information, as follows:

#!/usr/bin/env python # Python Network Programming Cookbook, Second Edition -- Chapter - 6 # This program is optimized for Python 3.5.2. # It may run on any other version with/without modifications. # To make it run on Python 2.7.x, needs some changes due to API differences. # Follow the comments inline to make the program work with Python 2. import argparse import getpass import paramiko RECV_BYTES = 4096 COMMAND = 'cat /proc/cpuinfo' def print_remote_cpu_info(hostname, ...

Get Python Network Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.