Clear counters before run
Change-Id: I9900df3e0c86063132b181b8fd0cabbac5439361
diff --git a/VERSION b/VERSION
index a48658c..a597e4f 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.7.13
+0.7.14
diff --git a/edge-monitoring/agent_modem/edge_monitoring_agent_modem.py b/edge-monitoring/agent_modem/edge_monitoring_agent_modem.py
index 0fe16d0..c1a8042 100755
--- a/edge-monitoring/agent_modem/edge_monitoring_agent_modem.py
+++ b/edge-monitoring/agent_modem/edge_monitoring_agent_modem.py
@@ -16,6 +16,7 @@
from collections import namedtuple
from statistics import median
import xml.etree.ElementTree as ET
+import traceback
'''
"Simple" script that checks Aether network operational status periodically
@@ -192,7 +193,7 @@
else: # run default user plane test
try:
subprocess.check_output(
- "ping -c 3 " + CONF.ips.dns + ">/dev/null 2>&1",
+ "ping -I {} -c 3 {} >/dev/null 2>&1".format(CONF.modem.iface, CONF.ips.dns),
shell=True)
return None, True
except subprocess.CalledProcessError as e:
@@ -223,9 +224,8 @@
return result, True
try:
logging.debug("Pinging {}".format(ip))
- pingOutput = subprocess.check_output(
- "ping -c " + str(count) + " " + \
- ip, shell=True).decode("UTF-8").split()
+ pingCmd = "ping -I {} -c {} {}".format(CONF.modem.iface, str(count), ip)
+ pingOutput = subprocess.check_output(pingCmd, shell=True).decode("UTF-8").split()
result['transmitted'] = int(pingOutput[-15])
result['received'] = int(pingOutput[-12])
if result['received'] > 0:
@@ -247,6 +247,7 @@
return result, False
except Exception as e:
logging.error("Ping test failed for " + ip + ": %s", e)
+ traceback.print_exc()
return result, False
return result, True
@@ -353,8 +354,8 @@
rsrq = int(tmp_rsrq.strip())
rsrp = int(tmp_rsrp.strip().split(' ')[0])
result = {
- 'rsrq': 0 if rsrq is 255 else rsrq,
- 'rsrp': 0 if rsrp is 255 else rsrp
+ 'rsrq': 0 if rsrq == 255 else rsrq,
+ 'rsrp': 0 if rsrp == 255 else rsrp
}
return result
@@ -486,14 +487,16 @@
c.perform()
logging.info("Report sent via " + interface + "!")
except Exception as e:
+ logging.error("Failed to send report in-band: " + str(e))
+ counters['report_send_error'] += 1
if report_via_modem and report_via_given_iface:
- logging.warning("Sending report via modem failed. Attempting to send report via " + str(CONF.report_iface) + ".")
+ logging.warning("Attempting to send report via " + str(CONF.report_iface) + ".")
interface = CONF.report_iface
c.setopt(pycurl.INTERFACE, interface)
c.perform()
logging.info("Report sent via " + interface + "!")
else:
- logging.error("Failed to send report: " + str(e))
+ logging.error("Failed to send report out-of-band: " + str(e))
c.close()
except Exception as e:
logging.error("Failed to send report: " + str(e))
@@ -535,15 +538,22 @@
'modem_cesq_error': 0,
'dry_run_ping_error': 0,
'ping_error': 0,
- 'iperf_error': 0
+ 'iperf_error': 0,
+ 'report_send_error': 0
}
+def clear_counters(counters):
+ for x in counters:
+ counters[x] = 0
+
def main():
global cycles
global hour_iperf_scheduled_time_last_ran
cycles = 0
hour_iperf_scheduled_time_last_ran = -1
+ counters = init_counters()
+
try:
if "report_in_band" in CONF._fields and \
"iface" in CONF.modem._fields and CONF.modem.iface:
@@ -576,7 +586,6 @@
modem = None
connect_retries = 0
- counters = init_counters()
while True:
dongle_retries = 0
dongle_stats = get_dongle_stats(counters)
@@ -619,6 +628,7 @@
speedtest_iperf = iperf_test(counters)
report_status(counters, signal_quality, dongle_stats, cp_state, up_state, ping_latency, speedtest_iperf)
+ counters = clear_counters(counters)
time.sleep(CONF.report_interval)
modem.close()