-
Notifications
You must be signed in to change notification settings - Fork 0
/
iwconfig.py
72 lines (55 loc) · 2.09 KB
/
iwconfig.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import os
import paramiko
import random
import time
import json
import threading
import sys
from datetime import datetime
from threading import Thread
from numpy import median
startTime = datetime.now()
infra_config = json.load(open("config/infra_config.json"))
deployment = json.load(open("config/deployment.json"))
device_types = json.load(open("config/device_types.json"))
deployment_output = json.load(open("dump/infra/deployment_output.json"))
private_networks_dict = infra_config["private_networks"]
public_networks_dict = infra_config["public_networks"]
all_devices_list = infra_config["devices"].keys()
network_dict = {}
coremark_avg = coremark_list = []
coremark_devices_all = {}
print
print "+++++++++++++++++++++++++++++++++++++++++++++++"
print " iwconfig script "
print "+++++++++++++++++++++++++++++++++++++++++++++++"
print
print "********************************************************"
iwconfig_result = []
iwconfig_dict = {}
#p = sys.argv[1]
#print "\n\n\n@@@@@@@@@@@@@@@@@@@@@@@@@@\nNETWORK - {0}\n\n".format(p)
#p_dict = private_networks_dict[p]
#gw = p_dict["gateway"]
gw = "Fog-4"
pub_network = deployment_output[gw]["public_networks"].keys()
gw_host = deployment_output[gw]["public_networks"][pub_network[0]]["ip"]
gw_port = deployment_output[gw]["public_networks"][pub_network[0]]["port"]
gw_user = "pi"
gw_key = "/Users/shreyas/pi_key"
k = paramiko.RSAKey.from_private_key_file(gw_key)
gw_client = paramiko.SSHClient()
gw_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
gw_client.connect(hostname = gw_host, port = gw_port, username = gw_user, pkey = k)
print "Starting iwconfig test in {}".format(gw)
command = "sudo iwconfig wlan0 | grep \"Bit\" | awk '{{print $2}}'"
for i in range(0,1000):
stdin , stdout, stderr = gw_client.exec_command(command)
result = stdout.read()
result = result.split("\n")[0].split("=")[1]
print "{}".format(result)
iwconfig_result.append(float(result))
iwconfig_dict[gw] = iwconfig_result
gw_client.close()
with open('dump/iwconfig_test_{}'.format(p),'w') as file:
file.write(json.dumps(iwconfig_dict))