From d11ccac73f8ab2f2c4b51a6556e2111d1f05aa39 Mon Sep 17 00:00:00 2001 From: Alex Kozyrev Date: Fri, 2 Aug 2019 16:12:57 -0400 Subject: [PATCH] Alarm is not raised in case PTP GM is lost "No lock" PTP alarm is raised only when GM is and was not present in a network. Current logic only reaises this alarm in case MAC address of GM is the same as local MAC address. But it is only the case when no external GM ever appeared in a PTP setup. In case GM was present in a network and then lost we need to check port status instead. PTP MAC address still points to an external GM. But port status is changed from SLAVE to LISTENING state. Change-Id: I30365685e6f44566702cc82534ab6ebf0613a731 Closes-bug: 1836884 Signed-off-by: Alex Kozyrev --- monitoring/collectd-extensions/src/ptp.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/monitoring/collectd-extensions/src/ptp.py b/monitoring/collectd-extensions/src/ptp.py index 2aeb85610..5232675a2 100755 --- a/monitoring/collectd-extensions/src/ptp.py +++ b/monitoring/collectd-extensions/src/ptp.py @@ -809,6 +809,22 @@ def read_func(): obj.phase = RUN_PHASE__SAMPLING obj.log_throttle_count = 0 + # Let's read the port status information + # + # sudo /usr/sbin/pmc -u -b 0 'GET PORT_DATA_SET' + # + data = subprocess.check_output([PLUGIN_STATUS_QUERY_EXEC, + '-u', '-b', '0', 'GET PORT_DATA_SET']) + + port_locked = False + obj.resp = data.split('\n') + for line in obj.resp: + if 'portState' in line: + collectd.debug("%s portState : %s" % (PLUGIN, line.split()[1])) + port_state = line.split()[1] + if port_state == 'SLAVE': + port_locked = True + # Let's read the clock info, Grand Master sig and skew # # sudo /usr/sbin/pmc -u -b 0 'GET TIME_STATUS_NP' @@ -840,7 +856,7 @@ def read_func(): # Handle case where this host is the Grand Master # ... or assumes it is. - if my_identity == gm_identity: + if my_identity == gm_identity or port_locked is False: if obj.controller is False: