2016-12-21 8 views
-1

파이썬에서는 paramiko를 사용하여 원격 장치를 ssh 처리합니다. 이제는 기본적으로 두 모듈 간의 처리량 측정 결과 인 결과 출력에서 ​​실시간 데이터 플롯 (시간 대 처리량)을 얻고 싶습니다. 저에게 어떻게 도와 줄 수있는 사람이 있습니까? 미리 감사드립니다. 더 나은 이해를 위해 여기서 공유하는 코드와 결과물.실시간 데이터 플롯을 생성하는 데 도움이 필요합니다.

import sys 
 
import time 
 
import select 
 
import paramiko 
 

 
host = '169.254.115.1' 
 
i = 1 
 

 
# 
 
# Try to connect to the host. 
 
# Retry a few times if it fails. 
 
# 
 
while True: 
 
    print ('Trying to connect to %s (%i/3)' % (host, i)) 
 

 
    try: 
 
     ssh = paramiko.SSHClient() 
 
     ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 
 
     ssh.connect(host, port=22, username='user', password='user') 
 
     print ("Connected to %s" % host) 
 
     break 
 
    except paramiko.AuthenticationException: 
 
     print ("Authentication failed when connecting to %s") % host 
 
     sys.exit(1) 
 
    except: 
 
     print ("Could not SSH to %s, waiting for it to start" % host) 
 
     i += 1 
 
     time.sleep(2) 
 

 
    # If we could not connect within time limit 
 
    if i == 3: 
 
     print ("Could not connect to %s. Giving up") % host 
 
     sys.exit(1) 
 

 
# Send the command (non-blocking) 
 
stdin, stdout, stderr = ssh.exec_command("cd /opt/cohda/test; sudo ./runtest_iperf_tx.sh") 
 

 
# Wait for the command to terminate 
 
while not stdout.channel.exit_status_ready(): 
 
    # Only print data if there is data to read in the channel 
 
    if stdout.channel.recv_ready(): 
 
     rl, wl, xl = select.select([stdout.channel], [], [], 0.0) 
 
     if len(rl) > 0: 
 
      # Print data from stdout 
 
      print (stdout.channel.recv(1024)), 
 
# 
 
# Disconnect from the host 
 
# 
 
print ("Command done, closing SSH connection") 
 
ssh.close()

Throughput or resultant output

+0

지금까지 작성한 코드 표시 –

+0

다시 내 게시물을보고 클릭하십시오. 여기 코드를 참조하십시오. –

+1

코드를 그림에있는 텍스트가 아닌 텍스트로 붙여 넣어야합니다. – IanS

답변

0

나는이 문제 임무를 한 경우에, 나는 당신이 파이썬으로 코딩 할 수 있기 때문에 보케 사용을 고려 것이고, 시각화 데이터 업데이트를 스트리밍 할 수 있습니다 : http://bokeh.pydata.org/en/latest/

그러나 반드시 여러 가지 방법이 있으며 많은 대안이 있습니다.