From 04e21044b91292a22d81d371ef21875324fafc6a Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Wed, 8 May 2024 18:12:59 +0000 Subject: [PATCH] check_send_receive_time: Default --site usefully. This saves us the time of shelling out to a new python process, loading all of Django, and printing one value we could just have read in-process. It is unclear why we ever did it this way. --- .../manifests/prod_app_frontend_once.pp | 2 +- .../manifests/profile/staging_app_frontend.pp | 2 +- .../check_send_receive_time | 23 +++++++++---------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/puppet/kandra/manifests/prod_app_frontend_once.pp b/puppet/kandra/manifests/prod_app_frontend_once.pp index e53750a1ee..989c2e680b 100644 --- a/puppet/kandra/manifests/prod_app_frontend_once.pp +++ b/puppet/kandra/manifests/prod_app_frontend_once.pp @@ -21,7 +21,7 @@ class kandra::prod_app_frontend_once { zulip::cron { 'check_send_receive_time': hour => '*', minute => '*', - command => '/usr/lib/nagios/plugins/zulip_app_frontend/check_send_receive_time --site=https://$(/home/zulip/deployments/current/scripts/get-django-setting NAGIOS_BOT_HOST)', + command => '/usr/lib/nagios/plugins/zulip_app_frontend/check_send_receive_time', use_proxy => false, } zulip::cron { 'check_user_zephyr_mirror_liveness': diff --git a/puppet/kandra/manifests/profile/staging_app_frontend.pp b/puppet/kandra/manifests/profile/staging_app_frontend.pp index 78ebb8ffc5..4ceebea784 100644 --- a/puppet/kandra/manifests/profile/staging_app_frontend.pp +++ b/puppet/kandra/manifests/profile/staging_app_frontend.pp @@ -22,7 +22,7 @@ class kandra::profile::staging_app_frontend inherits kandra::profile::base { zulip::cron { 'check_send_receive_time': hour => '*', minute => '*', - command => '/usr/lib/nagios/plugins/zulip_app_frontend/check_send_receive_time --site=https://$(/home/zulip/deployments/current/scripts/get-django-setting NAGIOS_BOT_HOST)', + command => '/usr/lib/nagios/plugins/zulip_app_frontend/check_send_receive_time', use_proxy => false, } } 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 d2cc2c7d2f..54893513df 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 @@ -24,18 +24,6 @@ setup_path() import django import zulip -usage = """Usage: send-receive.py [options] [config] - - 'config' is optional, if present will return config info. - Otherwise, returns the output data.""" - -parser = argparse.ArgumentParser(usage=usage) -parser.add_argument("--site", default="https://api.zulip.com") - -parser.add_argument("--insecure", action="store_true") - -options = parser.parse_args() - sys.path.append("/home/zulip/deployments/current") os.environ["DJANGO_SETTINGS_MODULE"] = "zproject.settings" @@ -46,6 +34,17 @@ from django.conf import settings from zerver.models.realms import get_realm from zerver.models.users import get_system_bot +usage = """Usage: send-receive.py [options] [config] + + 'config' is optional, if present will return config info. + Otherwise, returns the output data.""" + +parser = argparse.ArgumentParser(usage=usage) +parser.add_argument("--site", default=f"https://{settings.NAGIOS_BOT_HOST}") +parser.add_argument("--insecure", action="store_true") + +options = parser.parse_args() + states = { "OK": 0, "WARNING": 1,