Soften NTP alarm language for syncing with peer
In IPv6 setup, NTP refid is hash result of reference's IPv6 address. In such case, do not try to intepret the refid to tell if the peer has a reliable source. When the NTP service uses peer controller as reference, the alarm is a reminder to the admin user instead of reporting an issue. This is a minor alarm. Closes-Bug: 1834071 Change-Id: Ia2770ba7ed77640e58e8c35254a504b57487ff8f Signed-off-by: Bin Qian <bin.qian@windriver.com>
This commit is contained in:
parent
3876f288e1
commit
6218755c3d
@ -88,6 +88,7 @@ class NtpqObject:
|
|||||||
reachable_servers = [] # list of reachable servers
|
reachable_servers = [] # list of reachable servers
|
||||||
selected_server = 'None' # the ip address of the selected server
|
selected_server = 'None' # the ip address of the selected server
|
||||||
selected_server_save = 'None' # the last selected server ; note change
|
selected_server_save = 'None' # the last selected server ; note change
|
||||||
|
peer_selected = False # true when peer is selected
|
||||||
|
|
||||||
# variables used to raise alarms to FM
|
# variables used to raise alarms to FM
|
||||||
suppression = True
|
suppression = True
|
||||||
@ -161,10 +162,16 @@ def _raise_alarm(ip=None):
|
|||||||
if obj.alarm_raised is True:
|
if obj.alarm_raised is True:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
reason = "NTP configuration does not contain any valid "
|
if obj.peer_selected:
|
||||||
reason += "or reachable NTP servers."
|
reason = "NTP cannot reach external time source; " \
|
||||||
|
"syncing with peer controller only"
|
||||||
|
fm_severity = fm_constants.FM_ALARM_SEVERITY_MINOR
|
||||||
|
else:
|
||||||
|
reason = "NTP configuration does not contain any valid "
|
||||||
|
reason += "or reachable NTP servers."
|
||||||
|
fm_severity = fm_constants.FM_ALARM_SEVERITY_MAJOR
|
||||||
|
|
||||||
eid = obj.base_eid
|
eid = obj.base_eid
|
||||||
fm_severity = fm_constants.FM_ALARM_SEVERITY_MAJOR
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
reason = "NTP address "
|
reason = "NTP address "
|
||||||
@ -725,7 +732,14 @@ def read_func():
|
|||||||
cols = obj.ntpq[i].split(' ')
|
cols = obj.ntpq[i].split(' ')
|
||||||
ip = cols[0][1:]
|
ip = cols[0][1:]
|
||||||
if ip:
|
if ip:
|
||||||
if _is_controller(ip) is False:
|
ip_family = _is_ip_address(ip)
|
||||||
|
obj.peer_selected = _is_controller(ip)
|
||||||
|
if ip != obj.selected_server and obj.alarm_raised is True:
|
||||||
|
# a new ntp server is selected, old alarm may not be
|
||||||
|
# valid
|
||||||
|
_clear_base_alarm()
|
||||||
|
obj.alarm_raised = False
|
||||||
|
if obj.peer_selected is False:
|
||||||
if obj.selected_server:
|
if obj.selected_server:
|
||||||
# done update the selected server if more selections
|
# done update the selected server if more selections
|
||||||
# are found. go with the first one found.
|
# are found. go with the first one found.
|
||||||
@ -747,15 +761,12 @@ def read_func():
|
|||||||
|
|
||||||
if refid not in ('', '127.0.0.1') and \
|
if refid not in ('', '127.0.0.1') and \
|
||||||
not _is_controller(refid) and \
|
not _is_controller(refid) and \
|
||||||
socket.AF_INET == _is_ip_address(ip):
|
socket.AF_INET == ip_family:
|
||||||
# ipv4, peer controller refer to a time source is not
|
# ipv4, peer controller refer to a time source is not
|
||||||
# itself or a controller (this node)
|
# itself or a controller (this node)
|
||||||
obj.selected_server = ip
|
obj.selected_server = ip
|
||||||
collectd.debug("peer controller has a reliable "
|
collectd.debug("peer controller has a reliable "
|
||||||
"source")
|
"source")
|
||||||
else:
|
|
||||||
collectd.debug("peer controller does not have a "
|
|
||||||
"reliable source")
|
|
||||||
|
|
||||||
# anything else is unreachable
|
# anything else is unreachable
|
||||||
else:
|
else:
|
||||||
@ -796,7 +807,10 @@ def read_func():
|
|||||||
_clear_base_alarm()
|
_clear_base_alarm()
|
||||||
|
|
||||||
elif obj.alarm_raised is False:
|
elif obj.alarm_raised is False:
|
||||||
collectd.error("%s no selected server" % PLUGIN)
|
if obj.peer_selected:
|
||||||
|
collectd.info("%s peer is selected" % PLUGIN)
|
||||||
|
else:
|
||||||
|
collectd.error("%s no selected server" % PLUGIN)
|
||||||
if _raise_alarm() is False:
|
if _raise_alarm() is False:
|
||||||
obj.selected_server_save = 'None'
|
obj.selected_server_save = 'None'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user