From 9bd9ba93a72855a267b93e8832b716c8b9a8661f Mon Sep 17 00:00:00 2001 From: Cyberes Date: Sat, 16 Sep 2023 13:22:08 -0600 Subject: [PATCH] forgot to update db lag --- check_matrix_synapse.py | 5 +++++ checker/synapse_grafana.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/check_matrix_synapse.py b/check_matrix_synapse.py index 0c69cb0..3643c14 100755 --- a/check_matrix_synapse.py +++ b/check_matrix_synapse.py @@ -120,6 +120,11 @@ def main(): db_lag_MAX = 0.01 if not args.crit else args.crit # in seconds try: db_lag, null_present, raw_data = get_waiting_for_db(args.grafana_api_key, args.interval, args.range, args.grafana_server) + if db_lag == None: + print(f"UNKNOWN: no data for DB lag") + sys.exit(nagios.UNKNOWN) + + null_warn = f'Null data was present for this timeseries, value may be incorrect.\n{raw_data}' if null_present else '' if db_lag > db_lag_MAX: print(f"CRITICAL: DB lag is {db_lag} sec. {null_warn} |'db-lag'={db_lag}s;;;") diff --git a/checker/synapse_grafana.py b/checker/synapse_grafana.py index 56d2426..b47d348 100644 --- a/checker/synapse_grafana.py +++ b/checker/synapse_grafana.py @@ -279,6 +279,8 @@ def get_waiting_for_db(api_key, interval, data_range, endpoint): 'to': 'now', } response = requests.post(f'{endpoint}/api/ds/query', headers={'Authorization': f'Bearer {api_key}'}, json=json_data, verify=False).json() + if not len(response['results']['A']['frames']): + return None, None, None raw_data = response['results']['A']['frames'][0]['data']['values'][1] data = [] null_present = False