diff --git a/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time b/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time index 3514a5a054..19a67bec36 100755 --- a/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time +++ b/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time @@ -25,7 +25,10 @@ import scripts.lib.setup_path_on_import import django +from typing import Any, Dict, List, Optional + def total_seconds(timedelta): + # type: (datetime.timedelta) -> float return (timedelta.microseconds + (timedelta.seconds + timedelta.days * 24 * 3600) * 10**6) / 10.**6 usage = """Usage: send-receive.py [options] [config] @@ -90,6 +93,7 @@ states = { } def report(state, timestamp, msg=None): + # type: (str, Any, Optional[str]) -> None now = int(time.time()) if msg is None: msg = "send time was %s" % (timestamp,) @@ -101,11 +105,13 @@ def report(state, timestamp, msg=None): exit(states[state]) def send_zulip(sender, message): + # type: (zulip.Client, Dict[str, Any]) -> None result = sender.send_message(message) if result["result"] != "success" and options.nagios: report("CRITICAL", "Error sending Zulip, args were: %s, %s" % (message, result)) def get_zulips(): + # type: () -> List[Dict[str, Any]] global queue_id, last_event_id res = zulip_recipient.get_events(queue_id=queue_id, last_event_id=last_event_id) if 'error' in res.get('result'): diff --git a/puppet/zulip/files/nagios_plugins/zulip_nagios_server/check_postgres_replication_lag b/puppet/zulip/files/nagios_plugins/zulip_nagios_server/check_postgres_replication_lag index 2e56f00e84..3ebb62c8dc 100755 --- a/puppet/zulip/files/nagios_plugins/zulip_nagios_server/check_postgres_replication_lag +++ b/puppet/zulip/files/nagios_plugins/zulip_nagios_server/check_postgres_replication_lag @@ -17,10 +17,12 @@ states = { } def report(state, msg): + # type: (str, str) -> None print("%s: %s" % (state, msg)) exit(states[state]) def get_loc_over_ssh(host, func): + # type: (str, str) -> str try: return subprocess.check_output(['ssh', host, 'psql zulip -t -c "SELECT %s()"' % (func,)], @@ -30,6 +32,7 @@ def get_loc_over_ssh(host, func): report('CRITICAL', 'ssh failed: %s: %s' % (str(e), e.output)) def loc_to_abs_offset(loc_str): + # type: (str) -> int m = re.match(r'^\s*([0-9a-fA-F]+)/([0-9a-fA-F]+)\s*$', loc_str) if not m: raise ValueError("Unknown xlog location format: " + loc_str) diff --git a/puppet/zulip/files/nagios_plugins/zulip_postgres_appdb/check_fts_update_log b/puppet/zulip/files/nagios_plugins/zulip_postgres_appdb/check_fts_update_log index 205e239a67..6f9b39d756 100755 --- a/puppet/zulip/files/nagios_plugins/zulip_postgres_appdb/check_fts_update_log +++ b/puppet/zulip/files/nagios_plugins/zulip_postgres_appdb/check_fts_update_log @@ -22,6 +22,7 @@ states = { } def report(state, num): + # type: (str, str) -> None print("%s: %s rows in fts_update_log table" % (state, num)) exit(states[state]) diff --git a/puppet/zulip/files/nagios_plugins/zulip_postgres_common/check_postgres_backup b/puppet/zulip/files/nagios_plugins/zulip_postgres_common/check_postgres_backup index 63c5c0e34d..1e85030f54 100755 --- a/puppet/zulip/files/nagios_plugins/zulip_postgres_common/check_postgres_backup +++ b/puppet/zulip/files/nagios_plugins/zulip_postgres_common/check_postgres_backup @@ -16,6 +16,7 @@ states = { } def report(state, msg): + # type: (str, str) -> None print("%s: %s" % (state, msg)) exit(states[state])