2016-12-21 6 views
-1

Pythonでは、私はparamikoを使ってリモートデバイスをsshしています。さて、私は、2つのモジュール間の基本的にスループット測定である結果の出力からリアルタイムデータプロット(時間対スループット)を得たいと思います。誰でも私にそれを手助けすることができますか?前もって感謝します。コードと結果の出力は、ここであなたの理解を深めるために共有しています。リアルタイムデータプロットを生成するための支援が必要

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

私はこの問題を担当していた場合、私はそれはあなたがPythonでコーディングすることができますので、ボケを使用して検討すると、ビジュアライゼーションにデータの更新をストリーミングすることができます。http://bokeh.pydata.org/en/latest/

しかし、確かにそれを行う方法はたくさんありますが、多くの選択肢があります。

関連する問題