|
Description:
This code snippet shows how to kich off a performance data gathering shell script with telnetlib and download the data back to a local workstation with ftplib.
Source: Text Source
import telnetlib
from ftplib import FTP
LOG_GRABBER='/users/perfmon/grabLogs.sh'
LOG_OUT='logstats.txt'
prdLogBox='142.178.1.3'
uid = 'uid'
pwd = 'yourpassword'
tn = telnetlib.Telnet(prdLogBox)
tn.read_until("login: ")
tn.write(uid + "\n")
tn.read_until("Password:")
tn.write(pwd + "\n")
tn.write(LOG_GRABBER+"\n")
tn.write("exit\n")
tn.close()
ftp=FTP(prdLogBox)
ftp.login(uid,pwd)
logOut=open(LOG_OUT,'wb+')
ftp.retrbinary('RETR '+LOG_OUT, logOut.write)
ftp.quit()
logOut.close()
Discussion:
This recipe is used for performance monitoring in real procution environment. It is non-intrusive as the timing log (LOG4J actually) has been produced daily and copy to a differnt server during the non-rush hour.
Gather timing statistics in log daily from a production environment during the non rush hour, then download the results, put the results into a RDBMS, calculate the statistics such as min,max,avg,median, deviation.
|