...
In /home/pi, you will find the Python script wireless.py. The contents of the script are the following:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
#!/usr/bin/python
import subprocess
import datetime
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
def return_command_output(command):
proc = subprocess.Popen(command, stdout = subprocess.PIPE, shell = True)
(out, err) = proc.communicate()
out_without_carriage_return = out.rstrip('\n')
return out_without_carriage_return
def parse_iwconfig():
command1 = "sudo iwconfig wlan0 | grep \"Link Quality\""
command1_output = return_command_output(command1)
command1_output = ' '.join(command1_output.split())
command1_parsed = command1_output.split(" ")
link_quality = command1_parsed[1].split("=")[1]
link_quality = link_quality.split("/")[0]
signal_level = command1_parsed[3].split("=")[1]
command2 = "sudo iwconfig wlan0 | grep \"Tx-Power\""
command2_output = return_command_output(command2)
command2_output = ' '.join(command2_output.split())
command2_parsed = command2_output.split(" ")
bit_rate = command2_parsed[1].split("=")[1]
tx_power = command2_parsed[3].split("=")[1]
timestamp = int(datetime.datetime.now().strftime("%s")) * 1000
probeNo = "WiFiMon_Hardware_Probe_Number"
headers = {'content-type':"application/json"}
data = "{\"timestamp\":" + str(timestamp) + ", \"bitRate\":" + bit_rate + ", \"txPower\":" + tx_power + ", \"linkQuality\":" + link_quality + ", \"signalLevel\":" + signal_level + ", \"probeNo\":\"" + probeNo + "\"}"
try:
session = requests.Session()
session.verify = False
session.post(url='https://WiFiMon_Analysis_Server_FQDN:8443/wifimon/probes/', data=data, headers=headers, timeout=15)
except:
pass
return None
if __name__ == "__main__":
parse_iwconfig() |
Edit the file to change the URL pointing to the WiFiMon Analysis Station and change the designated number of the testtool. The name of the testtool is "NetTest-x". Please, change only character x by including the sequence number dedicated to your WiFiMon Hardware Probe. For example, if the WiFiMon Hardware Probe has been assigned number 1, enter "NetTest-1".
...