how to store the output of a telnet session on a local machine, so that it can be used further for calculations??

#!/usr/bin/python
import telnetlib
import logging
import os
import time

# set up logging to file - see previous section for more details
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M',
filename='error_log.txt',
filemode='w')

# define a Handler which writes INFO messages or higher to the sys.stderr
console = logging.StreamHandler()
console.setLevel(logging.INFO)

# set a format which is simpler for console use
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')

# tell the handler to use this format
console.setFormatter(formatter)

# add the handler to the root logger
logging.getLogger('').addHandler(console)

host='192.168.5.181'

telnet= telnetlib.Telnet("%s\n"%host)
user="root"
password="arct1c"


#print "** logging**"
telnet.read_until("login: ")
telnet.write(user+'\r\n')
telnet.read_until("Password: ")
telnet.write(password+'\r\n')
#print "**logged in ***"

time.sleep(10)
#read free memory usage

logging.info("free memory usage : ")
telnet.write("free\n")

#process memory usuage
logging.info("process memory usuage:")
telnet.write("cat /proc/meminfo\n")
time.sleep(40)

# %CPU usage
logging.info("%CPU usage:")
telnet.write("top -b -n 1\n")

telnet.write("exit\n")
logging.info( telnet.read_all())

time.sleep(40)
os.system('snmpwalk -v2c -c arct1c 192.168.5.181 .1.3.6.1.4.1.18489.1.2.1.1')

telnet= telnetlib.Telnet("%s\n"%host)
user="root"
password="arct1c"

telnet.read_until("login: ")
telnet.write(user+'\r\n')
telnet.read_until("Password: ")
telnet.write(password+'\r\n')

logging.info("free memory usage : ")
telnet.write("free\n")

logging.info("process memory usuage:")
telnet.write("cat /proc/meminfo\n")

logging.info("%CPU usage:")
telnet.write("top -b -n 1\n")
logging.info( telnet.read_all())


i want to calculate the difference before and after snmp walk


plz help me............

This question has already been answered. Start a new discussion instead.