[AETHER-2398]: Add schedule to iperf tests
Change-Id: I7d18dbd0cbc9c749656b64b4b97644f62006e638
diff --git a/VERSION b/VERSION
index faef31a..39e898a 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.7.0
+0.7.1
diff --git a/edge-monitoring/agent_modem/config.json b/edge-monitoring/agent_modem/config.json
index 0696c8c..6b50a79 100644
--- a/edge-monitoring/agent_modem/config.json
+++ b/edge-monitoring/agent_modem/config.json
@@ -17,5 +17,6 @@
"report_interval": 180,
"log_level": "WARN",
"log_file": "/var/log/edge_monitoring_agent.log",
- "iperf_port": 0
+ "iperf_port": 0,
+ "iperf_schedule": []
}
diff --git a/edge-monitoring/agent_modem/edge_monitoring_agent_modem.py b/edge-monitoring/agent_modem/edge_monitoring_agent_modem.py
index f4b6225..157d41e 100755
--- a/edge-monitoring/agent_modem/edge_monitoring_agent_modem.py
+++ b/edge-monitoring/agent_modem/edge_monitoring_agent_modem.py
@@ -13,6 +13,7 @@
import time
import serial
import subprocess
+import time
from collections import namedtuple
from statistics import median
@@ -281,8 +282,18 @@
'''
Prepares the iperf test.
'''
+ global hour_iperf_scheduled_time_last_ran
speedtest_iperf = {}
speedtest_iperf['cluster'] = {}
+
+ if "iperf_schedule" in CONF._fields and len(CONF.iperf_schedule) > 0:
+ if int(time.strftime("%H")) not in CONF.iperf_schedule: # not in the schedule
+ hour_iperf_scheduled_time_last_ran = -1
+ return None
+ elif int(time.strftime("%H")) == hour_iperf_scheduled_time_last_ran: # already ran this hour
+ return None
+ hour_iperf_scheduled_time_last_ran = int(time.strftime("%H"))
+
speedtest_iperf['cluster']['downlink'] = run_iperf_test(CONF.ips.iperf_server, CONF.iperf_port, 10, True)
speedtest_iperf['cluster']['uplink'] = run_iperf_test(CONF.ips.iperf_server, CONF.iperf_port, 10, False)
@@ -398,7 +409,9 @@
def main():
global cycles
+ global hour_iperf_scheduled_time_last_ran
cycles = 0
+ hour_iperf_scheduled_time_last_ran = -1
for ip in CONF.ips:
if not ip:
continue
@@ -406,7 +419,7 @@
subprocess.check_output("sudo ip route replace {}/32 via {}".format(
ip, CONF.modem.ip_addr), shell=True)
except subprocess.CalledProcessError as e:
- logging.error("Failed to add routes", e.returncode, e.output)
+ logging.error("Failed to add routes: " + str(e.returncode) + str(e.output))
time.sleep(10) # Sleep for 10 seconds before retry
sys.exit(1)