From 20eab264cf1a009f4994a57e611dd696fd95b10e Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Mon, 7 Jun 2021 23:29:08 -0700 Subject: [PATCH] puppet: Remove dependency on scripts.lib.zulip_tools. ab130ceb35d4 added a dependency on scripts.lib.zulip_tools; however, check_postgresql_replication_lag is run on hosts which do not have a zulip tree installed. Inline the simple functions that were imported. --- .../check_postgresql_replication_lag | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/puppet/zulip/files/nagios_plugins/zulip_postgresql/check_postgresql_replication_lag b/puppet/zulip/files/nagios_plugins/zulip_postgresql/check_postgresql_replication_lag index 9517b64dc2..e3da831f3c 100755 --- a/puppet/zulip/files/nagios_plugins/zulip_postgresql/check_postgresql_replication_lag +++ b/puppet/zulip/files/nagios_plugins/zulip_postgresql/check_postgresql_replication_lag @@ -4,14 +4,27 @@ replica PostgreSQL servers' xlog location. Requires that the user this connects to PostgreSQL as has been granted the `pg_monitor` role. +This can only use stdlib modules from python. """ +import configparser import re import subprocess from typing import Dict, List -from scripts.lib.zulip_tools import get_config, get_config_file -config_file = get_config_file() +def get_config( + config_file: configparser.RawConfigParser, + section: str, + key: str, + default_value: str = "", +) -> str: + if config_file.has_option(section, key): + return config_file.get(section, key) + return default_value + + +config_file = configparser.RawConfigParser() +config_file.read("/etc/zulip/zulip.conf") states = { "OK": 0,