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.
This commit is contained in:
Alex Vandiver 2024-05-08 18:12:59 +00:00 committed by Tim Abbott
parent 16a53d08fd
commit 04e21044b9
3 changed files with 13 additions and 14 deletions

View File

@ -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':

View File

@ -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,
}
}

View File

@ -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,