diff --git a/checker.py b/checker.py index 691ce82..9e365f0 100644 --- a/checker.py +++ b/checker.py @@ -136,21 +136,26 @@ def check_logs(log_handler): logs = subprocess.run(['docker', 'logs', '--since', '10m', 'infernet-node'], capture_output=True, text=True, check=True) log_content = logs.stdout except subprocess.CalledProcessError as e: - raise RuntimeError(f"Error running docker logs: {e}") from e + raise RuntimeError(f"Error running docker logs: {e}") - subscription_pattern = r'Ignored subscription creation.*id=(\d+)' - matches = re.finditer(subscription_pattern, log_content) - last_id = None + subscription_pattern = r'Ignored subscription creation.*id=(\d+).*err=([^\s]+)' + matches = list(re.finditer(subscription_pattern, log_content)) - for match in matches: - last_id = match.group(1) + if not matches: + log_handler.info("No subscription messages found") + return {"status": "Idle"} - if last_id: - log_handler.info(f"Found last subscription message, id: {last_id}") - return {"status": f"Subscription {last_id}"} + last_match = matches[-1] + last_id = last_match.group(1) + error_type = last_match.group(2) - log_handler.info("No subscription message found") - return {"status": "Idle"} + if error_type == "Container-set not supported": + status = f"Container error (id: {last_id})" + else: + status = f"Subscription {last_id}" + + log_handler.info(f"Found subscription message: id={last_id}, error={error_type}") + return {"status": status} if __name__ == "__main__": colorama.init(autoreset=True)