Skip to content

Commit

Permalink
fix DNS health check alarm not clear after reboot issue (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndam-bluecat authored Jan 16, 2023
1 parent 48e9680 commit bb60ae6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
13 changes: 8 additions & 5 deletions syslog_monitoring/Alarm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,24 @@
scheduler.configure(executors=executors, job_defaults=job_defaults)


NtpClocksUnsynchronized = {}
interval, threshold, bdds_servers = get_ntp_config_data()
alm_hostname = get_alarm_host_name()


def set_or_clear_alarm_ntp_clock_unsynchronized(case, source, target):
from .alarm_management import (
key_pair,
NTPCLOCKSUNSYNCHRONIZED
)
key = "{0}_{1}".format(source, target)
if case.lower() == "set":
if key in NtpClocksUnsynchronized.keys():
if key in key_pair[NTPCLOCKSUNSYNCHRONIZED].keys():
return None, None
NtpClocksUnsynchronized.update({key: {}})
key_pair[NTPCLOCKSUNSYNCHRONIZED].update({key: {}})
return "set", key
elif case.lower() == "clear":
if key in NtpClocksUnsynchronized.keys():
del NtpClocksUnsynchronized[key]
if key in key_pair[NTPCLOCKSUNSYNCHRONIZED].keys():
del key_pair[NTPCLOCKSUNSYNCHRONIZED][key]
return "clear", key
return None, None
return None, None
Expand Down
6 changes: 6 additions & 0 deletions syslog_monitoring/Alarm/alarm_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
STORAGEREADONLY = "StorageReadOnly"
ZONETRANSFERFAILED = "ZoneTransferFailed"
TCPCONNECTIONLIMITEXCEEDED = "TcpConnectionLimitExceeded"
TESTQUERYFAILED = "TestQueryFailed"
NTPCLOCKSUNSYNCHRONIZED = "NtpClocksUnsynchronized"

key_pair = {
LOADCONFIGURATIONFAILED: {
Expand All @@ -60,6 +62,10 @@
ZONETRANSFERFAILED: {
},
TCPCONNECTIONLIMITEXCEEDED: {
},
TESTQUERYFAILED: {
},
NTPCLOCKSUNSYNCHRONIZED: {
}
}

Expand Down
15 changes: 8 additions & 7 deletions syslog_monitoring/DNSHealthCheck/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
scheduler = BackgroundScheduler()
scheduler.configure(executors=executors, job_defaults=job_defaults)

TestQueryFailed = {

}

class ExecutorManager(object):

Expand Down Expand Up @@ -101,15 +98,19 @@ def query_dns():


def set_or_clear_alarm_test_query_failed(case, source, target):
from Alarm.alarm_management import (
key_pair,
TESTQUERYFAILED
)
key = "{0}_{1}".format(source, target)
if case.lower() == "set":
if key in TestQueryFailed.keys():
if key in key_pair[TESTQUERYFAILED].keys():
return None, None
TestQueryFailed.update({key:{}})
key_pair[TESTQUERYFAILED].update({key:{}})
return "set", key
elif case.lower() == "clear":
if key in TestQueryFailed.keys():
del TestQueryFailed[key]
if key in key_pair[TESTQUERYFAILED].keys():
del key_pair[TESTQUERYFAILED][key]
return "clear", key
return None, None
return None, None
Expand Down

0 comments on commit bb60ae6

Please sign in to comment.