Skip to content
Snippets Groups Projects
Commit 3dc585ee authored by Stéphane Diemer's avatar Stéphane Diemer
Browse files

Use log instead of print to avoid buffering issues | refs #33502

parent 0bbfa1c6
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@ def main():
os.environ["DEBIAN_FRONTEND"] = "noninteractive"
os.environ["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
print("Checking APT state:")
lg.log("Checking APT state:")
try:
apt = Apt(update=True)
......
......@@ -31,7 +31,7 @@ def test_ssh(host: str) -> bool:
:rtype: bool
"""
print("Checking connection to MediaVault ({}):".format(host))
lg.log("Checking connection to MediaVault ({}):".format(host))
cmd = "ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no {} :".format(
host
......@@ -68,7 +68,7 @@ def test_last_backup_is_recent(server: str) -> bool:
:rtype: bool
"""
print("Checking latest backup age:")
lg.log("Checking latest backup age:")
client = socket.gethostname()
......@@ -146,7 +146,7 @@ def check_local_backup(backup_folder: str) -> bool:
:rtype: bool
"""
print("Checking {}:".format(backup_folder))
lg.log("Checking {}:".format(backup_folder))
all_ok = True
latest = backup_folder / "latest"
......@@ -194,7 +194,7 @@ def check_local_backups(paths: str) -> bool:
processed = set()
for backup_marker in backup_root.glob("*/backup.marker"):
backup_folder = backup_marker.parent
print("Checking local backups in %s" % backup_folder)
lg.log("Checking local backups in %s" % backup_folder)
all_ok = min(check_local_backup(backup_folder), all_ok)
processed.add(backup_folder)
unprocessed = [str(x) for x in subfolders - processed]
......@@ -221,7 +221,7 @@ def main():
elif local_backup_folders:
exit(not check_local_backups(local_backup_folders))
else:
print("No backup_server defined in config, untestable")
lg.log("No backup_server defined in config, untestable")
exit(2)
......
......@@ -131,7 +131,7 @@ def check_resolver(conf: dict, resolvers: set) -> tuple:
def main():
print("Check DNS settings:")
lg.log("Check DNS settings:")
if not supported_platform():
lg.info("platform not supported")
......
......@@ -228,7 +228,7 @@ def main():
warnings = 0
errors = 0
print("Checking email settings:")
lg.log("Checking email settings:")
if not Path("/etc/postfix").exists():
lg.info("postfix is not installed")
......
......@@ -140,7 +140,7 @@ def main():
errors = 0
warnings = 0
print("Checking fail2ban state:")
lg.log("Checking fail2ban state:")
if not check_service_running("fail2ban"):
lg.warning("fail2ban is not running")
warnings += 1
......@@ -149,7 +149,7 @@ def main():
else:
lg.success("fail2ban is running")
print("Checking fail2ban jails:")
lg.log("Checking fail2ban jails:")
jails = get_jails()
for jail in jails:
lg.info("{} jail is running".format(jail))
......
......@@ -16,7 +16,7 @@ from utilities import logging as lg # noqa: E402
def main():
print("Checking nginx status:")
lg.log("Checking nginx status:")
if not Path("/etc/nginx").exists():
lg.info("nginx dir does not exists, skip test")
......
......@@ -181,7 +181,7 @@ def test_vhost(
def main():
print('Check that nginx vhosts are well configured:')
lg.log('Check that nginx vhosts are well configured:')
# check that Nginx dir exists
nginx_dir = '/etc/nginx/sites-enabled'
if not Path(nginx_dir).exists():
......
......@@ -279,7 +279,7 @@ def check_ha(db_conn: dict, errors: int = 0) -> int:
nodes = get_nodes(ha_conf)
# check haproxy
print("Checking local HAProxy frontends:")
lg.log("Checking local HAProxy frontends:")
if not check_listen(db_conn["host"], 54321):
lg.error("HAProxy pgsql-primary frontend is not listening")
errors += 1
......@@ -292,7 +292,7 @@ def check_ha(db_conn: dict, errors: int = 0) -> int:
lg.success("HAProxy pgsql-standby frontend is listening")
# check remotes
print("Checking remote PostgreSQL nodes:")
lg.log("Checking remote PostgreSQL nodes:")
for node in nodes:
node_host = nodes[node]["host"]
node_port = nodes[node]["port"]
......@@ -303,7 +303,7 @@ def check_ha(db_conn: dict, errors: int = 0) -> int:
lg.success("can bind {}:{}".format(node_host, node_port))
# check fenced
print("Checking cluster state:")
lg.log("Checking cluster state:")
fenced, node = check_fenced(nodes)
if fenced:
lg.error("Node `{}` is fenced".format(node))
......@@ -312,7 +312,7 @@ def check_ha(db_conn: dict, errors: int = 0) -> int:
lg.success("No fenced node found")
# check replication
print("Checking replication state:")
lg.log("Checking replication state:")
primary = db_conn.copy()
primary["port"] = 54321
standby = db_conn.copy()
......@@ -343,7 +343,7 @@ def check_local(db_conn: dict, errors: int = 0) -> int:
user = db_conn["user"]
# check listen
print("Checking local PostgreSQL node:")
lg.log("Checking local PostgreSQL node:")
if not check_listen(host, port):
lg.error("cannot connect to {}:{}".format(host, port))
errors += 1
......@@ -351,7 +351,7 @@ def check_local(db_conn: dict, errors: int = 0) -> int:
lg.success("can connect to {}:{}".format(host, port))
# check read
print("Checking read operation:")
lg.log("Checking read operation:")
read_query = "SELECT 1;"
status, info = check_psql(db_conn, read_query)
if not status:
......@@ -367,7 +367,7 @@ def check_local(db_conn: dict, errors: int = 0) -> int:
state = 'primary'
# check write
print("Checking write operation:")
lg.log("Checking write operation:")
if state != "primary":
lg.info("this database is in {} state".format(state))
else:
......@@ -405,7 +405,7 @@ def main():
db_conn.update({"password": db_pass})
# determine if HA setup and run according tests
print("Checking availibility mode:")
lg.log("Checking availibility mode:")
if is_ha():
lg.info("this setup is using a HA database")
errors = check_ha(db_conn)
......
......@@ -22,7 +22,7 @@ from utilities.config import load_conf # noqa: E402
def main():
print("Check TLS settings:")
lg.log("Check TLS settings:")
if subprocess.call(["which", "nginx"], stdout=subprocess.DEVNULL) != 0:
lg.info("nginx not found, skipping test")
......
......@@ -28,7 +28,7 @@ WOWZA_RECOMMENDED_HEAP_SIZE = 2000
def main():
'''Run all checks and exits with corresponding exit code.'''
print('Checking Wowza settings:')
lg.log('Checking Wowza settings:')
warnings = 0
errors = 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment